fix(cache): align Codex session_id/x-client-request-id headers with body key - #12
Closed
JoaoMarcos44 wants to merge 1 commit into
Closed
JoaoMarcos44 wants to merge 1 commit into
JoaoMarcos44 wants to merge 1 commit into
Conversation
…ody key Fixes NousResearch#79013. session_id header now carries the raw physical session id (NousResearch#57012 contract); x-client-request-id mirrors the body's effective prompt_cache_key instead of both diverging to a bare, un-hashed scope string. Fallback cache_key (when instructions/tools are empty) now falls back to the normalized scope instead of the raw session_id, same class of fix.
5 tasks
Owner
Author
|
Folded back into the upstream PR (NousResearch#78959) so maintainers review everything in one visible upstream PR instead of fork-only ones. Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes NousResearch#79013. Split out of NousResearch#78959's continuation for standalone review.
ResponsesApiTransport.build_kwargs()sent both Codex-backend headers (session_id,x-client-request-id) as the same normalized scope string (e.g.cron_job42), while the body'sprompt_cache_keyis a content hash (pck_<hash>). Two problems:session_idheader lost the raw physical id, contradicting the Align Codex cache affinity header NousResearch/hermes-agent#57012 contract (session_id= transcript identity,x-client-request-id= cache-routing key).x-client-request-idnever actually matched the key the body was cached under.Fix
session_idheader = raw physicalsession_id, untouched.x-client-request-id= the same effective (already-bounded)prompt_cache_keysent in the body. Also fixed the fallbackcache_key(used when instructions/tools are empty) to fall back to the normalized scope instead of the raw session_id -- same class of bug.Test plan
test_codex_cache_scope_boundary— session_id header stays raw; x-client-request-id mirrors body keytest_codex_cache_scope_headers_normalize_cron_session_id— x-client-request-id stable across cron re-fires of the same job; session_id stays per-fire physicaltest_codex_transport.pysuite green (68 tests)%%{init: {'theme': 'dark', 'themeVariables': { 'primaryColor': '#00f0ff', 'mainBkg': '#0a0a16', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#ff007f', 'lineColor': '#00f0ff'}}}%% graph TD A[Codex Request] --> B[body.prompt_cache_key<br/>pck_content_hash] A --> C[header.session_id<br/>Before: normalized scope] A --> D[header.x-client-request-id<br/>Before: normalized scope] C -->|Mismatch| E[Broken #57012 Contract] D -->|Mismatch| F[Diverges From Body Key] A --> G[header.session_id<br/>After: raw physical id] A --> H[header.x-client-request-id<br/>After: mirrors body key] G --> I[Transcript Identity Preserved] H --> J[Header/Body Agreement] style E fill:#3a0030,stroke:#ff007f,color:#fff style F fill:#3a0030,stroke:#ff007f,color:#fff style I fill:#003a3a,stroke:#00f0ff,color:#fff style J fill:#003a3a,stroke:#00f0ff,color:#fff