Skip to content

Use stable Guardian prompt cache keys#24803

Merged
jif-oai merged 5 commits into
mainfrom
jif/guardian-cache-key
May 28, 2026
Merged

Use stable Guardian prompt cache keys#24803
jif-oai merged 5 commits into
mainfrom
jif/guardian-cache-key

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 27, 2026

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.

@jif-oai jif-oai requested a review from a team as a code owner May 27, 2026 18:18
@jif-oai jif-oai changed the title feat: guardian cache key Use stable Guardian prompt cache keys May 27, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 28, 2026

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b05ffb5ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/guardian/review_session.rs Outdated
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 28, 2026

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf06538e4c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/guardian/review_session.rs
@jif-oai jif-oai merged commit 3307240 into main May 28, 2026
30 checks passed
@jif-oai jif-oai deleted the jif/guardian-cache-key branch May 28, 2026 10:55
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant