diff --git a/core/src/main/java/com/google/adk/agents/InvocationContext.java b/core/src/main/java/com/google/adk/agents/InvocationContext.java index 7602ca9f2..7f0e49d0c 100644 --- a/core/src/main/java/com/google/adk/agents/InvocationContext.java +++ b/core/src/main/java/com/google/adk/agents/InvocationContext.java @@ -75,7 +75,10 @@ protected InvocationContext(Builder builder) { this.eventsCompactionConfig = builder.eventsCompactionConfig; this.contextCacheConfig = builder.contextCacheConfig; this.invocationCostManager = builder.invocationCostManager; - this.callbackContextData = new ConcurrentHashMap<>(builder.callbackContextData); + // Don't copy the callback context data. This should be the same instance for the full + // invocation invocation so that Plugins can access the same data it during the invocation + // across all types of callbacks. + this.callbackContextData = builder.callbackContextData; } /** @@ -345,7 +348,10 @@ private Builder(InvocationContext context) { this.eventsCompactionConfig = context.eventsCompactionConfig; this.contextCacheConfig = context.contextCacheConfig; this.invocationCostManager = context.invocationCostManager; - this.callbackContextData = new ConcurrentHashMap<>(context.callbackContextData); + // Don't copy the callback context data. This should be the same instance for the full + // invocation invocation so that Plugins can access the same data it during the invocation + // across all types of callbacks. + this.callbackContextData = context.callbackContextData; } private BaseSessionService sessionService;