fix(codex): bound prompt cache key length - #24273
Conversation
|
Confirming this in production — external client path, not just internal session_id Most reports here cover the internal path where Hermes generates the Error: Setup: self-hosted Paperclip → self-hosted Hermes Agent (Docker, The root fix is in Paperclip (paperclipai/paperclip#8714 hashes over-length keys before sending). But this PR would add a meaningful second defensive layer in the Codex transport — clamping any over-length Supporting this PR. |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing the Codex cache-key failure mode. The session-ID path this patch changes has since been replaced on main by content-addressed cache keys: agent/transports/codex.py:16-46 creates a pck_ + 24-character digest, and build_kwargs() uses it at agent/transports/codex.py:252-263 (commit 0a741ed622c65b8c1a304c46fd489e03c171052d).
Problems
- The proposed guard only wraps
session_id. Current main appliesrequest_overridesafter its generated key atagent/transports/codex.py:295-297, so an explicit top-levelprompt_cache_keycan still replace it unbounded. - The xAI body path also preserves a caller-provided cache key via
setdefaultatagent/transports/codex.py:370-375;tests/agent/transports/test_codex_transport.py:150-165explicitly verifies that preservation.
Suggested changes
- Rework the patch around the current content-addressed implementation, then validate the final effective top-level and xAI body override values with focused long-key tests.
Automated hermes-sweeper review.
| @@ -101,7 +120,7 @@ def build_kwargs( | |||
|
|
|||
There was a problem hiding this comment.
This only bounds the session_id-derived value. On current main, request overrides are merged afterward (agent/transports/codex.py:295-297), so an explicit prompt_cache_key can still replace it unbounded; the xAI extra_body override is similarly preserved. Please rework this around the final merged values if the goal includes caller-provided keys.
|
Thanks @Armib20 — you filed the earliest fix for the over-length Codex |
Summary
prompt_cache_keyto the backend's 64-character limit.Why
Hermes session IDs can exceed the Codex backend
prompt_cache_keymaximum, causing non-retryable 400 errors:Test Plan
~/.hermes/hermes-agent/venv/bin/python -m pytest tests/agent/transports/test_codex_transport.py tests/run_agent/test_run_agent_codex_responses.py -q