Files
cleveragents-core/docs/api/config.md
freemo e9c96c3d0c
CI / build (push) Successful in 17s
CI / lint (push) Failing after 19s
CI / helm (push) Successful in 34s
CI / security (push) Failing after 42s
CI / quality (push) Has been cancelled
CI / unit_tests (push) Has been cancelled
CI / e2e_tests (push) Has been cancelled
CI / integration_tests (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / benchmark-publish (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / benchmark-regression (push) Has been cancelled
CI / docker (push) Has been cancelled
CI / status-check (push) Has been cancelled
docs: add API reference and architecture overview
Add docs/api/ with per-module API documentation for core, a2a, actor,
skills, tool, mcp, resource, and config packages. Add docs/architecture.md
with a developer-oriented system overview including component map, layer
diagram, plan lifecycle, and key design decisions. Update mkdocs.yml nav
to expose both new sections.

ISSUES CLOSED: #N/A
2026-04-02 19:02:53 +00:00

3.0 KiB

cleveragents.config — Configuration System

The config package provides application runtime configuration backed by environment variables, structured logging, metrics processing, and security scanning.

See ADR-024 for design rationale.


Settings

from cleveragents.config.settings import Settings

settings = Settings()
print(settings.provider)   # auto-detected from env
print(settings.model)      # default model for provider

Pydantic BaseSettings model. All fields are configurable via environment variables prefixed with CLEVERAGENTS_ (case-insensitive).

Key Fields

Field Env Var Description
provider CLEVERAGENTS_PROVIDER AI provider (openai, anthropic, …)
model CLEVERAGENTS_MODEL Model name
openai_api_key OPENAI_API_KEY OpenAI API key
anthropic_api_key ANTHROPIC_API_KEY Anthropic API key
google_api_key GOOGLE_API_KEY Google API key
azure_api_key AZURE_OPENAI_API_KEY Azure OpenAI API key
openrouter_api_key OPENROUTER_API_KEY OpenRouter API key
budget_per_plan CLEVERAGENTS_BUDGET_PER_PLAN Per-plan token budget
budget_per_day CLEVERAGENTS_BUDGET_PER_DAY Daily token budget
fallback_providers CLEVERAGENTS_FALLBACK_PROVIDERS Ordered fallback list
actor.default.estimation CLEVERAGENTS_ACTOR__DEFAULT__ESTIMATION Estimation actor name

Provider Auto-Detection

If no provider is explicitly set, Settings inspects the environment for known API keys in the following priority order:

openai → anthropic → google → azure → openrouter →
groq → together → cohere → gemini

Default Models

Provider Default Model
openai gpt-4o
anthropic claude-sonnet-4-20250514
google / gemini gemini-2.0-flash
azure gpt-4o
openrouter anthropic/claude-sonnet-4-20250514
cohere command-r-plus

Logging

Module: cleveragents.config.logging

Configures structured logging (structlog or stdlib) based on the CLEVERAGENTS_LOG_LEVEL and CLEVERAGENTS_LOG_FORMAT environment variables.

from cleveragents.config.logging import configure_logging

configure_logging(level="INFO", format="json")

Metrics Processor

Module: cleveragents.config.metrics_processor

Processes and aggregates token usage and cost metrics from plan execution. Integrates with the cost/budget service.


Security Scanner

Module: cleveragents.config.security_scanner

Scans configuration values for accidentally included secrets (API keys, tokens, passwords) and redacts them before logging or serialization.

from cleveragents.config.security_scanner import scan_for_secrets

issues = scan_for_secrets({"db_url": "postgresql://user:password@host/db"})
# → [SecretIssue(field="db_url", pattern="password_in_url")]