loop/agent.go: don't panic on nil toolResp
diff --git a/loop/agent.go b/loop/agent.go
index 910b4cc..f5b12f7 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -985,7 +985,7 @@
}
}()
- // Main response loop - continue as long as the model is using tools
+ // Main response loop - continue as long as the model is using tools or a tool use fails.
resp := initialResp
for {
// Check if we are over budget
@@ -1009,6 +1009,10 @@
return nil
}
+ if toolResp == nil {
+ return fmt.Errorf("cannot continue conversation with a nil tool response")
+ }
+
// Set the response for the next iteration
resp = toolResp
}