fix(acp): drop shadowing import json in build_tool_start (#20250)#20356
Closed
Beandon13 wants to merge 1 commit into
Closed
fix(acp): drop shadowing import json in build_tool_start (#20250)#20356Beandon13 wants to merge 1 commit into
Beandon13 wants to merge 1 commit into
Conversation
The generic-fallback branch of ``acp_adapter.tools.build_tool_start`` had a function-scope ``import json`` even though ``json`` is already imported at module scope. Python treats this as a local binding for the entire function body, so the earlier ``json.dumps`` call inside the ``_POLISHED_TOOLS`` branch raised ``UnboundLocalError`` for any polished tool without a dedicated branch (discord, kanban_*, ha_*, browser_*, feishu_*, yb_*, vision_analyze, image_generate, text_to_speech, cronjob, send_message, mixture_of_agents, etc.). Removes the redundant import, leaves a comment explaining why, and adds a parametrized regression test covering 20 polished tools that exercise the generic-fallback path. Refs NousResearch#20250 (secondary error: build_tool_start UnboundLocalError on 'json'). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 15, 2026
Contributor
|
This looks implemented on current Automated hermes-sweeper review evidence:
Thanks for the focused fix and for tying it back to #20250. |
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.
Summary
acp_adapter.tools.build_tool_starthad a function-scopeimport jsoneven thoughjsonis imported at module scope. Python treats it as a local binding for the entire function body, which made the earlierjson.dumpscall in the_POLISHED_TOOLSbranch raiseUnboundLocalErrorfor any polished tool without a dedicated branch.discord,discord_admin,kanban_*,ha_*,browser_*(the ones not given dedicated rendering branches),feishu_*,yb_*,vision_analyze,image_generate,text_to_speech,cronjob,send_message,mixture_of_agents,clarify, etc.Refs #20250 (this is the secondary
build_tool_starterror; the primary lifecycle issue is not addressed here).Testing
scripts/run_tests.sh tests/acp/test_tools.py::TestBuildToolStart -qscripts/run_tests.sh tests/acp/test_tools.py -q(full file)build_tool_start("tc", "discord", {})→UnboundLocalError. After fix: returns aToolCallStart.Test output
Full file: