Skip to content

Commit 52e001f

Browse files
authored
graph: Fix event leakage between concurrent nodes (#425)
1 parent db3f659 commit 52e001f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

graph/state_graph.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"reflect"
1818
"time"
1919

20+
"github.com/google/uuid"
2021
"go.opentelemetry.io/otel/attribute"
2122
oteltrace "go.opentelemetry.io/otel/trace"
2223

@@ -1344,10 +1345,12 @@ func buildAgentInvocation(ctx context.Context, state State, targetAgent agent.Ag
13441345

13451346
// clone a new Invocation from parent.
13461347
if parentInvocation, ok := agent.InvocationFromContext(ctx); ok && parentInvocation != nil {
1348+
filterKey := parentInvocation.GetEventFilterKey() + agent.EventFilterKeyDelimiter + targetAgent.Info().Name + uuid.NewString()
13471349
invocation := parentInvocation.Clone(
13481350
agent.WithInvocationAgent(targetAgent),
13491351
agent.WithInvocationMessage(model.NewUserMessage(userInput)),
13501352
agent.WithInvocationRunOptions(agent.RunOptions{RuntimeState: state}),
1353+
agent.WithInvocationEventFilterKey(filterKey),
13511354
)
13521355
return invocation
13531356
}
@@ -1357,6 +1360,7 @@ func buildAgentInvocation(ctx context.Context, state State, targetAgent agent.Ag
13571360
agent.WithInvocationRunOptions(agent.RunOptions{RuntimeState: state}),
13581361
agent.WithInvocationMessage(model.NewUserMessage(userInput)),
13591362
agent.WithInvocationSession(sessionData),
1363+
agent.WithInvocationEventFilterKey(targetAgent.Info().Name+uuid.NewString()),
13601364
)
13611365
return invocation
13621366
}

0 commit comments

Comments
 (0)