From 96d7d27bea8be0112f9d0a2aec73f3fc980becb6 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Wed, 3 Jun 2026 20:52:10 +0800 Subject: [PATCH] Hide private connector tool messages --- src/telegram_codex_bot/transcript_parser.py | 6 ++- .../test_transcript_parser.py | 43 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/telegram_codex_bot/transcript_parser.py b/src/telegram_codex_bot/transcript_parser.py index aef3a2e..4d0e1aa 100644 --- a/src/telegram_codex_bot/transcript_parser.py +++ b/src/telegram_codex_bot/transcript_parser.py @@ -193,7 +193,11 @@ def _display_tool_name(name: str) -> str: def _is_internal_tool_name(cls, name: str | None) -> bool: if not isinstance(name, str): return False - return name.lower() in cls._INTERNAL_TOOL_NAMES + # Codex connector/app tools are exposed in transcripts with private + # underscore-prefixed names (for example _list_repositories). These are + # implementation details and should stay behind the Thinking status + # instead of becoming persistent Telegram bubbles. + return name.startswith("_") or name.lower() in cls._INTERNAL_TOOL_NAMES @staticmethod def _clean_runtime_tool_output(output: str) -> str: diff --git a/tests/telegram_codex_bot/test_transcript_parser.py b/tests/telegram_codex_bot/test_transcript_parser.py index a4309d5..833a2ec 100644 --- a/tests/telegram_codex_bot/test_transcript_parser.py +++ b/tests/telegram_codex_bot/test_transcript_parser.py @@ -164,6 +164,49 @@ def test_update_plan_function_call_is_hidden_from_messages(self): assert result == [] assert pending == {} + def test_private_connector_tool_calls_are_hidden_but_thinking_stays( + self, monkeypatch + ): + monkeypatch.setattr(config, "show_commentary_messages", True) + thinking_item = { + "type": "response_item", + "timestamp": "2026-05-26T00:00:00Z", + "payload": { + "type": "reasoning", + "summary": [{"type": "summary_text", "text": "checking repos"}], + }, + } + use_item = { + "type": "response_item", + "timestamp": "2026-05-26T00:00:01Z", + "payload": { + "type": "function_call", + "call_id": "call_repos", + "name": "_list_repositories", + "arguments": json.dumps({"owner": "QuantStrategyLab"}), + }, + } + result_item = { + "type": "response_item", + "timestamp": "2026-05-26T00:00:02Z", + "payload": { + "type": "function_call_output", + "call_id": "call_repos", + "output": '{"repositories": []}', + }, + } + + entries = [ + TranscriptParser.parse_line(json.dumps(thinking_item)), + TranscriptParser.parse_line(json.dumps(use_item)), + TranscriptParser.parse_line(json.dumps(result_item)), + ] + result, pending = TranscriptParser.parse_entries([e for e in entries if e]) + + assert [entry.content_type for entry in result] == ["thinking"] + assert "checking repos" in result[0].text + assert pending == {} + def test_response_item_function_call_output_is_normalized_as_tool_result(self): item = { "type": "response_item",