Repository navigation
test: pin the order of existing hooks and events (#241 PR 0) - #242
Merged
Merged
Conversation
PR 0) Records each hook with the number of events sent when it fired, so the timeline is exact. Covers a plain answer, a tool call, a refusal, a provider error, a cancel while streaming, a cancel while tools run, a turn limit, and a rejected input. No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
… notes, continue_loop and errors before output Adds the cases the review found missing: the turn hook runs once per provider attempt; filters and middleware run in installation order (a Modify feeds the next, a Deny stops the chain, a Warn passes); a sourced tool goes through middleware; a turn hook's note lands on the latest user message; continue_loop runs no input filters; a provider error or cancel before any output leaves a message with no MessageStart/MessageEnd; a cancel after streaming started ends the message as Aborted. Renames cancelled_while_tools_run to cancelled_before_tools_start and corrects the notes on current behaviour. The original eight timelines are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG
yuanhao
added a commit
that referenced
this pull request
Oct 6, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG # Conflicts: # tests/hook_order_test.rs
This was referenced Oct 6, 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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR 0 of #241. It adds
tests/hook_order_test.rsand changes no behaviour.The
Extensionrefactor (#241 PR 1) re-routes the trait hooks through one dispatch path and leaves the closures where they are. This test must pass unchanged across that refactor: any difference is a behaviour change for existing users, such as yoyo'son_before_turncheckpoint mode.What it records:
Agent: input filters (sync and async),ToolSource,on_before_turn,TurnHook, the provider call,ToolMiddleware, toolexecute,on_error,on_after_turn.AgentEnd's final messages.Paths: a plain answer, a tool call then an answer, a refusal carrying a tool call, a provider error, a cancel while streaming, a cancel while tools run, a turn limit, and a rejected input.
Three things today's behaviour does, pinned as is and marked in the test. They're worth a separate issue rather than a change here:
TurnStart, so thatTurnStartnever gets aTurnEnd.MessageStartorMessageEndis sent for it, so a transcript built from events misses it.Checks:
cargo clippy --all-targetswith--all-featuresand with--no-default-features;cargo fmt --check.🤖 Generated with Claude Code
https://claude.ai/code/session_01T7iq5hpndSiHQcnAsywKuG