From 84449d9afee5bede1058a49a28fb0d4b80fbbc5f Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Tue, 21 Apr 2026 19:36:05 -0700 Subject: [PATCH] fix(prompt): tell CLI agents not to emit MEDIA:/path tags (#13766) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CLI has no attachment channel — MEDIA: tags are only intercepted on messaging gateway platforms (Telegram, Discord, Slack, WhatsApp, Signal, BlueBubbles, email, etc.). On the CLI they render as literal text, which is confusing for users. The CLI platform hint was the one PLATFORM_HINTS entry that said nothing about file delivery, so models trained on the messaging hints would default to MEDIA: tags on the CLI too. Tool schemas (browser_tool, tts_tool, etc.) also recommend MEDIA: generically. Extend the CLI hint to explicitly discourage MEDIA: tags and tell the agent to reference files by plain absolute path instead. Add a regression test asserting the CLI hint carries negative guidance about MEDIA: while messaging hints keep positive guidance. --- agent/prompt_builder.py | 8 +++++++- tests/agent/test_prompt_builder.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py index 2a2104349..8e061f831 100644 --- a/agent/prompt_builder.py +++ b/agent/prompt_builder.py @@ -350,7 +350,13 @@ PLATFORM_HINTS = { ), "cli": ( "You are a CLI AI Agent. Try not to use markdown but simple text " - "renderable inside a terminal." + "renderable inside a terminal. " + "File delivery: there is no attachment channel — the user reads your " + "response directly in their terminal. Do NOT emit MEDIA:/path tags " + "(those are only intercepted on messaging platforms like Telegram, " + "Discord, Slack, etc.; on the CLI they render as literal text). " + "When referring to a file you created or changed, just state its " + "absolute path in plain text; the user can open it from there." ), "sms": ( "You are communicating via SMS. Keep responses concise and use plain text " diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.py index 096206031..11712b951 100644 --- a/tests/agent/test_prompt_builder.py +++ b/tests/agent/test_prompt_builder.py @@ -789,6 +789,24 @@ class TestPromptBuilderConstants: assert "cron" in PLATFORM_HINTS assert "cli" in PLATFORM_HINTS + def test_cli_hint_does_not_suggest_media_tags(self): + # Regression: MEDIA:/path tags are intercepted only by messaging + # gateway platforms. On the CLI they render as literal text and + # confuse users. The CLI hint must steer the agent away from them. + cli_hint = PLATFORM_HINTS["cli"] + assert "MEDIA:" in cli_hint, ( + "CLI hint should mention MEDIA: in order to tell the agent " + "NOT to use it (negative guidance)." + ) + # Must contain explicit "don't" language near the MEDIA reference. + assert any( + marker in cli_hint.lower() + for marker in ("do not emit media", "not intercepted", "do not", "don't") + ), "CLI hint should explicitly discourage MEDIA: tags." + # Messaging hints should still advertise MEDIA: positively (sanity + # check that this test is calibrated correctly). + assert "include MEDIA:" in PLATFORM_HINTS["telegram"] + # ========================================================================= # Environment hints