Repository navigation
Conversation
…story The history was rebuilt from the last user or tool message, which assumed the pending tool-call message came right after it. Since HITL became a before_tool hook, messages added by other hooks sit in between, and they were dropped from what the Agent sends to the model. Only the last message holds the pending tool calls, so replace just that one.
|
@alanhuangyoo is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @alanhuangyoo, thanks a lot for your contribution! 🙏 We noticed that the Contributor License Agreement (CLA) check ( To get your PR reviewed, please sign the CLA via the link in the |
|
Thanks for signing the CLA, @alanhuangyoo! 🎉 This PR is now ready for review again and the reviewer has been re-assigned. |
|
@davidsbatista I'll review this one |
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
9029fb7 to
6438949
Compare
Related Issues
Proposed Changes:
ConfirmationHookdrops every message that comes after the last user or tool message._update_chat_historyrebuilds the history from that index, which assumed the pending tool-call message came right after it. Since HITL became abefore_toolhook (#11831), other hooks can add messages in between, and those messages vanished from what the Agent sends to the model. This happens even withNeverAskPolicy, where every call is confirmed unchanged.Two cases where this bites, both with a mock chat generator:
before_runhook appends a system message with user memory. The second LLM call gets[user, assistant(tool_calls), tool]; the system message is gone.on_exit+continue_runpattern from the@hookdocstring. After the reminder, the model calls a tool; the next LLM call no longer sees the draft answer or the reminder.The hook only acts when the last message has tool calls, and that is the only message it passes in, so the fix replaces just that message and keeps everything before it.
How did you test it?
test/hooks/human_in_the_loop/test_hooks.py: confirm, modify and reject keep the messages before the tool-call message, plus an async case. All four fail without the fix.test/components/agentsandtest/hooks: 668 passed (theRichConsoleUItests were deselected becauserichisn't installed here).ruff checkandruff format --checkpass. I didn't run mypy locally.Notes for the reviewer
The existing
_update_chat_historytests only use[user, assistant(tool_calls)]histories, so they pass either way.Checklist
This PR was fully generated with an AI assistant, including the fix, the tests and this description. The checks above are the ones that were actually run.