Inspect turn hooks before runtime preparation#29945
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e522746dcf
ℹ️ 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".
| .await; | ||
| return Ok(None); | ||
| } | ||
| let (inspected_input, blocked_input) = inspect_inputs(&sess, &turn_context, &input).await; |
There was a problem hiding this comment.
Add integration coverage for hook reordering
This reorders SessionStart/UserPromptSubmit inspection relative to the rest of turn setup and adds blocked/aborted setup paths, but the commit only changes production code. Because this is agent turn logic, please add an integration test under core/tests/suite that exercises the new ordering and persistence behavior so future changes do not regress it.
AGENTS.md reference: AGENTS.md:L112-L118
Useful? React with 👍 / 👎.
| { | ||
| accepted_user_input = true; | ||
| } | ||
| inspected_input.push((input_item, hook_outcome)); |
There was a problem hiding this comment.
Preserve transcript order for queued prompt hooks
When two user prompts are queued while the model is running, this loop now buffers every hook outcome and record_inspected_inputs is called only after inspect_inputs returns. That means the UserPromptSubmit hook for the second queued prompt runs before the first accepted prompt has been written to history/transcript_path; previously each accepted item was recorded before inspecting the next one. Hooks that read the transcript to decide whether to allow/block later queued prompts can now make decisions against stale history.
Useful? React with 👍 / 👎.
Summary
Why
A runtime snapshot must not publish for a turn that hooks stop before sampling. Separating inspection from recording establishes that decision boundary without rewriting history or moving hook context ahead of the normal initial developer context.