Commit ab58b75
Changed files (1)
cmd
del
cmd/del/main.go
@@ -2529,14 +2529,17 @@ func (d *Del) processMessage(ctx context.Context, userInput string) {
// Add all tool results to history
d.chatHistory = append(d.chatHistory, toolResults...)
- // Get final AI response after tool execution
+ // Get final AI response after tool execution (without tools to avoid confusion)
d.updateThinking("🧠 Generating final response...")
+ finalCtx, finalCancel := context.WithTimeout(ctx, 30*time.Second)
+ defer finalCancel()
+
var finalResponse string
- err = d.client.Chat(chatCtx, &api.ChatRequest{
+ err = d.client.Chat(finalCtx, &api.ChatRequest{
Model: d.model,
Messages: d.chatHistory,
- Tools: tools,
+ // Don't include tools in final response to avoid infinite loops
}, func(resp api.ChatResponse) error {
finalResponse += resp.Message.Content
return nil
@@ -2545,6 +2548,9 @@ func (d *Del) processMessage(ctx context.Context, userInput string) {
if err == nil && finalResponse != "" {
d.chatHistory = append(d.chatHistory, api.Message{Role: "assistant", Content: finalResponse})
fullResponse = finalResponse
+ } else if err != nil {
+ // If final response fails, just show tool results
+ fullResponse = "✅ Tool execution completed successfully."
}
}