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:
@@ -41,6 +41,7 @@ This applies to simple apps like:
|
|||||||
- **Never write HTML, CSS, JavaScript, TypeScript, or any programming code**
|
- **Never write HTML, CSS, JavaScript, TypeScript, or any programming code**
|
||||||
- **Do not create component examples or code snippets**
|
- **Do not create component examples or code snippets**
|
||||||
- **Do not provide implementation details or syntax**
|
- **Do not provide implementation details or syntax**
|
||||||
|
- **Do not use <dyad-write>, <dyad-edit>, <dyad-add-dependency> OR ANY OTHER <dyad-*> tags**
|
||||||
- Your job ends with information gathering and requirement analysis
|
- Your job ends with information gathering and requirement analysis
|
||||||
- All actual development happens in the next phase
|
- All actual development happens in the next phase
|
||||||
|
|
||||||
|
|||||||
@@ -235,14 +235,6 @@ export function AICreditStatus({ userBudget }: { userBudget: UserBudgetInfo }) {
|
|||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
<div>
|
<div>
|
||||||
<p>
|
|
||||||
You have used {Math.round(userBudget.usedCredits)} credits out of{" "}
|
|
||||||
{userBudget.totalCredits}.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Your budget resets on{" "}
|
|
||||||
{userBudget.budgetResetDate.toLocaleDateString()}
|
|
||||||
</p>
|
|
||||||
<p>Note: there is a slight delay in updating the credit status.</p>
|
<p>Note: there is a slight delay in updating the credit status.</p>
|
||||||
</div>
|
</div>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
ToolSet,
|
ToolSet,
|
||||||
TextStreamPart,
|
TextStreamPart,
|
||||||
stepCountIs,
|
stepCountIs,
|
||||||
|
hasToolCall,
|
||||||
} from "ai";
|
} from "ai";
|
||||||
|
|
||||||
import { db } from "../../db";
|
import { db } from "../../db";
|
||||||
@@ -69,6 +70,7 @@ import { prompts as promptsTable } from "../../db/schema";
|
|||||||
import { inArray } from "drizzle-orm";
|
import { inArray } from "drizzle-orm";
|
||||||
import { replacePromptReference } from "../utils/replacePromptReference";
|
import { replacePromptReference } from "../utils/replacePromptReference";
|
||||||
import { mcpManager } from "../utils/mcp_manager";
|
import { mcpManager } from "../utils/mcp_manager";
|
||||||
|
import z from "zod";
|
||||||
|
|
||||||
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
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),
|
temperature: await getTemperature(settings.selectedModel),
|
||||||
maxRetries: 2,
|
maxRetries: 2,
|
||||||
model: modelClient.model,
|
model: modelClient.model,
|
||||||
stopWhen: stepCountIs(3),
|
stopWhen: [stepCountIs(3), hasToolCall("edit-code")],
|
||||||
providerOptions,
|
providerOptions,
|
||||||
system: systemPromptOverride,
|
system: systemPromptOverride,
|
||||||
tools,
|
tools,
|
||||||
@@ -836,7 +838,15 @@ This conversation includes one or more image attachments. When the user uploads
|
|||||||
const { fullStream } = await simpleStreamText({
|
const { fullStream } = await simpleStreamText({
|
||||||
chatMessages: limitedHistoryChatMessages,
|
chatMessages: limitedHistoryChatMessages,
|
||||||
modelClient,
|
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({
|
systemPromptOverride: constructSystemPrompt({
|
||||||
aiRules: await readAiRules(getDyadAppPath(updatedChat.app.path)),
|
aiRules: await readAiRules(getDyadAppPath(updatedChat.app.path)),
|
||||||
chatMode: "agent",
|
chatMode: "agent",
|
||||||
|
|||||||
@@ -491,6 +491,7 @@ This applies to simple apps like:
|
|||||||
- **Never write HTML, CSS, JavaScript, TypeScript, or any programming code**
|
- **Never write HTML, CSS, JavaScript, TypeScript, or any programming code**
|
||||||
- **Do not create component examples or code snippets**
|
- **Do not create component examples or code snippets**
|
||||||
- **Do not provide implementation details or syntax**
|
- **Do not provide implementation details or syntax**
|
||||||
|
- **Do not use <dyad-write>, <dyad-edit>, <dyad-add-dependency> OR ANY OTHER <dyad-*> tags**
|
||||||
- Your job ends with information gathering and requirement analysis
|
- Your job ends with information gathering and requirement analysis
|
||||||
- All actual development happens in the next phase
|
- All actual development happens in the next phase
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user