From 8735408c87366c02281c6e15399fef37781dd93d Mon Sep 17 00:00:00 2001 From: ciregenz Date: Tue, 21 Jul 2026 14:09:17 -0700 Subject: [PATCH] [eric] agents: make tool-ui fire more (direct-call hint + exact component names in the nudge, slim ShowUI tool def ~2.1K tokens) --- .../manager/prompt/compose_turn_system_prompt.py | 14 ++++++++++---- backend/apps/agents/show_ui_mcp_server.py | 9 +++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/backend/apps/agents/manager/prompt/compose_turn_system_prompt.py b/backend/apps/agents/manager/prompt/compose_turn_system_prompt.py index 5fe0d19e..f05f9ba0 100644 --- a/backend/apps/agents/manager/prompt/compose_turn_system_prompt.py +++ b/backend/apps/agents/manager/prompt/compose_turn_system_prompt.py @@ -98,13 +98,19 @@ def compose_turn_system_prompt( if load_builtin_permissions().get("ShowUI", "always_allow") != "deny": rich_ui_note = ( "\n" - "Strongly prefer rendering rich UI over prose, every time the content fits:\n" - "- ShowUI for any structured result: tables, stats, links, plans, progress, code, diffs, " - "charts, maps, media, posts, receipts. Render the component, then add one line of text.\n" + "Strongly prefer rendering rich UI over prose, every time the content fits. The tools " + "are mcp__openswarm-ui__ShowUI and mcp__openswarm-ui__AskUI; they are always available " + "this session, so call them DIRECTLY by that name, no ToolSearch step needed.\n" + "- ShowUI for any structured result. Use the EXACT component name: a table = data-table, " + "stats = stats-display, links = link-preview, a plan = plan, steps = progress-tracker, " + "code = code-block, a diff = code-diff, a chart = chart, a map = geo-map, media = " + "image/image-gallery/video/audio, a social post = x-post/linkedin-post/instagram-post, " + "a receipt = order-summary. Render the component, then add one line of text.\n" "- For multi-step work, render a progress-tracker FIRST and re-call ShowUI with the SAME " "props.id after each step so the card advances live; same-id re-calls update in place.\n" "- AskUI for ANY question with enumerable choices, an approval, or tunable values: render " - "it and wait for the answer instead of asking in prose. Flat choices = option-list; a " + "it (option-list, question-flow, parameter-slider, preferences-panel, approval-card) and " + "wait for the answer instead of asking in prose. Flat choices = option-list; a " "multi-question form = one AskUI call per question in sequence. The user can always " "answer off-list in free text (result action 'free_text').\n" "Describing structured data in plain text when a component fits is the worse answer.\n" diff --git a/backend/apps/agents/show_ui_mcp_server.py b/backend/apps/agents/show_ui_mcp_server.py index fa487274..ceb97259 100644 --- a/backend/apps/agents/show_ui_mcp_server.py +++ b/backend/apps/agents/show_ui_mcp_server.py @@ -79,10 +79,11 @@ TOOLS = [ "name": "ShowUI", "description": ( "Render a rich inline UI component in the chat instead of describing data as text. " - "Use it whenever a result fits one of the shapes. Supported components:\n" - + "\n".join(f"- '{name}': {spec}" for name, spec in COMPONENT_SPECS.items()) - + "\nCall it with the component name and a props object matching that shape. " - "The component renders in place of raw text; still give a one-line text summary after. " + "Use it whenever a result fits a component. Components: " + + ", ".join(COMPONENT_SPECS.keys()) + + ". Call it with the component name and a props object; if your props are off, the tool " + "returns that component's exact required shape so you can fix and re-call. The component " + "renders in place of raw text; still give a one-line text summary after. " "LIVE UPDATES: calling ShowUI again with the SAME component and props.id updates that " "card in place. Use this to advance progress-tracker/plan step statuses AS you complete " "each step of real work, or to refresh data; never mint a new id for an update. Before "