feat(agent-cli): add codex, opencode and kilo ori harnesses with in-sandbox generation-id proxy - #73
feat(agent-cli): add codex, opencode and kilo ori harnesses with in-sandbox generation-id proxy#73abhinav-pola wants to merge 2 commits into
Conversation
…-id proxy Co-Authored-By: Abhinav Pola <abhinav.pola@openrouter.ai>
Original prompt from Abhinav
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…rden isolation Co-Authored-By: Abhinav Pola <abhinav.pola@openrouter.ai>
TL;DR
Adds
codex,opencodeandkiloas ori agents. Since none of them emit OpenRouter generation ids in their headless output, each run starts a tiny local HTTP proxy inside the sandbox, points the CLI's OpenRouter base URL at it, and records thegen-*ids from the actual responses the client received. Existing agents (claude, pi, prime-agent, omp) are untouched.What changed?
src/benchmarks/agent-cli/generation-proxy.ts: repo-owned Node proxy script (no deps,http+fetch) written to the sandbox via heredoc. Binds127.0.0.1on an ephemeral port, forwards method/headers/body tohttps://openrouter.ai, streams the response back unchanged, scans non-GET response bytes (JSON and SSE) for"id":"gen-<digits>-<suffix>", and emits each new id once asOR_GENERATION_ID <id>on stdout and to a log file.buildGenerationProxyPreludestarts it, waits for the port file, exportsOR_GENERATION_PROXY_BASE_URL, and kills it on exit.harness.ts:CODEX_HARNESS,OPENCODE_HARNESS,KILO_HARNESSplus JSONL parsers.ori codex -- exec --json ...with the ori provider overrides repeated at exec level sobase_urlcan point at the proxy. Parsesturn.completed.usage,item.completeditems (tool calls, errors, finalagent_message).OPENCODE_CONFIG_CONTENT/KILO_CONFIG_CONTENTbuilt after the prelude soprovider.openrouter.options.baseURLis the proxy. Parsesstep_finishusage/cost,tool_use,text,error.generationIds: parseProxyGenerationIds(stdout)because the proxy shares the client's stdout pipe.schema.ts:ORI_AGENTSgains the three ids.generation-proxy.test.ts(real proxy against a local Bun upstream, no network or key),harness.test.ts(parsers and generated scripts), solver-level test inori-solver.test.tsproving ids reachsample.metadata.generationIdsandrecordGenerationId. Test helper marker list extended.registry.test.tsswapped its "unwired agent" fixture fromcodextogroksince codex is now wired.Why?
Session-id recovery after the fact would also pick up generations from activity retries. Recording ids from the client's own traffic keeps attribution to exactly the trajectory that produced the result.
How to test
Manual: run terminal_bench with
agent: codex(oropencode,kilo) and confirmgenerationIdson the sample metadata are non-empty and resolve at/api/v1/generation?id=.Benchmark impact
None for existing agents. New agents are opt-in via
agent.Reviewer focus
host,connection,content-length,transfer-encoding,content-encodingbefore forwarding. Auth header passes through untouched and is never logged.gen-\d+-...) so model catalog ids likegen-eric/modelare not captured.exec-level-coverrides were verified locally to load (an earlier partial set failed withprovider name must not be empty).Checklist
Link to Devin session: https://openrouter.devinenterprise.com/sessions/d7b9666e78ce40b4b64eded0024b7e11
Open in Devin Desktop: https://openrouter.devinenterprise.com/desktop/session/d7b9666e78ce40b4b64eded0024b7e11?variant=devin
Requested by: @abhinav-pola