Unverified 提交 e655e5e4 authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

Stop agent loop on add_integration tool call (#2242)

Use the AI SDK's hasToolCall() function to stop the agent loop when the add_integration tool is invoked, allowing the user to set up the integration before the agent continues. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Stop the local agent loop when the add_integration tool is called, pausing the run so the user can finish setup. Adds hasToolCall('add_integration') to stopWhen and keeps the 25-step cap. <sup>Written for commit b5826e0563b4b0925715733a86e02707f9387e45. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds an early stop condition to pause the local agent when integration setup is triggered. > > - Imports `hasToolCall` and `addIntegrationTool` > - Updates `stopWhen` to `[stepCountIs(25), hasToolCall(addIntegrationTool.name)]` to halt on `add_integration` tool invocation > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b5826e0563b4b0925715733a86e02707f9387e45. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: 's avatarClaude <noreply@anthropic.com> Co-authored-by: 's avatargemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
上级 609b5848
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
streamText, streamText,
ToolSet, ToolSet,
stepCountIs, stepCountIs,
hasToolCall,
ModelMessage, ModelMessage,
type ToolExecutionOptions, type ToolExecutionOptions,
} from "ai"; } from "ai";
...@@ -55,6 +56,7 @@ import { ...@@ -55,6 +56,7 @@ import {
import { TOOL_DEFINITIONS } from "./tool_definitions"; import { TOOL_DEFINITIONS } from "./tool_definitions";
import { parseAiMessagesJson } from "@/ipc/utils/ai_messages_utils"; import { parseAiMessagesJson } from "@/ipc/utils/ai_messages_utils";
import { parseMcpToolKey, sanitizeMcpName } from "@/ipc/utils/mcp_tool_utils"; import { parseMcpToolKey, sanitizeMcpName } from "@/ipc/utils/mcp_tool_utils";
import { addIntegrationTool } from "./tools/add_integration";
const logger = log.scope("local_agent_handler"); const logger = log.scope("local_agent_handler");
...@@ -244,7 +246,7 @@ export async function handleLocalAgentStream( ...@@ -244,7 +246,7 @@ export async function handleLocalAgentStream(
system: systemPrompt, system: systemPrompt,
messages: messageHistory, messages: messageHistory,
tools: allTools, tools: allTools,
stopWhen: stepCountIs(25), // Allow multiple tool call rounds stopWhen: [stepCountIs(25), hasToolCall(addIntegrationTool.name)], // Allow multiple tool call rounds, stop on add_integration
abortSignal: abortController.signal, abortSignal: abortController.signal,
// Inject pending user messages (e.g., images from web_crawl) between steps // Inject pending user messages (e.g., images from web_crawl) between steps
// We must re-inject all accumulated messages each step because the AI SDK // We must re-inject all accumulated messages each step because the AI SDK
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论