streaming: tool output streams into [tool:] block, no new roles
This commit is contained in:
parent
805933453f
commit
9c1dd58474
|
|
@ -298,8 +298,13 @@ func run(ctx context.Context, cfg agentConfig, state state) error {
|
|||
var result string
|
||||
var resultBlocks []backend.ContentBlock
|
||||
var isErr bool
|
||||
streamed := false
|
||||
if cfg.Exec != nil {
|
||||
streamCtx := tools.WithOutputStream(ctx, func(data string) {
|
||||
if !streamed {
|
||||
emit(cfg, Event{Role: "tool", Name: tc.Name})
|
||||
streamed = true
|
||||
}
|
||||
emit(cfg, Event{Role: "tool", Name: tc.Name, Content: data})
|
||||
})
|
||||
out, blocks, err := cfg.Exec(streamCtx, tc.Name, tc.Arguments)
|
||||
|
|
@ -349,7 +354,9 @@ func run(ctx context.Context, cfg agentConfig, state state) error {
|
|||
if readSafe && !isErr {
|
||||
resultCache.Store(tc.Name+"\x00"+string(tc.Arguments), result)
|
||||
}
|
||||
emit(cfg, Event{Role: "tool", Name: tc.Name, Content: result})
|
||||
if !streamed {
|
||||
emit(cfg, Event{Role: "tool", Name: tc.Name, Content: result})
|
||||
}
|
||||
tier := TierHot
|
||||
if !isErr && cfg.ClassifyTier != nil {
|
||||
tier = cfg.ClassifyTier(tc.Name, tc.Arguments)
|
||||
|
|
|
|||
Reference in New Issue