From 85df48b0c3195188ce68bb8dc6f65e857b538c27 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Mon, 10 Aug 2026 20:07:35 +0200 Subject: [PATCH] agent: remove dead streaming code WithOutputStream context never crossed IPC boundary to toolsrv, so streamed was always false. Simplify to just emit result directly. --- agent/loop.go | 28 ++-------------------------- toolsrv/client9p.go | 5 ----- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/agent/loop.go b/agent/loop.go index 376399c..7ad1282 100644 --- a/agent/loop.go +++ b/agent/loop.go @@ -481,26 +481,9 @@ func execOne(rt *Runtime, ctx TurnCtx, call backend.ToolCall, resultCache *sync. var result string var resultBlocks []backend.ContentBlock var isErr bool - streamed := false if rt.Exec != nil { - streamBytes := 0 - streamCtx := toolsrv.WithOutputStream(ctx, func(data string) { - if streamBytes >= defaultToolResultMaxBytes { - return - } - if !streamed { - emit(ctx, Event{Role: "tool", Name: call.Name, OutputFormat: toolOutputFormat(rt, call.Name)}) - streamed = true - } - streamBytes += len(data) - if streamBytes > defaultToolResultMaxBytes { - excess := streamBytes - defaultToolResultMaxBytes - data = data[:len(data)-excess] - } - emit(ctx, Event{Role: "tool", Name: call.Name, Content: data, OutputFormat: toolOutputFormat(rt, call.Name)}) - }) - out, blocks, err := rt.Exec(streamCtx, call.Name, call.Arguments) + out, blocks, err := rt.Exec(ctx, call.Name, call.Arguments) if err != nil { isErr = true if ctx.Err() != nil { @@ -555,14 +538,7 @@ func execOne(rt *Runtime, ctx TurnCtx, call backend.ToolCall, resultCache *sync. }) } - if !streamed { - emit(ctx, Event{Role: "tool", Name: call.Name, Content: result, OutputFormat: toolOutputFormat(rt, call.Name)}) - } else { - if suffix != "" { - emit(ctx, Event{Role: "tool", Name: call.Name, Content: suffix, OutputFormat: toolOutputFormat(rt, call.Name)}) - } - emit(ctx, Event{Role: "tool", Name: call.Name, OutputFormat: toolOutputFormat(rt, call.Name)}) - } + emit(ctx, Event{Role: "tool", Name: call.Name, Content: result, OutputFormat: toolOutputFormat(rt, call.Name)}) tier := MemoryHot if !isErr { diff --git a/toolsrv/client9p.go b/toolsrv/client9p.go index 202b4de..f373073 100644 --- a/toolsrv/client9p.go +++ b/toolsrv/client9p.go @@ -419,11 +419,6 @@ func (e RateLimitedError) Error() string { return e.Err.Error() } -// WithOutputStream returns a context with streaming output function attached. -func WithOutputStream(ctx context.Context, fn func(string)) context.Context { - return WithStreamFunc(ctx, fn) -} - // --- Helpers --- func randomSecret() string {