From f15b0fbb4f1738055cf6f16f9b349dbca69b879a Mon Sep 17 00:00:00 2001 From: beardthelion Date: Tue, 28 Apr 2026 14:53:56 -0500 Subject: [PATCH] fix: add PLATFORM_HINTS entry for api_server platform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API server is a documented, first-class messaging platform with its own gateway adapter, docs pages, and toolset. But it's the only messaging platform missing from PLATFORM_HINTS in agent/prompt_builder.py. Without a platform hint, the agent has no context about the API server's rendering environment and defaults to markdown-heavy document-style outputs (code fences, bold, bullet points) — which break on the plain-text frontends most API server consumers wrap (Open WebUI, custom agents, third-party bridges). Adds a generic api_server entry that describes the medium (unknown rendering, assume plain text) without encoding any specific use case. Individual consumers can layer additional style guidance via ephemeral system prompts. Before (DeepSeek V4 Pro via API server, no hint): **Sendblue bridge** at /opt/sendblue-bridge - **68MB** on disk After (same prompt, with hint): Sendblue bridge at /opt/sendblue-bridge, 68MB on disk No breaking changes — new dict entry only. Existing API server consumers see no behavioral change except for models that previously defaulted to markdown formatting, which now produce cleaner plain-text output. --- agent/prompt_builder.py | 6 ++++++ tests/agent/test_prompt_builder.py | 1 + 2 files changed, 7 insertions(+) diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py index 8494a70eef..2f00020cc1 100644 --- a/agent/prompt_builder.py +++ b/agent/prompt_builder.py @@ -513,6 +513,12 @@ PLATFORM_HINTS = { "image and is the WRONG path. Bare Unicode emoji in text is also not a substitute " "— when a sticker is the right response, use yb_send_sticker." ), + "api_server": ( + "You're responding through an API server. The rendering layer is unknown — " + "assume plain text. No markdown formatting (no asterisks, bullets, headers, " + "code fences). Treat this like a conversation, not a document. Keep responses " + "brief and natural." + ), } # --------------------------------------------------------------------------- diff --git a/tests/agent/test_prompt_builder.py b/tests/agent/test_prompt_builder.py index 88de5186b8..d99e6944ff 100644 --- a/tests/agent/test_prompt_builder.py +++ b/tests/agent/test_prompt_builder.py @@ -788,6 +788,7 @@ class TestPromptBuilderConstants: assert "discord" in PLATFORM_HINTS assert "cron" in PLATFORM_HINTS assert "cli" in PLATFORM_HINTS + assert "api_server" in PLATFORM_HINTS def test_cli_hint_does_not_suggest_media_tags(self): # Regression: MEDIA:/path tags are intercepted only by messaging