From d8b29fb1d104e51a5fc2cd52d4320314b760117c Mon Sep 17 00:00:00 2001 From: Georg Bauer Date: Tue, 28 Jul 2026 22:36:16 +0200 Subject: [PATCH] fix: hopefully fixed a2ui confusion by the model --- src/a2ui.rs | 2 +- src/app/generation.rs | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/a2ui.rs b/src/a2ui.rs index 1425cd8..3196322 100644 --- a/src/a2ui.rs +++ b/src/a2ui.rs @@ -69,7 +69,7 @@ const FUNCTIONS: &[&str] = &[ "@index", ]; -pub(crate) const SYSTEM_PROMPT: &str = r#"A2UI local-chat rendering is available. Use it only to present substantive data to the user or collect specific structured input from the user. Do not create a surface for progress or status updates, acknowledgements, plans, tool-call narration, or ordinary prose; do not use A2UI merely because it is available. Plain prose is preferred otherwise. When using A2UI, use the newest A2UI v1.0 protocol. Emit A2UI directly in the assistant response, never through `write` or another tool, as newline-delimited messages inside a fenced `a2ui` block. Keep ordinary prose outside the block. Use catalogId `https://ds4server.local/a2ui/v1_0/catalog.json`. +pub(crate) const SYSTEM_PROMPT: &str = r#"A2UI is an escalation beyond Markdown, not the default response format. Use it only when the user explicitly asks for an interactive or graphical UI, or when the task materially requires controls, dynamic state, or a visualization that Markdown cannot carry. Use Markdown for web and file search results, research summaries, prose, lists, and tables, even when they contain substantive data. Do not create a surface for progress or status updates, acknowledgements, plans, tool-call narration, or ordinary prose. If unsure, use Markdown. When using A2UI, use the newest A2UI v1.0 protocol. Emit A2UI directly in the assistant response, never through `write` or another tool, as newline-delimited messages inside a fenced `a2ui` block. Keep ordinary prose outside the block. Use catalogId `https://ds4server.local/a2ui/v1_0/catalog.json`. Every line must be one JSON object with `version":"v1.0"` and exactly one of `createSurface`, `updateComponents`, `updateDataModel`, `deleteSurface`, `callFunction`, or `actionResponse`. Create a surface before updating it. Treat the current client metadata as authoritative: if its surfaces object is empty, prior surfaces in chat history were dismissed and you must create a new surface instead of updating them. Components are a flat adjacency list and the root component has id `root`. Compose complete UIs by combining basic components through container child ids; include every referenced child, tab child, and list template component. Reuse the active surfaceId to update it incrementally; never recreate an existing surface. `createSurface` may include initial `components`, `dataModel`, and `surfaceProperties`. For `actionResponse`, put `actionId` beside `version` and put only `value` or `error` inside `actionResponse`. diff --git a/src/app/generation.rs b/src/app/generation.rs index 82ce90c..d7fc437 100644 --- a/src/app/generation.rs +++ b/src/app/generation.rs @@ -538,16 +538,10 @@ impl App { let assistant_reasoning = effective.turn.reasoning_mode != ReasoningMode::Direct; #[cfg(target_os = "macos")] let model_prompt = if self.config.a2ui_enabled { - let mut prompt = format!( + format!( "{prompt}\n\nA2UI client metadata:\n{}", self.a2ui.client_metadata() - ); - if self.a2ui.active_surface().is_none() { - prompt.push_str( - "\n\nThere is no active A2UI surface. If this response presents UI, its first A2UI message must be createSurface with a new surfaceId and a complete root component tree. Do not update any surfaceId found only in earlier chat history.", - ); - } - prompt + ) } else { prompt.clone() };