hackagent.models.completions.codex
Codex backend: drive codex exec through a LiteLLM custom provider.
Codex is OpenAI's agentic coding CLI. It can be driven locally in
non-interactive/headless mode through codex exec. LiteLLM has no built-in
provider for this CLI target, so we register a per-instance
:class:litellm.CustomLLM handler under a unique provider name whose
completion shells out to codex exec instead of making an HTTP call, so
the request still flows through litellm.completion and comes back as a
:class:ModelResponse.
Ollama mode mirrors the Claude Code backend style: set binary to an
ollama executable and the backend will invoke Codex through
ollama launch codex while passing the Codex arguments after --.
CodexModel Objects
class CodexModel(SubprocessCLIModel)
Native backend for a locally-installed Codex CLI.
Drives Codex in non-interactive mode (codex exec) through a per-instance
:class:litellm.CustomLLM handler registered under a unique provider name
(hackagent_codex_<id>), so requests flow through litellm.completion
like every other backend — even though Codex is driven locally through a
CLI.
Required config:
name: the Codex model to drive. Used as both the-mvalue and the LiteLLM model string.
Optional config:
binary(defaultcodex): path to the Codex executable. Set this toollamato drive Codex throughollama launch codex.system_prompt/append_system_prompt: override or extend the instructions by wrapping the prompt sent to Codex stdin.max_turns: cap the agentic loop iterations, if supported by the installed Codex CLI version.cwd: working directory to runcodexin.timeout(seconds, default 300).extra_args: list of additional rawcodex execflags.
Note: endpoint is accepted for interface symmetry but ignored — Codex
is local here and has no endpoint URL in this backend.