#[non_exhaustive]pub struct MockAgentConfig {
pub agent: AgentConfig,
pub mock: MockConnectionStrategy,
}Expand description
Configuration for the deterministic, offline mock backend.
Pairs the generic AgentConfig (hooks, tools, policies, triggers) with a
scripted MockConnectionStrategy so an Agent can be driven entirely
offline — no network, no API key, no LLM. The parallel of
GeminiAgentConfig, always available (no feature flag). Build the
strategy with MockConnection::builder.
§Examples
use localharness::{Agent, policy};
use localharness::backends::mock::{MockAgentConfig, MockConnection};
let backend = MockConnection::builder()
.turn(|t| t.text("the scripted answer"))
.build();
let agent = Agent::start_mock(MockAgentConfig::new(backend)).await?;
assert_eq!(agent.chat("anything").await?.text().await?, "the scripted answer");
agent.shutdown().await?;Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.agent: AgentConfigBackend-agnostic settings (tools, policies, triggers).
mock: MockConnectionStrategyThe scripted mock backend strategy.
Implementations§
Source§impl MockAgentConfig
impl MockAgentConfig
Sourcepub fn new(mock: MockConnectionStrategy) -> Self
pub fn new(mock: MockConnectionStrategy) -> Self
Create a mock agent configuration from a scripted backend strategy
(built via MockConnection::builder).
Sourcepub fn with_system_instructions(
self,
instr: impl Into<SystemInstructions>,
) -> Self
pub fn with_system_instructions( self, instr: impl Into<SystemInstructions>, ) -> Self
Set the system instructions (recorded on the agent config; the mock ignores them — its turns are scripted, not generated).
Sourcepub fn with_capabilities(self, cap: CapabilitiesConfig) -> Self
pub fn with_capabilities(self, cap: CapabilitiesConfig) -> Self
Configure which built-in tools are enabled.
Sourcepub fn with_policies(self, policies: Vec<Policy>) -> Self
pub fn with_policies(self, policies: Vec<Policy>) -> Self
Set the safety policies for tool execution.
Sourcepub fn with_pre_tool_hook(self, hook: Arc<dyn PreToolCallDecideHook>) -> Self
pub fn with_pre_tool_hook(self, hook: Arc<dyn PreToolCallDecideHook>) -> Self
Register a custom pre-tool-call decide hook (see
AgentConfig::with_pre_tool_hook).
Sourcepub fn with_post_tool_hook(self, hook: Arc<dyn PostToolCallHook>) -> Self
pub fn with_post_tool_hook(self, hook: Arc<dyn PostToolCallHook>) -> Self
Register a custom post-tool-call inspect hook (see
AgentConfig::with_post_tool_hook).
Sourcepub fn with_workspace(self, ws: impl Into<PathBuf>) -> Self
pub fn with_workspace(self, ws: impl Into<PathBuf>) -> Self
Add a workspace root for path-containment enforcement.
Sourcepub fn with_trigger(self, trigger: Arc<dyn Trigger>) -> Self
pub fn with_trigger(self, trigger: Arc<dyn Trigger>) -> Self
Register a background trigger.