Skip to content

fix: cap prompt_cache_key at 64 chars to avoid OpenAI Codex 400 error (#66045) - #66053

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/66045-codex-prompt-cache-key
Closed

fix: cap prompt_cache_key at 64 chars to avoid OpenAI Codex 400 error (#66045)#66053
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/66045-codex-prompt-cache-key

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Bug: On openai-codex provider, prompt_cache_key can exceed 64 chars. The OpenAI backend rejects >64 chars with HTTP 400, causing every codex request to fail and silently fall back.

Fix: After cache_key is built in build_kwargs(), cap at 64 chars. Both usage paths (line 271 kwargs and line 382 merged_extra_body) are covered.

Closes #66045

OpenAI rejects prompt_cache_key values longer than 64 characters
with HTTP 400. Enforce a 64-char cap on the cache_key at its source
so both the kwargs path (line 271) and extra_body path (line 382)
benefit. Falls back to session_id when there is no static content.

Fixes NousResearch#66045
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/openai OpenAI / Codex Responses API P2 Medium — degraded but workaround exists sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) duplicate This issue or pull request already exists labels Jul 17, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #24273 — both bound the same Codex transport prompt_cache_key at the same build_kwargs() branch to prevent the 64-character backend rejection.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: LGTM / Comment

Three-line fix that directly addresses the root cause: OpenAI rejects prompt_cache_key > 64 chars with HTTP 400. The truncation approach is correct — the cache key is an opaque routing hint, so truncating it is safe. No security or quality concerns.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment (resubmit — prior COMMENT activity noted)

Notes

  • Minor fix/feature.
  • No security concerns, no debug artifacts.
  • LGTM.

Reviewed by Hermes Agent

@webtecnica

Copy link
Copy Markdown
Contributor Author

Fechando como duplicata — o PR #24273 já cobre o mesmo fix para o prompt_cache_key no Codex transport. Obrigado @alt-glitch pelo flag! 🙏

@webtecnica webtecnica closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/openai OpenAI / Codex Responses API sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex transport emits an over-length prompt_cache_key (>64) → every openai-codex request 400s and silently falls back

3 participants