The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(gateway): drive both repeat-counter paths through the real progress methods
Teknium8ae56a1da82b
diff --git a/tests/gateway/test_telegram_format.py b/tests/gateway/test_telegram_format.pyindex 51887d910d8..f5f9216dd68 100644--- a/tests/gateway/test_telegram_format.py+++ b/tests/gateway/test_telegram_format.py@@ -23,7 +23,6 @@ from plugins.platforms.telegram.adapter import (_strip_mdv2,_wrap_markdown_tables,)-from gateway.run_turn_progress import _append_progress_repeat_count# ---------------------------------------------------------------------------@@ -77,15 +76,31 @@ class TestFormatMessageBasic:class TestFormatMessageCodeBlocks:- def test_tool_progress_repeat_after_fence_keeps_fence_valid(self, adapter):- """Regression for #138148: repeat counts must not trail a closing fence."""- progress = "💻 terminal\n```\nssh -F /opt/data/home/.ssh/config fed...\n```"+ def test_repeated_fenced_tool_progress_stays_a_code_block(self, adapter):+ """Regression for #138148: the dedup counter must not trail a closing fence, on both the+ queued progress bubble and the native stream-consumer path."""+ import queue- repeated = _append_progress_repeat_count(progress, 4)+ from gateway.run_turn_progress import GatewayTurnProgressMixin as M- assert repeated.endswith("```\n(×4)")- assert "\\`\\`\\`" not in adapter.format_message(repeated)- assert "```\nssh -F /opt/data/home/.ssh/config fed...\n```" in adapter.format_message(repeated)+ progress = "💻 terminal\n```\nssh -F /opt/data/home/.ssh/config fed...\n```"+ native_lines = []+ sc = SimpleNamespace(accepts_tool_progress=True, on_tool_progress=native_lines.append)+ for consumer in (None, sc):+ ctx = SimpleNamespace(last_progress_msg=[None], repeat_count=[0], progress_queue=queue.Queue())+ runner = SimpleNamespace(_ctx=ctx, _stream_consumer=lambda c=consumer: c)+ for _ in range(4):+ M._progress_emit(runner, progress)+ if consumer is None:+ st = SimpleNamespace(progress_lines=[])+ while not ctx.progress_queue.empty():+ rendered = M._progress_absorb(runner, st, ctx.progress_queue.get())+ else:+ rendered = native_lines[-1]+ assert rendered.endswith("```\n(×4)"), rendered+ formatted = adapter.format_message(rendered)+ assert "\\`\\`\\`" not in formatted+ assert "```\nssh -F /opt/data/home/.ssh/config fed...\n```" in formatteddef test_code_block_special_chars_not_escaped(self, adapter):text = "```\nif (x > 0) { return !x; }\n```"