agent: remove dead streaming code

WithOutputStream context never crossed IPC boundary to toolsrv,
so streamed was always false. Simplify to just emit result directly.
This commit is contained in:
Levi Neely 2026-08-10 20:07:35 +02:00
parent b01189e731
commit 85df48b0c3
2 changed files with 2 additions and 31 deletions

View File

@ -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 {

View File

@ -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 {