Skip to content

Reuse guardian session across approvals#14668

Merged
charley-oai merged 16 commits intomainfrom
ccunningham/reuse-guardian-session
Mar 16, 2026
Merged

Reuse guardian session across approvals#14668
charley-oai merged 16 commits intomainfrom
ccunningham/reuse-guardian-session

Conversation

@charley-oai
Copy link
Copy Markdown
Contributor

@charley-oai charley-oai commented Mar 14, 2026

Summary

  • reuse a guardian subagent session across approvals so reviews keep a stable prompt cache key and avoid one-shot startup overhead
  • clear the guardian child history before each review so prior guardian decisions do not leak into later approvals
  • include the smart_approvals -> guardian_approval feature flag rename in the same PR to minimize release latency on a very tight timeline
  • add regression coverage for prompt-cache-key reuse without prior-review prompt bleed

Request

  • Bug/enhancement request: internal guardian prompt-cache and latency improvement request
Keep a persistent guardian subagent per parent session so approval reviews can reuse the same prompt cache key. Reset the child history before each review so prior guardian decisions do not leak into later reviews, while keeping the existing timeout and cancellation behavior intact.

Co-authored-by: Codex <noreply@openai.com>
@charley-oai charley-oai force-pushed the ccunningham/reuse-guardian-session branch from 6a07464 to 2618df0 Compare March 14, 2026 06:05
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

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: 2618df074e

ℹ️ 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".

charley-oai and others added 2 commits March 14, 2026 13:56
Start the guardian review deadline before the reusable-subagent manager lock and carry it through subagent spawn, history reset, network approval copying, and turn submission. Keep timeout-triggered cleanup non-blocking and heap-box the heavy timeout-wrapped futures so the prompt-cache reuse test does not overflow its stack.

Co-authored-by: Codex <noreply@openai.com>
Add an explicit guardian-subagent manager shutdown hook and call it from the parent session shutdown path, with a fallback on submission-loop exit if the channel closes without an explicit shutdown op. Add a regression test that caches a guardian child and asserts parent shutdown sends the child its own Op::Shutdown.

Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

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: 75d8487381

ℹ️ 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".

Rename the experimental guardian approvals flag back to guardian_approval, migrate the deprecated smart_approvals alias, and update the CLI/TUI copy.

Also propagate guardian review cancellation into reusable subagent spawn and replace cached session-approved hosts when syncing from the parent review session.

Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

let approved_hosts = self.session_approved_hosts.lock().await;
let approved_hosts = self.session_approved_hosts.lock().await.clone();
let mut other_approved_hosts = other.session_approved_hosts.lock().await;
other_approved_hosts.clear();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before:

  • copy_session_approved_hosts_to() only did extend(...)
  • if the cached guardian child had old approved hosts, they stayed there forever

After:

  • it clones the parent’s current approved-host set
  • clears the child’s set
  • repopulates it from the parent snapshot

That matters because the guardian session is now reused. Without this, the child could keep stale network approvals from earlier reviews and end
up with broader access than the parent session.

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: cc72ff4ccf

ℹ️ 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".

Split guardian logic into focused modules, rename the reusable child session plumbing to review-session terminology, and move the guardian snapshot alongside the moved tests.
Also preserve explicit false values when migrating smart_approvals to guardian_approval.

Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

Add snapshot coverage for reused guardian review sessions so follow-up requests show a stable prompt-cache key without retaining prior guardian output.

Co-authored-by: Codex <noreply@openai.com>
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: 9859060066

ℹ️ 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".

Reuse the cached guardian child only when the full effective review-session config matches the next review, so provider and backend changes force a respawn.

Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ 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".

Keep follow-up guardian approvals on the same child conversation instead of clearing history between reviews, and update the snapshot to show the appended prior review context.

Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

Co-authored-by: Codex <noreply@openai.com>
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: 418b3a9cd4

ℹ️ 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".

charley-oai and others added 2 commits March 15, 2026 16:39
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

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: 2b95cea921

ℹ️ 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".

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

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: c0a6417815

ℹ️ 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".

Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

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: 9822da0541

ℹ️ 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".

Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Copy Markdown
Contributor Author

@codex review this

@charley-oai charley-oai merged commit 6fdeb1d into main Mar 16, 2026
32 checks passed
@charley-oai charley-oai deleted the ccunningham/reuse-guardian-session branch March 16, 2026 05:56
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants