mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Use stable Guardian prompt cache keys (#24803)
## Why Guardian review sessions are reusable across forks when their `GuardianReviewSessionReuseKey` is unchanged, but the underlying Responses request was still using the child thread ID as `prompt_cache_key`. That meant forked Guardian reviews that should share cache context produced different cache keys, reducing prompt cache reuse and weakening the reuse invariant. ## What Changed - Adds a `ModelClient` prompt cache key override and uses it for `ResponsesApiRequest.prompt_cache_key`. - Computes Guardian review cache keys as `guardian:<sha1(parent_thread_id:reuse_key)>`, scoped to the parent thread plus the reuse-sensitive Guardian config. - Wires session construction to apply that override only for Guardian sub-agent sessions. ## Testing - Added coverage that Guardian cache keys are stable for the same parent/reuse key, change when either the parent thread or reuse key changes, fit within the Responses API length limit, and are absent for non-Guardian sessions. - Extended the parallel review test to assert forked Guardian reviews send the same `prompt_cache_key`.
This commit is contained in:
committed by
GitHub
Unverified
parent
4b9eda6ff6
commit
3307240195