fix(plugins): propagate session_id to pre_tool_call hook from all 3 callsites - #34622
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(plugins): propagate session_id to pre_tool_call hook from all 3 callsites#34622liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…allsites All three callsites of get_pre_tool_call_block_message() passed task_id but omitted session_id. Plugin hooks that scope their check on session_id (e.g. per-session rate limiting or security policies) silently received the empty-string default and became no-ops. Now each call forwards agent.session_id so hooks that need session context actually receive it. Regression tests confirm: - session_id kwarg reaches the hook when provided - Empty string default is preserved when omitted Fixes NousResearch#34618
Contributor
|
Verified this fix against current
LGTM. Confirms the issue's root cause: all three callers passed |
13 tasks
Contributor
|
Thanks for the focused regression fix. The reported behavior is already implemented on current
Automated hermes-sweeper review. |
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.
What does this PR do?
Propagates
session_idto thepre_tool_callplugin hook from all three callsites intool_executor.pyandagent_runtime_helpers.py. Previously,session_idwas accepted byget_pre_tool_call_block_message()but never passed by callers, causing plugins that scope by session to silently no-op.Related Issue
Fixes #34618
Type of Change
Changes Made
agent/tool_executor.py: Addedsession_id=agent.session_id or ""to both callsites (concurrent path line ~215, sequential path line ~593) ofget_pre_tool_call_block_message()agent/agent_runtime_helpers.py: Addedsession_id=agent.session_id or ""to theinvoke_tool()callsite (line ~1622)tests/hermes_cli/test_plugins.py: Added 2 regression tests:test_session_id_forwarded_to_hook(verifies kwarg reaches hook) andtest_session_id_defaults_to_empty_string(verifies default behavior preserved)How to Test
pytest tests/hermes_cli/test_plugins.py -k TestPreToolCallBlock -v— all 6 tests should pass (4 existing + 2 new)pre_tool_callhook that checkssession_id, confirm it receives a non-empty value during agent executionsession_idcontinue to work unchangedChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/hermes_cli/test_plugins.py -vand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
get_pre_tool_call_block_message(3 callsites inagent/tool_executor.pyandagent/agent_runtime_helpers.py)task_idis already propagated at all callsites;session_idfollows the same pattern