The OpenAI-compatible runner
A second agent runner drives any OpenAI-compatible chat endpoint (POST <base>/chat/completions)
in a tool-use loop over the same six tools Claude Code has: Bash, Read, Edit, Write, Glob, Grep.
The default is unchanged: without the switch below every run uses Claude Code.
Switch it on, in the forge's environment (only there: a run's env, where granted secrets land, is never
read for these, and a secret cannot be named OPENAI_*):
FORGE_AGENT_RUNNER=openaichooses the runner (any other value keeps Claude).OPENAI_BASE_URLis the endpoint's base,http://orhttps://, for examplehttps://api.openai.com/v1.OPENAI_MODELnames the model, unless the run names one.OPENAI_API_KEYis sent as a bearer token; leave it unset for an endpoint that needs none.
Without a base URL and a model a run ends as an error saying so. Read it as the run's result.
The endpoint's redirects are refused, so the key goes to the configured host or nowhere.
What it does: the file tools resolve every path inside the run's clone, following symlinks, and refuse
anything outside, or a path through a link to nothing; a write never follows a link at its last name.
Bash runs under bubblewrap held to the run's sandbox policy (src/crew/openai_jail.ts): every denied path
is covered, only the clone, its temp directory and its install cache are writable, and the shell has a
network of its own whose one way out is the forge's egress proxy (HTTPS_PROXY), which passes the policy's
hosts alone; loopback, its own namespace's listeners, goes direct (NO_PROXY), so an app's tests reach the server they start. It needs an enforced sandbox: where the host cannot enforce one, Bash answers with a refusal and the model uses the file
tools. The shell sees only PATH, HOME, TMPDIR and the run's env less anything named like a secret
(OPENAI_*, FORGE_*, KEY, TOKEN, SECRET, PASSWORD). Bounds: an endpoint answer over 4 MB
ends the run, a turn runs at most 16 tool calls, Bash is killed at 120 s and its output cut at 30 000
bytes, Grep skips files over 1 MB, reads 1 000 characters of a line and refuses a pattern with a repeated
group that can backtrack without bound. A run ends at 60 turns.
Not carried over from the Claude runner: resuming a session (each run starts fresh), steering a run while it works, and images.
A picked subscription is what the run spends (#15198). When the forge picks an account for the run,
its token goes to that account's gateway (<gateway>/v1/chat/completions, through the forge's door for
a crew run), never to OPENAI_BASE_URL with the operator's key. An account with no gateway (a bare
Anthropic token) cannot drive this runner, so the run ends as an error saying so rather than spending the
operator's key on it.
Cost and the cap. An endpoint reports tokens, not dollars, so the forge prices them from the table
in src/crew/openai_price.ts: cost = tokens in × in/1e6 + tokens out × out/1e6, at the providers' list
prices in USD per million tokens. It errs high: cached input is charged as fresh, a model pays the
price of the longest name it starts with, and a model the table does not know pays its dearest row,
$15/$75. The running cost reaches the crew through onUsage and the outcome's costUsd, and a turn
that brings it to the run's budget ends the run with max_budget_reached, as a Claude run does; that
turn's tool calls are not run. The run log's first line names the price used.
Pinned by test/openai-runner.test.ts and test/openai-runner-escape.test.ts; the code is src/crew/openai_runner.ts.