Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(agent): raise the agent stream scanner cap to 32 MiB and share it (MUL-5722) (#6383)

Bohan Jianga23b936b7b65
diff --git a/server/pkg/agent/antigravity.go b/server/pkg/agent/antigravity.go
index 1fc529fd87..13cf54f8f9 100644
--- a/server/pkg/agent/antigravity.go
+++ b/server/pkg/agent/antigravity.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -125,8 +124,7 @@ func (b *antigravityBackend) Execute(ctx context.Context, prompt string, opts Ex
finalStatus := "completed"
var finalError string
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
trySend(msgCh, Message{Type: MessageStatus, Status: "running"})
@@ -353,8 +351,7 @@ func readAntigravityTranscriptOutput(logPath, conversationID string) string {
defer f.Close()
var parts []string
- scanner := bufio.NewScanner(f)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(f)
for scanner.Scan() {
line := scanner.Bytes()
if len(line) == 0 {
diff --git a/server/pkg/agent/claude.go b/server/pkg/agent/claude.go
index ad877a8e22..6a96dd62a3 100644
--- a/server/pkg/agent/claude.go
+++ b/server/pkg/agent/claude.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -213,8 +212,7 @@ func (b *claudeBackend) Execute(ctx context.Context, prompt string, opts ExecOpt
_ = stdout.Close()
}()
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
diff --git a/server/pkg/agent/codebuddy.go b/server/pkg/agent/codebuddy.go
index 906a8a9719..af39a8c9d1 100644
--- a/server/pkg/agent/codebuddy.go
+++ b/server/pkg/agent/codebuddy.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -196,8 +195,7 @@ func (b *codebuddyBackend) Execute(ctx context.Context, prompt string, opts Exec
_ = stdout.Close()
}()
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
diff --git a/server/pkg/agent/codex.go b/server/pkg/agent/codex.go
index 6989fdb5c2..2ed7b9fe84 100644
--- a/server/pkg/agent/codex.go
+++ b/server/pkg/agent/codex.go
@@ -1085,8 +1085,7 @@ func (b *codexBackend) executeOnce(ctx context.Context, prompt string, opts Exec
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/codex_test.go b/server/pkg/agent/codex_test.go
index db65f24047..61e6d9bdc6 100644
--- a/server/pkg/agent/codex_test.go
+++ b/server/pkg/agent/codex_test.go
@@ -3133,8 +3133,8 @@ func TestCodexExecuteCleansUpWhenScannerOverflowsOnResume(t *testing.T) {
}
// Regression for GH#4520. On `thread/resume`, the fake codex emits a
- // single stdout line larger than the daemon's bufio.Scanner cap (10 MB),
- // which trips "bufio.Scanner: token too long" in the reader goroutine.
+ // single stdout line larger than agentStreamMaxLineBytes, which trips
+ // "bufio.Scanner: token too long" in the reader goroutine.
// Pre-fix, drainAndWait then hung forever on cmd.Wait(): the reader had
// stopped consuming the pipe, codex was blocked writing into a full
// stdout buffer, stdin.Close never unblocked codex, and the deferred
@@ -3155,12 +3155,13 @@ func TestCodexExecuteCleansUpWhenScannerOverflowsOnResume(t *testing.T) {
`read line`+"\n"+
`echo '{"jsonrpc":"2.0","id":1,"result":{}}'`+"\n"+
`read line`+"\n"+
- // Emit a > 10 MB single line with no embedded newline. printf
+ // Emit a single line past the cap with no embedded newline. printf
// avoids the trailing newline echo would add; head + tr generates
- // the bulk payload in pure POSIX shell. The scanner errors out at
- // 10 MB even though we write 11 MB.
+ // the bulk payload in pure POSIX shell. The size is derived from
+ // the production constant so raising the cap cannot silently turn
+ // this regression test into a no-op.
`printf '{"jsonrpc":"2.0","id":2,"result":{"big":"'`+"\n"+
- `head -c 11000000 /dev/zero | tr '\0' 'x'`+"\n"+
+ fmt.Sprintf(`head -c %d /dev/zero | tr '\0' 'x'`, agentStreamMaxLineBytes+1024*1024)+"\n"+
`printf '"}}\n'`+"\n"+
// Hold the process open without reading more stdin. Pre-fix this
// hangs cmd.Wait() because codex never sees stdin EOF (it isn't
diff --git a/server/pkg/agent/copilot.go b/server/pkg/agent/copilot.go
index 17bf6de1a3..a07c06489e 100644
--- a/server/pkg/agent/copilot.go
+++ b/server/pkg/agent/copilot.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -395,8 +394,7 @@ func (b *copilotBackend) Execute(ctx context.Context, prompt string, opts ExecOp
_ = stdout.Close()
}()
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
diff --git a/server/pkg/agent/cursor.go b/server/pkg/agent/cursor.go
index bc9e19197c..b08c0e396a 100644
--- a/server/pkg/agent/cursor.go
+++ b/server/pkg/agent/cursor.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -141,8 +140,7 @@ func (b *cursorBackend) Execute(ctx context.Context, prompt string, opts ExecOpt
hasResultUsage := false
var thinking cursorThinkingStream
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
raw := scanner.Text()
diff --git a/server/pkg/agent/cursor_execute_unix_test.go b/server/pkg/agent/cursor_execute_unix_test.go
index 61e5589eb0..a960a4b5e1 100644
--- a/server/pkg/agent/cursor_execute_unix_test.go
+++ b/server/pkg/agent/cursor_execute_unix_test.go
@@ -3,6 +3,7 @@
package agent
import (
+ "fmt"
"log/slog"
"os"
"path/filepath"
@@ -186,11 +187,14 @@ exit 1
}
func TestCursorExecuteReportsScannerOverflow(t *testing.T) {
- script := `#!/bin/sh
-printf '%s\n' '{"type":"system","subtype":"init","session_id":"sess-overflow"}'
-dd if=/dev/zero bs=1048576 count=11 2>/dev/null | tr '\000' x
+ // The oversized event is sized from agentStreamMaxLineBytes so raising
+ // the shared cap cannot silently turn this into a plain oversized-line
+ // pass that never reaches the overflow branch.
+ script := fmt.Sprintf(`#!/bin/sh
+printf '%%s\n' '{"type":"system","subtype":"init","session_id":"sess-overflow"}'
+dd if=/dev/zero bs=1048576 count=%d 2>/dev/null | tr '\000' x
printf '\n'
-`
+`, agentStreamMaxLineBytes/(1024*1024)+1)
result := executeFakeCursor(t, script)
if result.Status != "failed" {
diff --git a/server/pkg/agent/deveco.go b/server/pkg/agent/deveco.go
index fc1361caed..cc5d207f1c 100644
--- a/server/pkg/agent/deveco.go
+++ b/server/pkg/agent/deveco.go
@@ -27,7 +27,6 @@ package agent
// (see packages/core/agents/mcp-support.ts).
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -313,8 +312,7 @@ func (b *devecoBackend) processEvents(r io.Reader, ch chan<- Message) devecoEven
finalStatus := "completed"
var finalError string
- scanner := bufio.NewScanner(r)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(r)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
diff --git a/server/pkg/agent/grok.go b/server/pkg/agent/grok.go
index 8f9eded4df..310e424393 100644
--- a/server/pkg/agent/grok.go
+++ b/server/pkg/agent/grok.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"fmt"
"io"
@@ -239,8 +238,7 @@ func (b *grokBackend) Execute(ctx context.Context, prompt string, opts ExecOptio
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/hermes.go b/server/pkg/agent/hermes.go
index c04f18c408..e16140d090 100644
--- a/server/pkg/agent/hermes.go
+++ b/server/pkg/agent/hermes.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"bytes"
"context"
"encoding/json"
@@ -315,8 +314,7 @@ func (b *hermesBackend) Execute(ctx context.Context, prompt string, opts ExecOpt
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/kimi.go b/server/pkg/agent/kimi.go
index 9f7f60e457..aaebff1c39 100644
--- a/server/pkg/agent/kimi.go
+++ b/server/pkg/agent/kimi.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"fmt"
"io"
@@ -178,8 +177,7 @@ func (b *kimiBackend) Execute(ctx context.Context, prompt string, opts ExecOptio
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/kiro.go b/server/pkg/agent/kiro.go
index 6235ce52e2..1fcc20f3b8 100644
--- a/server/pkg/agent/kiro.go
+++ b/server/pkg/agent/kiro.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"errors"
"fmt"
@@ -205,8 +204,7 @@ func (b *kiroBackend) Execute(ctx context.Context, prompt string, opts ExecOptio
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/openclaw.go b/server/pkg/agent/openclaw.go
index a4f8929f36..81a4e00047 100644
--- a/server/pkg/agent/openclaw.go
+++ b/server/pkg/agent/openclaw.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"bytes"
"context"
"encoding/json"
@@ -405,8 +404,7 @@ func (b *openclawBackend) processOutput(r io.Reader, ch chan<- Message) openclaw
// backend on this code path emits real NDJSON streams and needs live
// progress updates, we'll need to split the fast path off a streaming
// reader instead of io.ReadAll.
- scanner := bufio.NewScanner(bytes.NewReader(buf))
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(bytes.NewReader(buf))
var output strings.Builder
var sessionID string
diff --git a/server/pkg/agent/opencode.go b/server/pkg/agent/opencode.go
index 2626782bfa..093d9aea52 100644
--- a/server/pkg/agent/opencode.go
+++ b/server/pkg/agent/opencode.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -305,8 +304,7 @@ func (b *opencodeBackend) processEvents(r io.Reader, ch chan<- Message) eventRes
stepHasContinuationTool := false // current step has a local tool result OpenCode must feed back
awaitingContinuation := false // the last step_finish still required another step
- scanner := bufio.NewScanner(r)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(r)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
diff --git a/server/pkg/agent/pi.go b/server/pkg/agent/pi.go
index a85c4e9a8d..9648b56b63 100644
--- a/server/pkg/agent/pi.go
+++ b/server/pkg/agent/pi.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -262,10 +261,9 @@ func (b *piBackend) Execute(ctx context.Context, prompt string, opts ExecOptions
var finalError string
usage := make(map[string]TokenUsage)
- scanner := bufio.NewScanner(stdout)
// Pi message_update events can be large (they embed the full message
- // partial on each delta), so give the scanner generous headroom.
- scanner.Buffer(make([]byte, 0, 1024*1024), 32*1024*1024)
+ // partial on each delta); the shared stream bound covers that.
+ scanner := newAgentStreamScanner(stdout)
var textBuffer strings.Builder
for scanner.Scan() {
diff --git a/server/pkg/agent/qoder.go b/server/pkg/agent/qoder.go
index ef96d6c079..5f6a9e9cfc 100644
--- a/server/pkg/agent/qoder.go
+++ b/server/pkg/agent/qoder.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"fmt"
"io"
@@ -196,8 +195,7 @@ func (b *qoderBackend) Execute(ctx context.Context, prompt string, opts ExecOpti
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/qwen.go b/server/pkg/agent/qwen.go
index d48658ddd4..18634a5242 100644
--- a/server/pkg/agent/qwen.go
+++ b/server/pkg/agent/qwen.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"encoding/json"
"fmt"
@@ -139,8 +138,7 @@ func (b *qwenBackend) Execute(ctx context.Context, prompt string, opts ExecOptio
_ = stdout.Close()
}()
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/qwenpaw.go b/server/pkg/agent/qwenpaw.go
index 2d74980388..b1a070d563 100644
--- a/server/pkg/agent/qwenpaw.go
+++ b/server/pkg/agent/qwenpaw.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"fmt"
"io"
@@ -156,8 +155,7 @@ func (b *qwenpawBackend) Execute(ctx context.Context, prompt string, opts ExecOp
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {
diff --git a/server/pkg/agent/stream_json_final_output_test.go b/server/pkg/agent/stream_json_final_output_test.go
index e643636ac2..c395f5e557 100644
--- a/server/pkg/agent/stream_json_final_output_test.go
+++ b/server/pkg/agent/stream_json_final_output_test.go
@@ -3,6 +3,7 @@ package agent
import (
"bytes"
"context"
+ "fmt"
"log/slog"
"path/filepath"
"runtime"
@@ -173,9 +174,15 @@ printf '%s\n' '{"type":"user","message":{"role":"user","content":[{"type":"tool_
},
{
name: "scanner error fails closed",
- // The production scanner caps a single event at 10 MiB. A larger
- // token produces bufio.ErrTooLong while the child still exits 0.
- scriptBody: `dd if=/dev/zero bs=1048576 count=11 2>/dev/null | tr '\000' x; printf '\n'` + "\n",
+ // The production scanner caps a single event at
+ // agentStreamMaxLineBytes. A larger token produces
+ // bufio.ErrTooLong while the child still exits 0. The count is
+ // derived from the constant so raising the cap cannot silently
+ // turn this case into a plain-oversized-line pass.
+ scriptBody: fmt.Sprintf(
+ `dd if=/dev/zero bs=1048576 count=%d 2>/dev/null | tr '\000' x; printf '\n'`,
+ agentStreamMaxLineBytes/(1024*1024)+1,
+ ) + "\n",
wantStatus: "failed",
wantOutput: "",
wantError: "stdout read error",
diff --git a/server/pkg/agent/stream_scanner.go b/server/pkg/agent/stream_scanner.go
new file mode 100644
index 0000000000..ec94e2d79e
--- /dev/null
+++ b/server/pkg/agent/stream_scanner.go
@@ -0,0 +1,36 @@
+package agent
+
+import (
+ "bufio"
+ "io"
+)
+
+// agentStreamMaxLineBytes bounds a single line read from an agent CLI's
+// event stream. Agent transports are line-delimited JSON, and one line can
+// carry a whole conversation: Codex app-server serializes an entire thread
+// into the single `thread/resume` response, and providers that re-send a
+// growing message partial on every delta (Pi) or embed a large tool result
+// in one event grow the same way. Crossing this bound makes scanner.Scan()
+// return false with bufio.ErrTooLong, which the backends can only report as
+// a transport failure — the session itself is fine, we just cannot read it.
+//
+// 32 MiB was picked as the follow-up to GH#4520, where the previous 10 MiB
+// bound broke `thread/resume` for long Codex threads (MUL-5722). It is
+// headroom, not a guarantee: a thread can still outgrow any fixed cap, so
+// the recovery path matters more than the number.
+const agentStreamMaxLineBytes = 32 * 1024 * 1024
+
+// agentStreamInitialBufferBytes is the scanner's starting allocation. Lines
+// above it still grow up to agentStreamMaxLineBytes; this only decides how
+// much is reserved before the first grow, so ordinary events never realloc.
+const agentStreamInitialBufferBytes = 1024 * 1024
+
+// newAgentStreamScanner returns a bufio.Scanner sized for agent event
+// streams. Every backend reading a line-delimited agent transport must go
+// through this constructor: the bound used to be copy-pasted per backend and
+// silently drifted, which is how GH#4520's fix reached only one of them.
+func newAgentStreamScanner(r io.Reader) *bufio.Scanner {
+ scanner := bufio.NewScanner(r)
+ scanner.Buffer(make([]byte, 0, agentStreamInitialBufferBytes), agentStreamMaxLineBytes)
+ return scanner
+}
diff --git a/server/pkg/agent/stream_scanner_test.go b/server/pkg/agent/stream_scanner_test.go
new file mode 100644
index 0000000000..4cec912b02
--- /dev/null
+++ b/server/pkg/agent/stream_scanner_test.go
@@ -0,0 +1,60 @@
+package agent
+
+import (
+ "bufio"
+ "bytes"
+ "errors"
+ "strings"
+ "testing"
+)
+
+// TestAgentStreamScannerReadsPastOldTenMiBCap is the regression for MUL-5722 /
+// GH#4520: Codex serializes a whole thread into the single `thread/resume`
+// response line, and the previous 10 MiB bound turned any thread past that
+// size into a permanent "bufio.Scanner: token too long" resume failure.
+func TestAgentStreamScannerReadsPastOldTenMiBCap(t *testing.T) {
+ t.Parallel()
+
+ const oldCap = 10 * 1024 * 1024
+ if agentStreamMaxLineBytes <= oldCap {
+ t.Fatalf("agentStreamMaxLineBytes must exceed the old %d-byte cap, got %d",
+ oldCap, agentStreamMaxLineBytes)
+ }
+
+ line := strings.Repeat("x", oldCap+1024*1024)
+ scanner := newAgentStreamScanner(strings.NewReader(line + "\n"))
+
+ if !scanner.Scan() {
+ t.Fatalf("expected a %d-byte line to scan, got err=%v", len(line), scanner.Err())
+ }
+ if got := len(scanner.Bytes()); got != len(line) {
+ t.Fatalf("expected %d bytes, got %d", len(line), got)
+ }
+ if err := scanner.Err(); err != nil {
+ t.Fatalf("unexpected scanner error: %v", err)
+ }
+}
+
+// TestAgentStreamScannerStillFailsClosedAboveCap keeps the bound a bound: the
+// backends' overflow handling (fail the turn rather than silently truncate an
+// event) depends on Scan reporting bufio.ErrTooLong, so raising the cap must
+// not mean removing it.
+func TestAgentStreamScannerStillFailsClosedAboveCap(t *testing.T) {
+ t.Parallel()
+
+ var buf bytes.Buffer
+ buf.Grow(agentStreamMaxLineBytes + 2)
+ for i := 0; i < agentStreamMaxLineBytes+1; i++ {
+ buf.WriteByte('x')
+ }
+ buf.WriteByte('\n')
+
+ scanner := newAgentStreamScanner(&buf)
+
+ if scanner.Scan() {
+ t.Fatalf("expected an over-cap line to fail, scanned %d bytes", len(scanner.Bytes()))
+ }
+ if err := scanner.Err(); !errors.Is(err, bufio.ErrTooLong) {
+ t.Fatalf("expected bufio.ErrTooLong, got %v", err)
+ }
+}
diff --git a/server/pkg/agent/traecli.go b/server/pkg/agent/traecli.go
index da9d7f0baa..57459520e4 100644
--- a/server/pkg/agent/traecli.go
+++ b/server/pkg/agent/traecli.go
@@ -1,7 +1,6 @@
package agent
import (
- "bufio"
"context"
"fmt"
"io"
@@ -205,8 +204,7 @@ func (b *traecliBackend) Execute(ctx context.Context, prompt string, opts ExecOp
readerDone := make(chan struct{})
go func() {
defer close(readerDone)
- scanner := bufio.NewScanner(stdout)
- scanner.Buffer(make([]byte, 0, 1024*1024), 10*1024*1024)
+ scanner := newAgentStreamScanner(stdout)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" {