Skip to content

Commit e474101

Browse files
shentongmartinmeguminnnnnnnnn
authored andcommitted
fix: only set automatic close on events added to session and emitted … (#343)
fix: only set automatic close on events added to session and emitted by flow agent Change-Id: I48c12915b0f2ee5606262bbf0857eb1a571faf10
1 parent e876957 commit e474101

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

adk/chatmodel.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ func (h *cbHandler) onChatModelEndWithStreamOutput(ctx context.Context,
302302
}
303303
out := schema.StreamReaderWithConvert(output, cvt)
304304
event := EventFromMessage(nil, out, schema.Assistant, "")
305-
setAutomaticClose(event)
306305
h.Send(event)
307306

308307
return ctx
@@ -332,7 +331,6 @@ func (h *cbHandler) onToolEndWithStreamOutput(ctx context.Context,
332331
}
333332
out := schema.StreamReaderWithConvert(output, cvt)
334333
event := EventFromMessage(nil, out, schema.Tool, runInfo.Name)
335-
setAutomaticClose(event)
336334
h.Send(event)
337335

338336
return ctx
@@ -441,7 +439,6 @@ func (a *ChatModelAgent) buildRunFunc(ctx context.Context) runFunc {
441439
// copy the stream first because when setting output to session, the stream will be consumed
442440
ss := msgStream.Copy(2)
443441
event = EventFromMessage(msg, ss[1], schema.Assistant, "")
444-
setAutomaticClose(event)
445442
msgStream = ss[0]
446443
} else {
447444
event = EventFromMessage(msg, nil, schema.Assistant, "")

adk/flow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ func (a *flowAgent) Run(ctx context.Context, input *AgentInput, opts ...AgentRun
298298
// copy the event so that the copied event's stream is exclusive for any potential consumer
299299
// copy before adding to session because once added to session it's stream could be consumed by genAgentInput at any time
300300
copied := copyAgentEvent(event)
301+
setAutomaticClose(event)
301302
runCtx.session.addEvent(event)
302303
setAutomaticClose(copied)
303304
generator.Send(copied)

0 commit comments

Comments
 (0)