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
fix: handle local LLM crashes in Orchestrator mode
- Add retry mechanism for empty model responses (max 3 retries)
- Detect and handle connection errors common with local LLMs (Jan.ai, LM Studio)
- Provide orchestrator-specific guidance for complex prompts
- Add simplification hints after first retry in orchestrator mode
- Improve error messages with actionable troubleshooting steps
- Add comprehensive test coverage for error scenarios
Fixes#8948
`[Task#${this.taskId}] Empty response from model (attempt ${currentRetries+1}/${maxEmptyResponseRetries})`+
2444
+
(isOrchestratorMode
2445
+
? " in Orchestrator mode - may be due to model limitations with complex prompts"
2446
+
: ""),
2447
+
)
2448
+
2449
+
// Provide user feedback about the retry
2450
+
constretryMessage=isOrchestratorMode
2451
+
? `The model returned an empty response. This can happen with local models in Orchestrator mode due to complex prompts. Retrying with simplified approach (attempt ${currentRetries+1}/${maxEmptyResponseRetries})...`
2452
+
: `The model returned an empty response. Retrying (attempt ${currentRetries+1}/${maxEmptyResponseRetries})...`
// For Orchestrator mode on retry, suggest switching to a simpler mode
2457
+
letmodifiedUserContent=[...currentUserContent]
2458
+
if(isOrchestratorMode&¤tRetries>=1){
2459
+
// Add a hint to simplify the response
2460
+
modifiedUserContent.push({
2461
+
type: "text",
2462
+
text: "\n\n[System: The model is having difficulty with complex orchestration. Please provide a simpler, more direct response focusing on the immediate task.]",
2463
+
})
2464
+
}
2465
+
2466
+
// Add a small delay before retry to avoid rapid-fire requests
2467
+
awaitdelay(2000)
2468
+
2469
+
// Push retry onto stack with incremented counter
2470
+
stack.push({
2471
+
userContent: modifiedUserContent,
2472
+
includeFileDetails: false,
2473
+
retryAttempt: currentItem.retryAttempt,
2474
+
[emptyResponseRetryKey]: currentRetries+1,
2475
+
}asany)
2476
+
2477
+
continue
2478
+
}else{
2479
+
// After max retries, provide helpful error message
2480
+
consterrorMessage=isOrchestratorMode
2481
+
? "The model repeatedly failed to provide a response. This often happens with local LLM models in Orchestrator mode due to the complexity of multi-step planning. Consider:\n"+
2482
+
"1. Switching to a simpler mode like 'code' or 'architect'\n"+
2483
+
"2. Using a more capable model (GPT-4, Claude, etc.)\n"+
2484
+
"3. Ensuring your local model has sufficient context window (40k+ tokens recommended for Orchestrator mode)"
2485
+
: "The model repeatedly failed to provide a response. This may indicate:\n"+
2486
+
"1. Model compatibility issues with the current prompt format\n"+
2487
+
"2. Insufficient model context window for the conversation\n"+
2488
+
"3. Network or API connectivity problems\n"+
2489
+
"Please try a different model or simplify your request."
2490
+
2491
+
awaitthis.say("error",errorMessage)
2492
+
2493
+
// Add to conversation history to maintain state
2494
+
awaitthis.addToApiConversationHistory({
2495
+
role: "assistant",
2496
+
content: [
2497
+
{
2498
+
type: "text",
2499
+
text: "I was unable to generate a response after multiple attempts. Please try a different approach or model.",
2500
+
},
2501
+
],
2502
+
})
2503
+
2504
+
// For Orchestrator mode, suggest mode switch
2505
+
if(isOrchestratorMode){
2506
+
const{ response }=awaitthis.ask(
2507
+
"mistake_limit_reached",
2508
+
"The Orchestrator mode is having difficulty with this model. Would you like to switch to a simpler mode like 'code' or continue with a different approach?",
2509
+
)
2510
+
2511
+
if(response==="messageResponse"){
2512
+
// User provided guidance, continue
2513
+
continue
2514
+
}
2515
+
}
2516
+
}
2407
2517
}
2408
2518
2409
2519
// If we reach here without continuing, return false (will always be false for now)
0 commit comments