Skip to content

Commit f4cf237

Browse files
tlgimenesclaude
andauthored
fix(decopilot): include prompt arguments in catalog and skip re-reading applied prompts (#2771)
* fix(decopilot): include prompt arguments in catalog and skip re-reading applied prompts The prompt catalog now surfaces argument metadata (name, required) so the LLM knows which arguments to pass when calling read_prompt. The workflow prompt also instructs the LLM to skip read_prompt when a prompt was already expanded inline via the mention UI, preventing the MCP -32602 error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(decopilot): strengthen warning to not re-read already-loaded prompts The previous instruction was too subtle — the LLM still called read_prompt for prompts already in context. Made the warning more prominent with MUST NOT and WARNING formatting to ensure the LLM skips the redundant call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 90af76f commit f4cf237

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

apps/mesh/src/api/routes/decopilot/constants.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ Follow this workflow for every request:
4343
3. **Plan** — for multi-step tasks (3+ tool calls), outline the steps
4444
and wait for user confirmation. For simple tasks, act immediately.
4545
4. **Learn skills** — check <available-prompts> for a matching prompt.
46-
If one exists, load it with read_prompt and follow its steps.
46+
**WARNING: If a prompt's content already appears anywhere in the
47+
conversation history (e.g. applied via /promptName in the UI), you
48+
MUST NOT call read_prompt for it — the content is already loaded.
49+
Follow its instructions directly.** Only call read_prompt for prompts
50+
whose content is NOT yet in the conversation, passing any required
51+
arguments listed in <available-prompts>.
4752
5. **Execute** — enable the tools you need, then carry out the plan.
4853
6. **If not possible** — explain why, suggest what connection the user
4954
could add, and offer a partial workaround if one exists.

apps/mesh/src/api/routes/decopilot/stream-core.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,13 +844,26 @@ function escapeXmlAttr(s: string): string {
844844
*/
845845
async function buildPromptCatalog(client: {
846846
listPrompts(): Promise<{
847-
prompts: Array<{ name: string; description?: string }>;
847+
prompts: Array<{
848+
name: string;
849+
description?: string;
850+
arguments?: Array<{ name: string; required?: boolean }>;
851+
}>;
848852
}>;
849853
}): Promise<string | null> {
850854
const { prompts } = await client.listPrompts();
851855
if (prompts.length === 0) return null;
852856

853-
const lines = prompts.map((p) => `${p.name}|${p.description ?? ""}`);
857+
const lines = prompts.map((p) => {
858+
let line = `${p.name}|${p.description ?? ""}`;
859+
if (p.arguments && p.arguments.length > 0) {
860+
const args = p.arguments
861+
.map((a) => (a.required ? `${a.name} (required)` : a.name))
862+
.join(", ");
863+
line += `|args: ${args}`;
864+
}
865+
return line;
866+
});
854867

855868
return `\n\n<available-prompts>\n${lines.join("\n")}\n</available-prompts>`;
856869
}

0 commit comments

Comments
 (0)