Add Codex upstream to local proxy broker - #54877
Conversation
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM — clean Codex upstream adapter.
Well-structured implementation with proper base class extension. Good test coverage for the adapter and chat.completions to responses translation.
Reviewed by Hermes Agent
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
Clean, well-scoped change with no concerns.
--- Reviewed by Hermes Agent
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused reuse of the existing Codex credential pool and Cloudflare-header helper.
Problems
hermes_cli/proxy/server.py:110-129translates messages but drops Chat Completionstoolsandtool_choice. Native Codex transport explicitly converts tools inagent/transports/codex.py:91-94; tool-using downstream clients would silently lose their tool contract.hermes_cli/proxy/server.py:133-178consumes Responses SSE into text-only JSON, hard-codesfinish_reason: stop, and cannot surface function calls. It also returns JSON even if the downstream request setsstream: true.- The parser help changes, but
hermes_cli/proxy/cli.py:126andwebsite/docs/user-guide/features/subscription-proxy.md:75still advertise onlynous|xai.
Suggested changes
- Add complete request and response translation coverage for tools and streaming, or narrow the documented compatibility contract.
- Update the proxy CLI help and user/reference docs alongside provider registration.
Automated hermes-sweeper review.
| else: | ||
| replay_messages.append(msg) | ||
|
|
||
| responses_payload = { |
There was a problem hiding this comment.
This payload drops inbound Chat Completions tools and tool_choice. The native Codex transport converts tool schemas through _responses_tools (agent/transports/codex.py:91-94); please either implement the equivalent mapping and test a tool-call turn, or explicitly narrow this compatibility endpoint.
| "choices": [ | ||
| { | ||
| "index": 0, | ||
| "message": {"role": "assistant", "content": "".join(text_parts)}, |
There was a problem hiding this comment.
This always emits a text-only, non-streaming completion with finish_reason: stop. Responses function calls are discarded, and a caller that requested stream: true cannot receive SSE. Preserve the caller's streaming mode and map function-call output before advertising Chat Completions compatibility.
| "--provider", | ||
| default="nous", | ||
| help="Upstream provider: nous or xai (default: nous). See `hermes proxy providers`.", | ||
| help="Upstream provider: nous, openai-codex, or xai (default: nous). See `hermes proxy providers`.", |
There was a problem hiding this comment.
Please update the other user-facing help/docs too: hermes_cli/proxy/cli.py:126 still lists only nous|xai, and website/docs/user-guide/features/subscription-proxy.md:75 says those are the only shipped providers.
Summary
openai-codexas ahermes proxyupstream backed by the shared Hermes Codex credential pool/v1/chat/completionsby translating to Codex/responsesstreaming and returning chat-completion JSONhermes proxy providersand update CLI helpVerify-first notes
hermes_cli/proxy/adapters/base.py,nous_portal.py,xai.py, andserver.pycontract.agent.credential_pool.load_pool("openai-codex"),pool.select(), andpool.try_refresh_current(); no new OAuth implementation.agent.auxiliary_client._codex_cloudflare_headersfororiginator,User-Agent, andChatGPT-Account-ID.openclaw.jsonCodex model references without modifying live config.Tests / proof
python -m pytest tests/hermes_cli/test_proxy.py tests/agent/test_codex_cloudflare_headers.py -q→ 62 passedpython -m py_compile hermes_cli/proxy/adapters/codex.py hermes_cli/proxy/adapters/base.py hermes_cli/proxy/server.py hermes_cli/proxy/adapters/__init__.py hermes_cli/subcommands/gateway.py tests/hermes_cli/test_proxy.pygit diff --check127.0.0.1:8645:/health→{"status":"ok","upstream":"OpenAI Codex","authenticated":true}/v1/chat/completionswith dummy bearer/modelgpt-5.5→ HTTP 200, contentBROKER_OKRollout safety
No live config was changed. Next staged rollout step is to install/run the proxy service persistently, then repoint one low-traffic Hermes profile to
http://127.0.0.1:8645/v1, verify, then continue profile-by-profile before OpenClaw.