Repository navigation
feat!: Recast HITL as before tool hook - #11831
Merged
Merged
Conversation
… injected args were not always correct
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||
sjrl
marked this pull request as ready for review
July 1, 2026 07:45
bogdankostic
reviewed
Jul 1, 2026
bogdankostic
left a comment
Contributor
There was a problem hiding this comment.
Looks already good, just some minor comments regarding validation on whether ConfirmationHook is used with the before_tool hook point and deepcopying hook contexts.
This was referenced Jul 5, 2026
4 tasks done
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.
Related Issues
The goal of this is to reduce the need for dedicated parameters on the Agent's init method by utilizing the new Hooks feature as the preferred method for modifying the behavior of the Agent's loop.
Proposed Changes:
Added
ConfirmationHook, abefore_toolAgent hook that applies Human-in-the-Loop confirmation strategies to pending tool calls. It confirms, modifies, or rejects the tool calls the model requested before they run by rewriting the conversation in the Agent'sState. Itsconfirmation_strategiesmapping accepts a single tool name, a tuple of tool names, or the wildcard"*"that applies to any tool without a more specific entry, so you can set a default strategy for all tools and override individual ones.Breaking Changes:
Human-in-the-Loop tool confirmation on
Agentis now expressed as abefore_toolhook instead of a dedicated concept. Theconfirmation_strategiesandconfirmation_strategy_contextparameters have beenremoved from
Agent.__init__,Agent.run, andAgent.run_async. To migrate, wrap your confirmationstrategies in the new
ConfirmationHook, register it under thebefore_toolhook point, and pass any request-scoped resources through the generichook_contextrun argument instead ofconfirmation_strategy_context:How did you test it?
Added new tests.
Notes for the reviewer
I did think about seeing if there was a way to reduce abstractions and verbosity such as replacing
ConfirmationStrategywith aConfirmationHookprotocol, but I ruled this out since it did come with cons.BlockingConfirmationHookwould only be able to hold one policy+UI so if you wanted to set "always ask" fordelete_fileand "sometimes ask" for the remaining tools then you would need to set multiple hooks which increases verbosity. The current{tool: strategy}map (with tuple keys and"*"wildcard) handles per-tool differentiation, including mixing a blocking strategy for one tool and a custom non-blocking one for another, in a single hook.run(tool_name, description, params, ...) -> ToolExecutionDecision— and Haystack handles the fiddly message surgery (rejection/modify message rewriting + history reconstruction). Making the hook the new protocol would force those authors to implement the fullrun(state) -> Nonemaking them redo that surgery themselves.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.