streaming: tool output streams into tool block directly

This commit is contained in:
ollie 2026-07-19 21:25:42 +02:00
parent 5fc7bd816e
commit 805933453f
1 changed files with 6 additions and 6 deletions

View File

@ -300,7 +300,7 @@ func run(ctx context.Context, cfg agentConfig, state state) error {
var isErr bool
if cfg.Exec != nil {
streamCtx := tools.WithOutputStream(ctx, func(data string) {
emit(cfg, Event{Role: "exec", Name: tc.Name, Content: data})
emit(cfg, Event{Role: "tool", Name: tc.Name, Content: data})
})
out, blocks, err := cfg.Exec(streamCtx, tc.Name, tc.Arguments)
if err != nil {
@ -346,11 +346,11 @@ func run(ctx context.Context, cfg agentConfig, state state) error {
result += fmt.Sprintf("\n\n[HARD LIMIT: %s output truncated — %d of %d bytes shown. This is a safety ceiling, not a semantic boundary.]",
tc.Name, cfg.ToolResultMaxBytes, orig)
}
if readSafe && !isErr {
resultCache.Store(tc.Name+"\x00"+string(tc.Arguments), result)
}
emit(cfg, Event{Role: "tool", Name: tc.Name, Content: result})
tier := TierHot
if readSafe && !isErr {
resultCache.Store(tc.Name+"\x00"+string(tc.Arguments), result)
}
emit(cfg, Event{Role: "tool", Name: tc.Name, Content: result})
tier := TierHot
if !isErr && cfg.ClassifyTier != nil {
tier = cfg.ClassifyTier(tc.Name, tc.Arguments)
}