Skip to main content

Module config

Module config 

Source
Expand description

Model configuration from the spec and SCX_FORGE_* environment variables, and the backend the agent uses to drive edits.

Each role’s backend is selected by its backend field. [ai].backend (and [ai].coding_backend) accept either an OpenAI-compatible URL or one of the special keywords claude, codex, opencode, cursor-agent, which select that subprocess CLI for the role. The planner and coding roles resolve independently, so they can use different backends (e.g. an openai planner with a claude coder).

For the openai backend the built-in HTTP tool loop talks to an OpenAI-compatible endpoint:

  • planner: [ai].backend (or $SCX_FORGE_BACKEND), $SCX_FORGE_API_KEY (optional, omit for keyless local backends like Ollama), [ai].model.
  • coding: [ai].coding_backend (or $SCX_FORGE_CODING_BACKEND, else the planner backend), $SCX_FORGE_CODING_API_KEY (else $SCX_FORGE_API_KEY), [ai].coding_model (else [ai].model).

Spec values take precedence over the matching env var. The SCX_FORGE_* names are deliberately agent-specific so they do not collide with the OPENAI_* vars that subprocess CLIs (e.g. codex) read for their own auth.

For the subprocess backends (claude, opencode, codex, cursor-agent) the agent shells out to that CLI to make the edits. Those CLIs use their own native auth/config (each reads whatever it documents, e.g. OPENAI_* for codex, ANTHROPIC_* for claude, CURSOR_API_KEY for cursor-agent) from the inherited environment. [ai].model / [ai].coding_model are still honored and passed to the CLI as its model id (e.g. haiku for claude); leave them unset to use the CLI’s own default. When a subprocess planner and the coder are the same backend+model it plans and edits in one shot; when they differ the planner runs read-only in plan mode (see crate::agent_cli::Mode) and hands its plan to the coder.

Structs§

ModelConfig
ModelRoles

Enums§

Backend
Which mechanism the agent uses to produce each round’s edits.

Functions§

env_nonempty 🔒
Read and trim an environment variable, returning None when unset or empty.
normalize_base_url 🔒
Strip trailing slashes and an optional /v1, then append /v1.
normalize_checked 🔒
Normalize a base URL and reject one that is empty after trimming.
resolve_role 🔒
Resolve one role’s ModelConfig from its backend field value.
resolve_roles_from_env
Resolve both model roles. Each role’s backend is selected by its backend value (a URL -> openai; the keywords claude/codex/opencode -> that subprocess CLI), so the planner and coder can run on different backends.
trimmed_nonempty 🔒