diff --git a/src/telegram_codex_bot/transcript_parser.py b/src/telegram_codex_bot/transcript_parser.py index 5fd4779..b7a1bae 100644 --- a/src/telegram_codex_bot/transcript_parser.py +++ b/src/telegram_codex_bot/transcript_parser.py @@ -1048,21 +1048,11 @@ def append_result(entry: ParsedEntry) -> None: ) ) elif result_text or result_images: - append_result( - ParsedEntry( - role="assistant", - text=cls._format_tool_result_text( - result_text, tool_name - ) - if result_text - else (tool_summary or ""), - content_type="tool_result", - tool_use_id=_tuid, - timestamp=entry_timestamp, - tool_name=tool_name, - image_data=result_images, - ) - ) + # If the matching tool_use was already skipped or the + # monitor resumed after it, the output has no context. + # Do not send anonymous raw output as a persistent + # expandable quote in Telegram. + continue elif btype == "text": t = block.get("text", "").strip() diff --git a/tests/telegram_codex_bot/test_transcript_parser.py b/tests/telegram_codex_bot/test_transcript_parser.py index d608bf5..03af9e3 100644 --- a/tests/telegram_codex_bot/test_transcript_parser.py +++ b/tests/telegram_codex_bot/test_transcript_parser.py @@ -852,6 +852,25 @@ def test_wait_function_call_output_keeps_tool_name_for_auto_cleanup(self): assert [entry.content_type for entry in result] == ["tool_use", "tool_result"] assert result[1].tool_name == "Wait" + def test_unpaired_function_call_output_is_hidden_in_monitor_mode(self): + parsed = TranscriptParser.parse_line( + json.dumps( + { + "type": "response_item", + "payload": { + "type": "function_call_output", + "call_id": "call_missing_tool_use", + "output": 'Chunk ID: abc\nWall time: 0.0\nOutput:\n{"conclusion":"failure"}', + }, + } + ) + ) + + result, pending = TranscriptParser.parse_entries([parsed], pending_tools={}) + + assert result == [] + assert pending == {} + def test_local_command_with_stdout(self, make_jsonl_entry, make_text_block): xml = ( "/status"