Class GlobalInstructionPlugin
java.lang.Object
com.google.adk.plugins.BasePlugin
com.google.adk.plugins.GlobalInstructionPlugin
- All Implemented Interfaces:
Plugin
Plugin that provides global instructions functionality at the App level.
Global instructions are applied to all agents in the application, providing a consistent way
to set application-wide instructions, identity, or personality. Global instructions can be
provided as a static string, or as a function that resolves the instruction based on the CallbackContext.
The plugin operates through the before_model_callback, allowing it to modify LLM requests before they are sent to the model by prepending the global instruction to any existing system instructions provided by the agent.
-
Field Summary
Fields inherited from class BasePlugin
name -
Constructor Summary
ConstructorsConstructorDescriptionGlobalInstructionPlugin(String globalInstruction) GlobalInstructionPlugin(String globalInstruction, String name) GlobalInstructionPlugin(Function<CallbackContext, io.reactivex.rxjava3.core.Maybe<String>> instructionProvider) GlobalInstructionPlugin(Function<CallbackContext, io.reactivex.rxjava3.core.Maybe<String>> instructionProvider, String name) -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Maybe<LlmResponse> beforeModelCallback(CallbackContext callbackContext, LlmRequest.Builder llmRequest) Callback executed before a request is sent to the model.Methods inherited from class BasePlugin
getNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Plugin
afterAgentCallback, afterModelCallback, afterRunCallback, afterToolCallback, beforeAgentCallback, beforeRunCallback, beforeToolCallback, close, onEventCallback, onModelErrorCallback, onToolErrorCallback, onUserMessageCallback
-
Constructor Details
-
GlobalInstructionPlugin
-
GlobalInstructionPlugin
-
GlobalInstructionPlugin
public GlobalInstructionPlugin(Function<CallbackContext, io.reactivex.rxjava3.core.Maybe<String>> instructionProvider) -
GlobalInstructionPlugin
public GlobalInstructionPlugin(Function<CallbackContext, io.reactivex.rxjava3.core.Maybe<String>> instructionProvider, String name)
-
-
Method Details
-
beforeModelCallback
public io.reactivex.rxjava3.core.Maybe<LlmResponse> beforeModelCallback(CallbackContext callbackContext, LlmRequest.Builder llmRequest) Description copied from interface:PluginCallback executed before a request is sent to the model.- Parameters:
callbackContext- The context for the current agent call.llmRequest- The mutable request builder, allowing modification of the request before it is sent to the model.- Returns:
- An optional LlmResponse to trigger an early exit. Returning Empty to proceed normally.
-