[hooks] stop continuation & stop_hook_active mechanics#14532
Merged
eternal-openai merged 1 commit intomainfrom Mar 13, 2026
Merged
[hooks] stop continuation & stop_hook_active mechanics#14532eternal-openai merged 1 commit intomainfrom
eternal-openai merged 1 commit intomainfrom
Conversation
pakrym-oai
reviewed
Mar 13, 2026
| if stop_hook_active { | ||
| if let Some(continuation_prompt) = stop_outcome.continuation_prompt.clone() | ||
| { | ||
| let developer_message: ResponseItem = |
Collaborator
There was a problem hiding this comment.
We might need to start a turn with a user message instead of the developer message.
The user message will have to be wrapped into a tag so we can disambiguate between automatic and real user message.
pakrym-oai
reviewed
Mar 13, 2026
| } | ||
|
|
||
| #[tokio::test(flavor = "multi_thread", worker_threads = 2)] | ||
| async fn stop_hook_can_block_multiple_times_in_same_turn() -> Result<()> { |
Collaborator
There was a problem hiding this comment.
Are there no other hook tests? Suprised we just created this file.
pakrym-oai
reviewed
Mar 13, 2026
| }, | ||
| "reason": { | ||
| "default": null, | ||
| "description": "Claude requires `reason` when `decision` is `block`; we enforce that semantic rule during output parsing rather than in the JSON schema.", |
Collaborator
There was a problem hiding this comment.
Do we like this description?
pakrym-oai
reviewed
Mar 13, 2026
| } else { | ||
| None | ||
| }; | ||
| let aggregate = aggregate_results(results.iter().map(|result| &result.data)); |
Collaborator
There was a problem hiding this comment.
Looks like StopOutcome and StopHandlerData are the same modulo hook_events and we already pass results into aggregate_results. Should we just build the final StopOutcome there?
pakrym-oai
approved these changes
Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stop hooks now receive
stop_hook_activeand enable stop hooks to loop forever if they'd like to. In the initial hooks PR, we implemented a simpler mechanic that the stop-blocking could only happen once in a rowexample run:
.codex/config.toml
.codex/hooks.json
.codex/hooks/session_start_demo.py
.codex/hooks/stop_demo_block.py