pub struct AgentConfig {Show 49 fields
pub name: String,
pub model: Option<String>,
pub provider_id: String,
pub model_name: String,
pub temperature: f32,
pub max_tokens: i32,
pub system_prompt_override: Option<String>,
pub persona: Option<String>,
pub max_react_iterations: Option<i32>,
pub max_scratchpad_size: Option<i32>,
pub max_retries: Option<i32>,
pub max_concurrent_jobs: Option<usize>,
pub supports_native_thinking: bool,
pub frequency_penalty: Option<f32>,
pub presence_penalty: Option<f32>,
pub textual_feedback: bool,
pub use_streaming: bool,
pub merge_system_prompt: bool,
pub unwrap_hallucinated_tool_calls: bool,
pub repair_invalid_escapes: bool,
pub scratchpad_limit: i32,
pub scratchpad_squeeze_fraction: f64,
pub compact_history_default_keep: usize,
pub json_mode: bool,
pub disable_native_tools: bool,
pub context_window: i32,
pub reasoning_effort: Option<String>,
pub tool_format: Option<String>,
pub input_price_per_mtok: Option<f64>,
pub output_price_per_mtok: Option<f64>,
pub chars_per_token: Option<f64>,
pub orchestrators: Vec<OrchestratorEntry>,
pub task_precision: Option<HashMap<String, TaskPrecision>>,
pub failure_dumps: Option<String>,
pub response_sla_secs: u64,
pub propagate_payment_error: bool,
pub capability_tags: Vec<String>,
pub description: Option<String>,
pub signing_schemes: Vec<String>,
pub auto_stop: bool,
pub exec: Option<ExecProviderConfig>,
pub mcp: Option<McpProviderConfig>,
pub claude: Option<ClaudeProviderConfig>,
pub provider_config: HashMap<String, Value>,
pub openrouter: Option<OpenRouterConfig>,
pub builtin_tools: Vec<BuiltinToolGrant>,
pub prompt_exposure_guard: bool,
pub middleware: MiddlewareConfig,
pub read_file_roots: Vec<PathBuf>,
}Expand description
Configuration for a specific agent.
Fields§
§name: String§model: Option<String>Dotpath model reference: "provider_id.model_key".
When set, resolves the provider and merges ModelDef fields into this
agent at config load time (load_agent_from_config). Replaces the
legacy provider_id + model_name + flat LLM field pattern.
provider_id: StringLegacy provider reference. When model is set, this is overwritten
during resolution. Kept for backward compatibility.
model_name: String§temperature: f32§max_tokens: i32§system_prompt_override: Option<String>§persona: Option<String>§max_react_iterations: Option<i32>§max_scratchpad_size: Option<i32>§max_retries: Option<i32>§max_concurrent_jobs: Option<usize>Max jobs this agent runs concurrently. Enforced as the pull consumer’s
max_ack_pending, so the broker withholds the next task until an
in-flight one finishes. Set to 1 for agents whose jobs mutate shared
state (e.g. a git repo a middleware resets per job) to prevent races.
None (default) leaves it unbounded.
supports_native_thinking: bool§frequency_penalty: Option<f32>§presence_penalty: Option<f32>Presence penalty for the model. Defaults to Some(1.5) to encourage
diverse vocabulary in multi-agent deliberation (reduces repetitive
phrasing across rounds). Set to None or 0.0 in config to disable.
textual_feedback: bool§use_streaming: bool§merge_system_prompt: bool§unwrap_hallucinated_tool_calls: bool§repair_invalid_escapes: bool§scratchpad_limit: i32§scratchpad_squeeze_fraction: f64Fraction of max_scratchpad_size at which compact_history
also auto-squeezes the scratchpad. Default 0.95 — leaving 5%
headroom keeps the next tool call from immediately tripping
the persistence cap.
compact_history_default_keep: usizeDefault value of compact_history(keep_last_n_calls) when the
model omits the argument. Two recent tool results give the
model enough context to reason while older results fold into
the scratchpad summary.
json_mode: bool§disable_native_tools: bool§context_window: i32§reasoning_effort: Option<String>§tool_format: Option<String>§input_price_per_mtok: Option<f64>USD per million input tokens. Used for cost estimation in budget reporting.
output_price_per_mtok: Option<f64>USD per million output tokens. Used for cost estimation in budget reporting.
chars_per_token: Option<f64>Characters per token for heuristic estimation when the provider doesn’t return
usage stats. Deserialized as Option<f64> (None when absent in config).
The runtime fallback of 4.0 (English approximation) is applied at the call
site via .unwrap_or(4.0) in nsed_agent.rs; set lower (~1.5) for CJK/code.
orchestrators: Vec<OrchestratorEntry>Per-agent orchestrator extensions (additive to the process-wide list). Only used at agent startup for connection resolution; never serialized over NATS since this is deployment topology, not agent behavior.
task_precision: Option<HashMap<String, TaskPrecision>>Per-task-category precision parameters for the thermodynamic model.
Map from task category (e.g. “supply”, “audit”, “quant”, “legal”) to
{ pg, pv } where pg = zero-shot generation precision, pv = verification precision.
Used by the dashboard to compute the NSED utility function:
U(t) = 1 - (1-pg) * exp(-Lambda*(pv-pg)t) - betat^2
If absent, the dashboard falls back to built-in MODEL_PRECISION defaults.
failure_dumps: Option<String>Controls failure dump output when parse or API errors occur.
Values: "on" (default — dump error + raw response), "full" (include
system prompt, request body, and messages), "off" (disable).
Dumps are written to failures/<session>_<agent>/.
Can also be set globally via the NSED_FAILURE_DUMPS env var (1 = on, full = full).
The config value takes precedence over the env var.
response_sla_secs: u64Maximum seconds this agent needs to complete a single task (propose or evaluate).
When > 0, this is a hard infrastructure constraint — the orchestrator will never
give this agent less time than this value per phase. Set to 0 to opt out of
SLA reporting (the field is omitted from heartbeats). Defaults to 3600s (1 hour).
propagate_payment_error: boolWhether to propagate 402 Payment Required errors to the orchestrator.
When true (default), an agent_error event is published immediately.
When false, the agent silently pauses and lets the orchestrator timeout.
Free-form capability tags (e.g., ["legal", "audit", "quantitative"]).
Used for filtering in agent picker and directory.
description: Option<String>Short description of the agent’s specialization. Shown in the agent directory and picker UI.
signing_schemes: Vec<String>Signing schemes this agent supports (placeholder for #115).
Values will be validated against SigningScheme enum when implemented.
Empty means no signing support (legacy/internal agent).
auto_stop: boolWhen true, buffer entries from this agent are created with stopped = true,
preventing auto-release until an external system edits and explicitly
releases them via POST /buffer/{id}/release. Used with stub providers
for human-operated agents.
exec: Option<ExecProviderConfig>Configuration for exec-based external agent providers.
When provider_type is "exec", the agent spawns a subprocess instead
of calling an LLM. See docs/exec-agent-protocol.md.
mcp: Option<McpProviderConfig>Configuration for MCP-based external agent providers.
When provider_type is "mcp", the agent spawns a subprocess and
communicates via the Model Context Protocol (stdio transport).
See docs/mcp-agent-protocol.md.
claude: Option<ClaudeProviderConfig>Configuration for Claude CLI as an agent provider.
When provider_type is "claude", automatically constructs claude
CLI flags from AgentConfig fields (system prompt, model, session) plus
Claude-specific options (permission mode, budget, MCP tools).
See docs/mcp-agent-protocol.md#claude-provider.
provider_config: HashMap<String, Value>Free-form provider config for third-party ProviderFactory
implementations. Built-in providers (exec / mcp / claude) use
their typed sections above; a custom provider.type reads its knobs
from here, so registering a new provider needs no new field on this
core struct.
Deserialize the whole map into a typed struct with
AgentConfig::provider_config_as, or index the map directly.
openrouter: Option<OpenRouterConfig>OpenRouter-specific request extensions (provider routing + ZDR).
Injected into the request body as "provider": { ... } when the
underlying base URL is OpenRouter. Non-OpenRouter providers will
ignore or reject the block — only set this for OpenRouter agents.
builtin_tools: Vec<BuiltinToolGrant>Per-agent grants for built-in sandboxed tools. Attached to an
agent’s tool list only for the native-LLM provider branch;
provider_type: claude / exec / mcp route their tools through
provider-native channels (claude sub-agents, the exec subprocess’s
own tool surface, MCP server) so grants configured on those agents
are silently ignored at runtime (loaders are expected to warn).
Use this to give native-LLM agents scoped runtime capabilities
(e.g. read files confined to a specific filesystem root) without
going through the user_tools NATS dispatcher pipeline.
Each grant becomes a tool in the agent’s tool list at startup.
See crate::tools::scoped_read for the read_file
implementation and its security model.
prompt_exposure_guard: boolEnable the prompt_exposure safety guardrail on this agent’s LLM
responses. When true, the agent scans every terminal tool-call
content (proposal / batch evaluation) for internal-prompt leakage
(XML scaffolding tags, canonical tool names, meta-protocol phrases)
and forces a retry with a block-reason feedback message when a leak
is detected. Defaults to false so existing deployments do not
change behavior until explicitly opted in. See
docs/middleware.md#prompt_exposure-config
for the detection heuristics.
middleware: MiddlewareConfigAgent middleware pipelines (before_prompt / on_provider_response /
on_completion / before_release). Inert unless configured — the worker
only runs a pipeline when it’s non-empty, so existing agents are
unaffected. Deserialize-only (the config carries a non-serializable
runtime moderation_model).
read_file_roots: Vec<PathBuf>Per-agent filesystem roots for the sandboxed read_file tool.
Each entry grants the agent permission to read any file under
the canonical path of that root. Symlink targets that resolve
outside the root are rejected. Empty (default) means the tool
isn’t activated for this agent.
Skipped on serialization so host filesystem paths never travel over the wire (e.g. orchestrator capability advertisements). Loaded from YAML on the agent host only.
Implementations§
Source§impl AgentConfig
impl AgentConfig
Sourcepub fn provider_config_as<T: DeserializeOwned>(&self) -> Result<T, Error>
pub fn provider_config_as<T: DeserializeOwned>(&self) -> Result<T, Error>
Deserialize the whole provider_config map
into a typed struct T. Third-party ProviderFactory impls use
this to read their bespoke YAML config without adding a typed section
to this core struct:
#[derive(serde::Deserialize)]
struct CodexConfig { permission_mode: String, sandbox: bool }
let cfg: CodexConfig = agent_config.provider_config_as()?;An empty map deserializes to whatever T makes of an empty mapping
(e.g. a struct whose fields all have #[serde(default)]).
Sourcepub fn validate_provider_sections(
&self,
resolved_provider_type: Option<&str>,
) -> Result<(), String>
pub fn validate_provider_sections( &self, resolved_provider_type: Option<&str>, ) -> Result<(), String>
Validate that at most one provider section is populated and, when
resolved_provider_type is known, that it matches the populated section.
Sourcepub fn validate_compaction_knobs(&self) -> Result<(), String>
pub fn validate_compaction_knobs(&self) -> Result<(), String>
Validate compaction knobs land in usable ranges. A
scratchpad_squeeze_fraction outside (0.0, 1.0] and a
compact_history_default_keep of zero would silently produce
degenerate compaction behavior.
Trait Implementations§
Source§impl Clone for AgentConfig
impl Clone for AgentConfig
Source§fn clone(&self) -> AgentConfig
fn clone(&self) -> AgentConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposeSchema for AgentConfig
impl ComposeSchema for AgentConfig
Source§impl Debug for AgentConfig
impl Debug for AgentConfig
Source§impl Default for AgentConfig
Manual Default implementation that matches the serde defaults.
#[derive(Default)] would set response_sla_secs to 0 and
propagate_payment_error to false, which differs from the documented
serde defaults (3600s / 1 hour and true respectively).
impl Default for AgentConfig
Manual Default implementation that matches the serde defaults.
#[derive(Default)] would set response_sla_secs to 0 and
propagate_payment_error to false, which differs from the documented
serde defaults (3600s / 1 hour and true respectively).
Source§impl<'de> Deserialize<'de> for AgentConfig
impl<'de> Deserialize<'de> for AgentConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for AgentConfig
impl Serialize for AgentConfig
Auto Trait Implementations§
impl !RefUnwindSafe for AgentConfig
impl !UnwindSafe for AgentConfig
impl Freeze for AgentConfig
impl Send for AgentConfig
impl Sync for AgentConfig
impl Unpin for AgentConfig
impl UnsafeUnpin for AgentConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more