Package com.google.adk.plugins
Class SaveFilesAsArtifactsPlugin
java.lang.Object
com.google.adk.plugins.BasePlugin
com.google.adk.plugins.SaveFilesAsArtifactsPlugin
- All Implemented Interfaces:
Plugin
Saves files attached to user messages as artifacts, replacing each with a placeholder that names
the artifact so agents can load it later, such as with
LoadArtifactsTool. Each file is saved under its display name, where a user: prefix shares it across the user's sessions, or under a
generated name if it has no display name; files over 20 MB are replaced with an error note
instead. Mirrors Python ADK's SaveFilesAsArtifactsPlugin.-
Field Summary
Fields inherited from class com.google.adk.plugins.BasePlugin
name -
Constructor Summary
ConstructorsConstructorDescriptionSaveFilesAsArtifactsPlugin(boolean attachFileReference) SaveFilesAsArtifactsPlugin(boolean attachFileReference, String name) Creates the plugin. -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content>beforeAgentCallback(BaseAgent agent, CallbackContext callbackContext) Reports the versions saved from the user message on the event of the first agent to run, since a plugin cannot add actions to the user's own event.io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content>onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) Callback executed when a user message is received before an invocation starts.Methods inherited from class com.google.adk.plugins.BasePlugin
getNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.adk.plugins.Plugin
afterAgentCallback, afterModelCallback, afterRunCallback, afterToolCallback, beforeModelCallback, beforeRunCallback, beforeToolCallback, close, onEventCallback, onModelErrorCallback, onRunErrorCallback, onToolErrorCallback
-
Constructor Details
-
SaveFilesAsArtifactsPlugin
public SaveFilesAsArtifactsPlugin() -
SaveFilesAsArtifactsPlugin
public SaveFilesAsArtifactsPlugin(boolean attachFileReference) -
SaveFilesAsArtifactsPlugin
Creates the plugin.- Parameters:
attachFileReference- Whether to also attach aFileDatareference to each saved file when the artifact service stores it at a URI the model can read (gs,httpsorhttp).name- The unique name of the plugin instance.
-
-
Method Details
-
onUserMessageCallback
public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> onUserMessageCallback(InvocationContext invocationContext, com.google.genai.types.Content userMessage) Description copied from interface:PluginCallback executed when a user message is received before an invocation starts.- Parameters:
invocationContext- The context for the entire invocation.userMessage- The message content input by user.- Returns:
- An optional Content to replace the user message. Returning Empty to proceed normally.
-
beforeAgentCallback
public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Content> beforeAgentCallback(BaseAgent agent, CallbackContext callbackContext) Reports the versions saved from the user message on the event of the first agent to run, since a plugin cannot add actions to the user's own event.- Parameters:
agent- The agent that is about to run.callbackContext- The context for the agent invocation.- Returns:
- An optional Content object to bypass the agent's execution. Returning Empty to proceed normally.
-