Commit f1d3cc5
authored
fix: prevent panic when LLMAgent has no Model configured (google#280)
Add nil check in Flow.callLLM() after BeforeModelCallbacks but before
accessing Model.GenerateContent(). This prevents a nil pointer dereference
panic when an llmagent is created without a Model configuration.
The check is positioned after BeforeModelCallbacks to allow callbacks that
return cached responses to short-circuit execution without requiring a Model.
This provides a clear error message instead of a cryptic segmentation fault:
'agent %q has no Model configured; ensure Model is set in llmagent.Config'
Preserves valid use cases:
- Testing agent metadata/structure without running the agent
- BeforeAgentCallbacks that short-circuit before agent execution
- BeforeModelCallbacks that return cached responses
Fixes panic: runtime error: invalid memory address or nil pointer
dereference when sub-agents without Models were invoked.1 parent 7f5fe5e commit f1d3cc5
1 file changed
+5
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| |||
0 commit comments