googleai: panic on system-only message list in GenerateContent
Author: rg0nowCreated Jun 18, 2026Updated Sep 12, 2026
generateFromMessages panics with index out of range [-1] when all input messages are system messages (history becomes empty before selecting the request message).
Repro shape:
- messages contain only role=system
- call GenerateContent (including stream mode)
- panic at history[n-1]
Stack seen from downstream integration: github.com/tmc/langchaingo/llms/googleai.generateFromMessages(...) llms/googleai/googleai.go:333
Suggested fix: return an error for empty non-system history, or gracefully route to single-message path.
Source: tmc/langchaingo