Conversation
Store completed successful responses by sha256(canonical JSON body) in the private state directory and replay identical un-keyed requests locally until the TTL expires (bounded by maxEntries). Errors, cancellations, and indeterminate dispatches are never stored; explicit Idempotency-Key flows take precedence and skip the cache entirely. Disabled by default: enableResponseCache must be explicitly true. Replay is marked with X-Response-Cache-Replayed and a sanitized gateway log event.
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.
What changed
Codex retries identical requests after local hiccups without an
Idempotency-Key; each retry previously created another Hyperagent thread. Adds an opt-in cache of completed successful responses keyed by the existing canonical-body fingerprint (sha256):lookupResponseCache/storeResponseCachebehind a dedicated file lock; TTL pruning + oldest-first eviction; stored in private state dir (0600).cacheManager; un-keyed requests consult it before dispatch; hits replay locally withX-Response-Cache-Replayed: trueand a sanitizedresponse_cache_replayedgateway event; successful completions are stored only when no explicit key was used.Config (all opt-in):
enableResponseCache(false by default),responseCacheTtlMs(30 min),responseCacheMaxEntries(128).Safety
Idempotency-Keyalways wins; its flows skip the cache entirely.Why it saves credits
Duplicate retries stop creating duplicate Hyperagent threads.
Testing
npm test: 80 pass, 0 fail. New tests: store/replay exactness, TTL expiry + pruning, maxEntries eviction, no caching of failed dispatches, and Idempotency-Key precedence.