Documentation
¶
Overview ¶
Package codex adapts the Codex CLI (`codex exec`) into an inference backend.
The CLI is launched non-interactively with the read-only sandbox, in an empty scratch directory, with no session persisted and a sanitized environment: agent2api uses it as a plain LLM, never as an agent that touches the machine.
None of that takes the tools away. The read-only sandbox still lets a shell command read the whole disk, and an MCP server the user added to config.toml is started outside the sandbox altogether — so a caller could ask for a file and get it back in the answer, or have a server act on their behalf. Two layers keep that from happening:
- argv switches off every tool codex lets a flag or config key remove (see toolFeatures and mcpOverrides), so the model is not offered them;
- the parser refuses any thread item that is not a message, a reasoning summary or a warning, and stops the CLI there.
The second is the guarantee, as `parser.system` is for Qwen Code: what codex offers depends on the release, the model and the user's config, and a list of switches cannot anticipate the next tool. A tool call that slips past the first layer fails the request rather than answering it.
Index ¶
Constants ¶
const DefaultSandbox = config.DefaultSandbox
DefaultSandbox is the sandbox mode used when adapters.codex.sandbox is not set. It mirrors the config default rather than restating it, so the two cannot drift; the adapter keeps its own fallback because Options can be built without going through the config layer at all.
const ID = "codex"
ID is the adapter id used to namespace this backend's models.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is the Codex backend.
func (*Adapter) EffortLevels ¶ added in v0.1.5
EffortLevels implements adapter.EffortSetter.
The knob is a config override rather than a flag, and `-c` is always available, so there is nothing to probe for.
Worth knowing before trusting a level end to end: codex turns it into a `thinking_budget` for the upstream endpoint, and the endpoint decides whether that number is acceptable. Against the third-party provider on the recording machine, `low` worked and `high` came back `400 InternalError.Algo. InvalidParameter: The thinking_budget parameter must be a positive integer and not greater than …`. That surfaces as an honest upstream error rather than a silent downgrade, which is the behaviour to keep — but it means a level this adapter accepts can still be refused further up.