diff --git a/internal/providers/claude_cli_chat.go b/internal/providers/claude_cli_chat.go index 8acc8025..7c8271f6 100644 --- a/internal/providers/claude_cli_chat.go +++ b/internal/providers/claude_cli_chat.go @@ -138,7 +138,7 @@ func (p *ClaudeCLIProvider) ChatStream(ctx context.Context, req ChatRequest, onC // Parse stream-json line-by-line scanner := bufio.NewScanner(stdout) - scanner.Buffer(make([]byte, 0, 256*1024), 1024*1024) // 256KB initial, 1MB max + scanner.Buffer(make([]byte, 0, 256*1024), 10*1024*1024) // 256KB initial, 10MB max var finalResp ChatResponse var contentBuf strings.Builder @@ -194,6 +194,10 @@ func (p *ClaudeCLIProvider) ChatStream(ctx context.Context, req ChatRequest, onC } } + if err := scanner.Err(); err != nil { + return nil, fmt.Errorf("claude-cli: stream read error: %w", err) + } + if err := cmd.Wait(); err != nil { if debugFile != nil { fmt.Fprintf(debugFile, "\n=== STDERR:\n%s\n=== EXIT ERROR: %v\n", stderrBuf.String(), err)