diff options
| -rw-r--r-- | cmd/del/main.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cmd/del/main.go b/cmd/del/main.go index 0696fb3..2d42eda 100644 --- a/cmd/del/main.go +++ b/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." } } |
