hackagent.router.providers.codex
Codex provider built on top of LiteLLM.
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 — exactly like the Claude Code provider — we
register a per-instance :class:litellm.CustomLLM handler under a unique
provider name. Its completion shells out to codex exec instead of making
an HTTP call, so the request still flows through litellm.completion and is
captured by the HackAgent tracking logger like every other provider.
This makes a locally-installed Codex CLI a first-class attack target: no
external bridge, no HTTP server. The only prerequisite is the codex binary
being on PATH (checked at adapter construction).
Ollama mode mirrors the Claude Code provider style: set binary to an
ollama executable and the adapter will invoke Codex through
ollama launch codex while passing the Codex arguments after --.
CodexConfigurationError Objects
class CodexConfigurationError(AdapterConfigurationError)
Codex adapter configuration issues (e.g. binary not found).
CodexInteractionError Objects
class CodexInteractionError(AdapterInteractionError)
Errors invoking the codex CLI.
CodexResponseParsingError Objects
class CodexResponseParsingError(AdapterResponseParsingError)
Errors parsing the codex exec --json output.
CodexAgent Objects
class CodexAgent(Agent)
Adapter 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 provider — 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 adapter.
handle_request
def handle_request(request_data: Dict[str, Any]) -> Dict[str, Any]
Send a single Codex turn via litellm.completion.
Flow mirrors :class:ADKAgent::
request_data → litellm.completion(model="hackagent_codex_<id>/<model>",
messages=…)
→ _CodexCustomLLM.completion → ``codex exec``