Class CallbackContext

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

public class CallbackContext extends ReadonlyContext
The context of various callbacks for an agent invocation.
  • Field Details

  • Constructor Details

    • CallbackContext

      public CallbackContext(InvocationContext invocationContext, EventActions eventActions)
      Initializes callback context.
      Parameters:
      invocationContext - Current invocation context.
      eventActions - Callback event actions.
    • CallbackContext

      public CallbackContext(InvocationContext invocationContext, EventActions eventActions, String eventId)
      Initializes callback context.
      Parameters:
      invocationContext - Current invocation context.
      eventActions - Callback event actions.
      eventId - The ID of the event associated with this context.
  • Method Details

    • state

      public State state()
      Returns the delta-aware state of the current callback.
      Overrides:
      state in class ReadonlyContext
    • eventActions

      public EventActions eventActions()
      Returns the EventActions associated with this context.
    • eventId

      public String eventId()
      Returns the ID of the event associated with this context.
    • listArtifacts

      public io.reactivex.rxjava3.core.Single<List<String>> listArtifacts()
      Lists the filenames of the artifacts attached to the current session.
      Returns:
      the list of artifact filenames
    • loadArtifact

      public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename)
      Loads the latest version of an artifact from the service.
    • loadArtifact

      public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, int version)
      Loads a specific version of an artifact from the service.
    • loadArtifact

      @Deprecated public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, Optional<Integer> version)
      Deprecated.
    • saveArtifact

      public io.reactivex.rxjava3.core.Completable saveArtifact(String filename, com.google.genai.types.Part artifact)
      Saves an artifact and records it as a delta for the current session.
      Parameters:
      filename - Artifact file name.
      artifact - Artifact content to save.
      Returns:
      a Completable that completes when the artifact is saved.
      Throws:
      IllegalStateException - if the artifact service is not initialized.