Environment (please complete the following):
- OS: Darwin Kernel Version 24.6.0
- kubectl-ai version:
- version: 0.0.23
- commit: 0f6537e
- date: 2025-08-25T23:13:54Z
- LLM provider: openai
- LLM model: claude sonnet 4
Describe the bug
I get intermittent error using kubectl-ai on mac machine.
panic: runtime error: index out of range [-1]
goroutine 8 [running]:
github.com/openai/openai-go.(*ChatCompletion).accumulateDelta(_, {{0x140004741c7, 0x11}, {0x14000634288, 0x1, 0x1}, 0x68c978f5, {0x140004741f8, 0x63}, {0x14000474349, ...}, ...})
/home/runner/go/pkg/mod/github.com/openai/openai-go@v1.11.0/streamaccumulator.go:129 +0x6e0
github.com/openai/openai-go.(*ChatCompletionAccumulator).AddChunk(_, {{0x140004741c7, 0x11}, {0x14000634288, 0x1, 0x1}, 0x68c978f5, {0x140004741f8, 0x63}, {0x14000474349, ...}, ...})
/home/runner/go/pkg/mod/github.com/openai/openai-go@v1.11.0/streamaccumulator.go:40 +0x4c
github.com/GoogleCloudPlatform/kubectl-ai/gollm.(*openAIChatSession).SendStreaming.func1(0x140004e0640)
/home/runner/work/kubectl-ai/kubectl-ai/gollm/openai.go:332 +0x128
github.com/GoogleCloudPlatform/kubectl-ai/pkg/agent.(*Agent).Run.func1()
/home/runner/work/kubectl-ai/kubectl-ai/pkg/agent/conversation.go:498 +0x10a0
created by github.com/GoogleCloudPlatform/kubectl-ai/pkg/agent.(*Agent).Run in goroutine 1
/home/runner/work/kubectl-ai/kubectl-ai/pkg/agent/conversation.go:293 +0x1b0
I did ask LLM about it, here is what I got back
"“When using streaming responses from the OpenAI-compatible model, an occasional malformed incremental update (a chunk with an invalid internal index) causes the underlying OpenAI Go SDK to panic with ‘index out of range [-1]’. This is not caused by your input; it’s a transient protocol issue. Re-running the command usually succeeds because the next streamed sequence is well-formed.”"
Environment (please complete the following):
- version: 0.0.23
- commit: 0f6537e
- date: 2025-08-25T23:13:54Z
Describe the bug
I get intermittent error using kubectl-ai on mac machine.
I did ask LLM about it, here is what I got back
"“When using streaming responses from the OpenAI-compatible model, an occasional malformed incremental update (a chunk with an invalid internal index) causes the underlying OpenAI Go SDK to panic with ‘index out of range [-1]’. This is not caused by your input; it’s a transient protocol issue. Re-running the command usually succeeds because the next streamed sequence is well-formed.”"