Skip to main content

Module config

Module config 

Source
Expand description

Configuration types for the Agent system

This module defines configuration structures that control agent behavior. All configs have sensible defaults and can be loaded from files or environment.

§Design Principles

  1. Sensible Defaults - Should work out of the box
  2. Optional Fields - Only require what’s essential
  3. Serializable - Can be loaded from TOML/JSON/YAML
  4. Type Safe - Invalid configs won’t compile

§Loading Configuration

Configuration is loaded from multiple sources with the following priority:

  1. Environment variables (highest priority)
  2. Config file (if specified or found)
  3. Default values (lowest priority)

§Config File Discovery

If no config file is specified, the following locations are searched:

  1. ./agent.toml (current directory)
  2. ~/.config/agent/config.toml (user config directory)

§Environment Variables

The following environment variables are supported:

  • ANTHROPIC_API_KEY - API key for Anthropic
  • OPENAI_API_KEY - API key for OpenAI
  • AGENT_MODEL - Override the default model
  • AGENT_PROVIDER - Override the default provider

§Example

ⓘ
use codive_core::config::AppConfig;

// Load from default locations with env var overrides
let config = AppConfig::load(None)?;

// Load from specific file
let config = AppConfig::load(Some("./my-config.toml"))?;

Structs§

AgentConfig
Configuration for an agent instance
AppConfig
Top-level application configuration
McpConfig
Configuration for MCP (Model Context Protocol) servers
McpServerConfig
Configuration for a single MCP server
ModelConfig
Configuration for the LLM model
PromptConfig
Configuration for prompt management
ProviderInfo
Information about a supported LLM provider
ServerConfig
Configuration for the server component
TuiConfig
Configuration for the TUI (Terminal User Interface)
VerificationConfig
Configuration for AI-driven code verification

Enums§

ConfigError
Errors that can occur when loading configuration
McpTransport
Transport type for MCP communication

Constants§

PROVIDERS
Registry of supported providers in priority order. When auto-detecting, the first provider with an available API key is used. Models are selected for best coding performance (as of Jan 2026).

Functions§

detect_provider
Detect the best available provider based on API keys. Returns the first provider that has an API key set in the environment.
get_provider
Get provider info by name