From d9a1cee2451340c175efb117c0e62363438c0f6d Mon Sep 17 00:00:00 2001 From: Tyson Thomas Date: Sun, 9 Nov 2025 10:33:28 -0800 Subject: [PATCH] fix the agent runner bug --- .../ai_chat/agent_framework/AgentRunner.ts | 43 +++++++++++++++---- .../implementation/agents/ActionAgent.ts | 1 + front_end/panels/ai_chat/core/AgentNodes.ts | 3 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/front_end/panels/ai_chat/agent_framework/AgentRunner.ts b/front_end/panels/ai_chat/agent_framework/AgentRunner.ts index a39becdd0b..71a8a541c1 100644 --- a/front_end/panels/ai_chat/agent_framework/AgentRunner.ts +++ b/front_end/panels/ai_chat/agent_framework/AgentRunner.ts @@ -1575,14 +1575,41 @@ Key guidelines: default: summaryPrompt = `The agent "${agentName}" has reached its maximum iteration limit of ${maxIterations}. -Please analyze the entire conversation above and provide a concise summary that includes: - -1. **User Request**: What the user originally asked for -2. **Agent Decisions**: Key decisions and actions the agent took -3. **Final State**: What the agent was doing when it timed out -4. **Progress Assessment**: Whether the agent was making progress or stuck - -Format your response as a clear, informative summary that would help a calling agent understand what happened and decide next steps.`; +Please analyze the entire conversation above and provide a COMPREHENSIVE and DETAILED summary (minimum 400-600 words) that includes: + +1. **User Request** (1-2 paragraphs) + - What the user originally asked for + - Key requirements and scope mentioned + - Expected deliverables or outcomes + +2. **Agent Decisions** (2-3 paragraphs) + - List each tool call made with specific details (tool name, key arguments, purpose) + - Explain the reasoning behind each decision + - Describe the strategy or approach the agent took + - What data or information was extracted at each step + - Any patterns in the agent's behavior (e.g., broad searches, specific targeting) + +3. **Final State** (1-2 paragraphs) + - Exactly what the agent was doing when it timed out + - What task was in progress + - What data had been gathered so far (URLs, content, structured data) + - State of any ongoing operations + +4. **Progress Assessment** (2-3 paragraphs) + - Whether the agent was making meaningful progress toward the goal + - If stuck, identify loops, errors, or blocking issues + - Assess if the iteration limit (${maxIterations}) was appropriate for this task + - What percentage of the goal was accomplished + - Quality of work completed so far + +5. **Recommendations for Next Steps** (2-3 paragraphs with bullet points) + - Specific, actionable steps a calling agent should take to continue this work + - Which tools to use next and with what arguments + - What data to prioritize or process + - Suggested iteration limit if re-running + - Alternative approaches if current path seems blocked + +IMPORTANT: Even if the agent only completed a few iterations, provide DETAILED analysis of what it did accomplish. Describe each action comprehensively, analyze the decision-making, and provide concrete recommendations. Do not give brief answers - expand each section thoroughly with specific examples and data from the conversation.`; break; } diff --git a/front_end/panels/ai_chat/agent_framework/implementation/agents/ActionAgent.ts b/front_end/panels/ai_chat/agent_framework/implementation/agents/ActionAgent.ts index 00208eb82d..0a7f039a6d 100644 --- a/front_end/panels/ai_chat/agent_framework/implementation/agents/ActionAgent.ts +++ b/front_end/panels/ai_chat/agent_framework/implementation/agents/ActionAgent.ts @@ -190,5 +190,6 @@ ${args.input_data ? `Input Data: ${args.input_data}` : ''} } } }, + includeSummaryInAnswer: true, // Enable summary for action execution to provide insights }; } diff --git a/front_end/panels/ai_chat/core/AgentNodes.ts b/front_end/panels/ai_chat/core/AgentNodes.ts index c24f3b607e..aba0b7af4a 100644 --- a/front_end/panels/ai_chat/core/AgentNodes.ts +++ b/front_end/panels/ai_chat/core/AgentNodes.ts @@ -1022,8 +1022,7 @@ export function createToolExecutorNode(state: AgentState, provider: LLMProvider, isError, toolCallId, // Link back to the tool call for OpenAI format ...(isError && { error: resultText }), - // On errors, surface the tool result in the main chat lane so users see it - uiLane: (isAgentTool && !isError) ? 'agent' as const : 'chat', + uiLane: isAgentTool ? 'agent' as const : 'chat', }; logger.debug('ToolExecutorNode: Adding tool result message with toolCallId:', { toolCallId, toolResultMessage });