Fix MCP & title bar (#1348)
<!-- This is an auto-generated description by cubic. --> ## Summary by cubic Fixes MCP handoff by detecting an edit-code tool call and stopping generation. Simplifies the title bar credit tooltip; also blocks dyad-* tags in the system prompt and updates tests. - **Bug Fixes** - Stop generation on edit-code via hasToolCall; add a no-op edit-code tool to signal handoff. - Combine tool-call stop with existing step limit for reliability. - Forbid <dyad-*> tags in the system prompt to prevent misuse. - Remove credit usage/reset details from the title bar tooltip; keep the delay note. - Update e2e snapshot to reflect the new prompt rule. <!-- End of auto-generated description by cubic. -->
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
ToolSet,
|
||||
TextStreamPart,
|
||||
stepCountIs,
|
||||
hasToolCall,
|
||||
} from "ai";
|
||||
|
||||
import { db } from "../../db";
|
||||
@@ -69,6 +70,7 @@ import { prompts as promptsTable } from "../../db/schema";
|
||||
import { inArray } from "drizzle-orm";
|
||||
import { replacePromptReference } from "../utils/replacePromptReference";
|
||||
import { mcpManager } from "../utils/mcp_manager";
|
||||
import z from "zod";
|
||||
|
||||
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
||||
|
||||
@@ -766,7 +768,7 @@ This conversation includes one or more image attachments. When the user uploads
|
||||
temperature: await getTemperature(settings.selectedModel),
|
||||
maxRetries: 2,
|
||||
model: modelClient.model,
|
||||
stopWhen: stepCountIs(3),
|
||||
stopWhen: [stepCountIs(3), hasToolCall("edit-code")],
|
||||
providerOptions,
|
||||
system: systemPromptOverride,
|
||||
tools,
|
||||
@@ -836,7 +838,15 @@ This conversation includes one or more image attachments. When the user uploads
|
||||
const { fullStream } = await simpleStreamText({
|
||||
chatMessages: limitedHistoryChatMessages,
|
||||
modelClient,
|
||||
tools,
|
||||
tools: {
|
||||
...tools,
|
||||
"generate-code": {
|
||||
description:
|
||||
"ALWAYS use this tool whenever generating or editing code for the codebase.",
|
||||
inputSchema: z.object({}),
|
||||
execute: async () => "",
|
||||
},
|
||||
},
|
||||
systemPromptOverride: constructSystemPrompt({
|
||||
aiRules: await readAiRules(getDyadAppPath(updatedChat.app.path)),
|
||||
chatMode: "agent",
|
||||
|
||||
Reference in New Issue
Block a user