diff --git a/core/src/main/java/com/google/adk/agents/ReadonlyContext.java b/core/src/main/java/com/google/adk/agents/ReadonlyContext.java index 9965adf2d..1cdac16de 100644 --- a/core/src/main/java/com/google/adk/agents/ReadonlyContext.java +++ b/core/src/main/java/com/google/adk/agents/ReadonlyContext.java @@ -16,8 +16,11 @@ package com.google.adk.agents; +import com.google.adk.events.Event; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.genai.types.Content; +import java.util.List; import java.util.Map; import java.util.Optional; @@ -50,6 +53,21 @@ public String agentName() { return invocationContext.agent().name(); } + /** Returns the session ID. */ + public String sessionId() { + return invocationContext.session().id(); + } + + /** + * Returns a read-only view of the events of the current session. + * + *

This is a shallow copy and if the underlying values of the list are modified, the read-only + * view will also be modified. + */ + public ImmutableList events() { + return ImmutableList.copyOf(invocationContext.session().events()); + } + /** * Returns a read-only view of the state of the current session. *