Class ReadonlyContext

java.lang.Object
com.google.adk.agents.ReadonlyContext
Direct Known Subclasses:
CallbackContext

public class ReadonlyContext extends Object
Provides read-only access to the context of an agent run.
  • Field Details

  • Constructor Details

  • Method Details

    • userContent

      public Optional<com.google.genai.types.Content> userContent()
      Returns the user content that initiated this invocation.
    • invocationId

      public String invocationId()
      Returns the ID of the current invocation.
    • branch

      public Optional<String> branch()
      Returns the branch of the current invocation, if present.
    • agentName

      public String agentName()
      Returns the name of the agent currently running.
    • sessionId

      public String sessionId()
      Returns the session ID.
    • events

      public List<Event> events()
      Returns an unmodifiable view of the events of the session.

      Warning: This is a live view, not a snapshot.

    • state

      public Map<String,Object> state()
      Returns an unmodifiable view of the state of the session.

      Warning: This is a live view, not a snapshot.