pub struct AgentConfig {Show 17 fields
pub model: String,
pub api_key: Option<String>,
pub system_instructions: Option<SystemInstructions>,
pub capabilities: Option<CapabilitiesConfig>,
pub workspaces: Vec<PathBuf>,
pub tools: Vec<ToolDefinition>,
pub policies: Vec<PolicyRule>,
pub triggers: Vec<TriggerEntry>,
pub hooks: Vec<HookEntry>,
pub skills: Vec<PathBuf>,
pub mcp_servers: Vec<McpServer>,
pub conversation_id: Option<String>,
pub save_dir: Option<PathBuf>,
pub app_data_dir: Option<PathBuf>,
pub response_schema: Option<JsonSchema>,
pub gemini: Option<GeminiConfig>,
pub max_quota_retries: Option<u32>,
}Expand description
Full configuration for creating an agent.
Covers model selection, system instructions, capabilities, tools, policies, hooks, MCP servers, structured output, and Gemini backend settings. All fields have sensible defaults.
§Construction patterns
AgentConfig deliberately supports two construction paths:
-
TypedBuilder— ergonomic chained construction withimpl IntoIteratorsetters for collection fields. Preferred for programmatic use:let config = AgentConfig::builder() .model("gemini-3.5-flash") .build(); -
Struct literal with
..Default::default()— convenient for deserialization (serde), config files, and framework code that already has fully-formed values:let config = AgentConfig { model: "gemini-3.5-flash".into(), ..AgentConfig::default() };
Both paths are supported intentionally. The builder provides ergonomic
setters (e.g. accepting impl IntoIterator for collection fields),
while struct literals enable direct field access for serialization
roundtrips and downstream framework integration.
Fields§
§model: StringThe model name (e.g. "gemini-3.5-flash").
api_key: Option<String>API key. Falls back to GEMINI_API_KEY env var if None.
system_instructions: Option<SystemInstructions>Optional system instructions (custom text or templated sections).
capabilities: Option<CapabilitiesConfig>Agent capability toggles (tool lists, subagents, compaction).
workspaces: Vec<PathBuf>Workspace directories the agent can access.
When empty (the default), the Python SDK’s own default of
[os.getcwd()] applies. Set explicitly to override.
tools: Vec<ToolDefinition>Custom tool definitions exposed to the agent.
policies: Vec<PolicyRule>Policy rules evaluated before each tool call.
triggers: Vec<TriggerEntry>Event-driven triggers attached to this agent.
hooks: Vec<HookEntry>Lifecycle hooks (pre-turn, post-turn, pre-tool, etc.).
skills: Vec<PathBuf>Paths to skill instruction files loaded into the agent.
Serializes as "skills_paths" to match the Python SDK field name.
mcp_servers: Vec<McpServer>MCP server configurations.
conversation_id: Option<String>Pre-existing conversation ID to resume.
save_dir: Option<PathBuf>Directory where conversation state is saved.
app_data_dir: Option<PathBuf>Application data directory.
response_schema: Option<JsonSchema>Optional JSON schema for structured responses.
gemini: Option<GeminiConfig>Gemini model backend configuration.
Controls per-model API keys, model selection per capability,
and generation parameters such as thinking_level.
Serializes as "gemini_config" to match the Python SDK field name.
max_quota_retries: Option<u32>Maximum number of quota retry attempts before giving up.
If None, defaults to 0 (no retries).
Implementations§
Source§impl AgentConfig
impl AgentConfig
Sourcepub fn builder() -> AgentConfigBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> AgentConfigBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>
Create a builder for building AgentConfig.
On the builder, call .model(...)(optional), .api_key(...)(optional), .system_instructions(...)(optional), .capabilities(...)(optional), .workspaces(...)(optional), .tools(...)(optional), .policies(...)(optional), .triggers(...)(optional), .hooks(...)(optional), .skills(...)(optional), .mcp_servers(...)(optional), .conversation_id(...)(optional), .save_dir(...)(optional), .app_data_dir(...)(optional), .response_schema(...)(optional), .gemini(...)(optional), .max_quota_retries(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of AgentConfig.
Source§impl AgentConfig
impl AgentConfig
Sourcepub fn effective_api_key(&self) -> Option<String>
pub fn effective_api_key(&self) -> Option<String>
Resolve the effective API key using the same priority chain as the
Python SDK’s LocalAgentConfig → _build_harness_config:
- Per-model key (
gemini.models.default.api_key) - Shared
GeminiConfigkey (gemini.api_key) - Top-level shorthand (
api_key) $GEMINI_API_KEYenvironment variable
Sourcepub fn custom_tool_names(&self) -> Vec<String>
pub fn custom_tool_names(&self) -> Vec<String>
Returns the names of all explicitly registered custom tools.
To get the full list of tools including built-ins, combine this
with capabilities.enabled_tools or examine tools + default semantics.
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 more