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.
  • 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.
    • loadArtifact

      public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String filename, Optional<Integer> version)
      Loads an artifact from the artifact service associated with the current session.
      Parameters:
      filename - Artifact file name.
      version - Artifact version (optional).
      Returns:
      loaded part, or empty if not found.
      Throws:
      IllegalStateException - if the artifact service is not initialized.
    • saveArtifact

      public void 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.
      Throws:
      IllegalStateException - if the artifact service is not initialized.