76e88cae2a
Twenty-three tests imported helpers from sibling test modules by dotted path (tests.run_agent.test_run_agent, tests.cli.test_cli_init, tests.gateway.test_42039_duplicate_user_message); those follow the moves and renames. The run_agent autouse fixture that zeroes jittered_backoff now covers all of tests/agent, where one pre-existing test asserts the real backoff is positive — it opts out via a real_retry_backoff marker, the same pattern real_concurrent_gate and real_agent_prewarm use.
29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
"""A batch of parallel tool calls announces "preparing <tool>…" once per tool, not once per call (#10478)."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
from tests.hermes_cli.test_tool_progress_scrollback import _make_cli
|
|
import tests.hermes_cli.test_tool_progress_scrollback as _scrollback
|
|
|
|
|
|
def _announce(cli, names):
|
|
printed = []
|
|
with patch.object(_scrollback._cli_mod, "_cprint", lambda line: printed.append(line)):
|
|
for n in names:
|
|
cli._on_tool_gen_start(n)
|
|
return printed
|
|
|
|
|
|
def test_repeated_tool_in_one_batch_prints_once():
|
|
cli = _make_cli(tool_progress="off")
|
|
printed = _announce(cli, ["terminal", "terminal", "terminal", "read_file"])
|
|
assert sum("preparing terminal" in p for p in printed) == 1
|
|
assert sum("preparing read_file" in p for p in printed) == 1
|
|
# A tool actually starting closes the batch; the next generation announces again.
|
|
with patch.object(_scrollback._cli_mod, "_cprint", lambda line: None):
|
|
cli._on_tool_progress("tool.started", "terminal", "ls", {"command": "ls"})
|
|
assert sum("preparing terminal" in p for p in _announce(cli, ["terminal"])) == 1
|
|
# A batch that never reached tool.started (cancel/error) must not mute the next invocation.
|
|
cli._reset_stream_state()
|
|
assert sum("preparing terminal" in p for p in _announce(cli, ["terminal"])) == 1
|