Move permissions guidance into World State - #31602
Conversation
There was a problem hiding this comment.
💡 Codex Review
codex/codex-rs/core/src/session/turn.rs
Line 356 in 78114be
When DeferredExecutor is off (its feature default is false), this passes the turn-start world_state into mid-turn compaction. Execpolicy approvals mutate services.exec_policy later in the same turn, but the cached world_state is only refreshed under DeferredExecutor before sampling, so a context-limit/new_context compaction after an approval rebuilds replacement history with stale permissions and drops the separate ApprovedCommandPrefixSaved guidance that compaction does not retain. The remainder of that turn can therefore lose the newly approved prefix guidance; rebuild the world state here or keep the approval fragment through compaction.
ℹ️ 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".
| self.instructions | ||
| .clone() | ||
| .map(|instructions| Box::new(instructions) as Box<dyn ContextualUserFragment>) |
There was a problem hiding this comment.
Cap permissions diffs before re-emitting them
For OnRequest/granular sessions, a permissions refresh now emits the entire PermissionsInstructions body from this world-state diff path. That body includes the full approved exec-policy prefix list via approved_command_prefixes_text(exec_policy), and this new update path has no hard cap; after many saved approvals a single developer item can exceed 1k tokens every time permissions refresh. Please cap or summarize the rendered permissions diff before boxing it.
AGENTS.md reference: AGENTS.md:L97-L99
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
the World State RFC says we will render the full block on each change.
rebuilding worldstate before inline compaction would lead to history rewrites (replacement history says env A was always ready if it went from starting -> ready after first request but before mid-turn compaction). but this finding is correct that this is currently a regression as written for flag off behavior; before this change compaction used the live |
|
Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Why
Permissions guidance is model-visible state, but initial context and later turns currently build and compare it through separate paths. That comparison covers only selected
TurnContextfields, missing changes such as refreshed catalog text and requiring reviewer-specific persistence like #31309.What changed
permissionsWorld State section keyed by model and a fingerprint of the rendered guidanceThis supersedes #31309 by persisting what the model was actually shown rather than one input to that rendering.
Known Tradeoffs