You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib/agent.ts
+17-9Lines changed: 17 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1158,6 +1158,14 @@ export async function runAgentLoop(
1158
1158
userPrompt+=`\n\nError executing tool ${toolCall.tool}: ${_err.message}\n\nPlease try a different approach or provide a response with the information you have.`;
1159
1159
}
1160
1160
}
1161
+
// If this iteration was primarily for extension and it was the only tool call,
1162
+
// don't immediately consider it a full step towards the final response generation logic below.
1163
+
// The loop condition `step < currentMaxSteps` will handle continuation.
1164
+
if(extendedIteration&&toolCalls.length===1){
1165
+
// Continue to the next iteration if steps were just extended
1166
+
// and no other substantive tool was called.
1167
+
continue;
1168
+
}
1161
1169
1162
1170
// Check if we've reached the maximum number of steps
1163
1171
if(step===currentMaxSteps-1&&!agentState.isComplete){// Check against currentMaxSteps
@@ -1188,16 +1196,16 @@ export async function runAgentLoop(
1188
1196
agentState.finalResponse="I apologize, but I couldn't complete the full analysis due to a timeout. "+
1189
1197
"Here's what I found so far: "+
1190
1198
agentState.steps.map((s: AgentStep)=>{
1191
-
consttoolName=s.tool;// s.tool is already a string
1199
+
consttoolName=s.tool;
1192
1200
letoutputString: string;
1193
-
if(typeofs.output==='object'&&s.output!==null){
1194
-
try{
1195
-
outputString=JSON.stringify(s.output);
1196
-
}catch{
1197
-
outputString=String(s.output);// Fallback for non-serializable objects
0 commit comments