refactor(channels): move tool hint rendering out of core (#6498)

* refactor(channels): move tool hint rendering out of core

* test: align progress privacy check with structured tool events
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-29 10:37:29 +08:00
1 parent b1cc89e922
commit acc3750c28
30 files changed
+530 -124

No files matched your search

+27
View File
@@ -1659,6 +1659,33 @@ def test_agent_uses_default_config_when_no_workspace_or_config_flags(mock_agent_
)
@pytest.mark.parametrize("enabled", [True, False])
def test_one_shot_agent_renders_structured_tool_hints(mock_agent_runtime, enabled):
config = mock_agent_runtime["config"]
config.channels.send_tool_hints = enabled
config.channels.send_progress = False
config.agents.defaults.tool_hint_max_length = 20
mock_agent_runtime["agent_loop"].channels_config = config.channels
events = [{
"phase": "start", "call_id": "search-1", "name": "web_search",
"arguments": {"query": "abcdefghijklmnopqrstuvwxyz"},
}]
async def process_direct(*_args, on_progress, **_kwargs):
await on_progress("", tool_hint=True, tool_events=events)
return OutboundMessage(channel="cli", chat_id="direct", content="Done")
mock_agent_runtime["agent_loop"].process_direct.side_effect = process_direct
with patch("nanobot.cli.terminal._print_cli_progress_line") as print_progress:
result = runner.invoke(app, ["agent", "-m", "search"])
assert result.exit_code == 0, result.output
if enabled:
assert print_progress.call_args.args[0] == 'search "abcdefghijklmnopqrs…"'
else:
print_progress.assert_not_called()
def test_agent_uses_explicit_config_path(mock_agent_runtime, tmp_path: Path):
config_path = tmp_path / "agent-config.json"
config_path.write_text("{}")