Class LlmAgent
java.lang.Object
com.google.adk.agents.BaseAgent
com.google.adk.agents.LlmAgent
The LLM-based agent.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder forLlmAgent.static enumEnum to define if contents of previous events should be included in requests to the underlying LLM. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LlmAgent.Builderbuilder()Returns aLlmAgent.BuilderforLlmAgent.Constructs the text global instruction for this agent based on theglobalInstructionfield.canonicalInstruction(ReadonlyContext context) Constructs the text instruction for this agent based on theinstructionfield.io.reactivex.rxjava3.core.Flowable<BaseTool> Overload of canonicalTools that defaults to an empty context.io.reactivex.rxjava3.core.Flowable<BaseTool> canonicalTools(ReadonlyContext context) Convenience overload of canonicalTools that accepts a non-optional ReadonlyContext.io.reactivex.rxjava3.core.Flowable<BaseTool> canonicalTools(Optional<ReadonlyContext> context) Constructs the list of tools for this agent based on thetools()field.protected BaseLlmFlowbooleanbooleanexecutor()Optional<com.google.genai.types.GenerateContentConfig> Optional<com.google.genai.types.Schema> maxSteps()model()Optional<com.google.genai.types.Schema> booleanplanning()protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext) Agent-specific asynchronous logic.protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext) Agent-specific synchronous logic.tools()Methods inherited from class com.google.adk.agents.BaseAgent
afterAgentCallback, beforeAgentCallback, description, findAgent, findSubAgent, name, parentAgent, parentAgent, rootAgent, runAsync, runLive, subAgents
-
Constructor Details
-
LlmAgent
-
-
Method Details
-
builder
Returns aLlmAgent.BuilderforLlmAgent. -
determineLlmFlow
-
runAsyncImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext) Description copied from class:BaseAgentAgent-specific asynchronous logic.- Specified by:
runAsyncImplin classBaseAgent- Parameters:
invocationContext- Current invocation context.- Returns:
- stream of agent-generated events.
-
runLiveImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext) Description copied from class:BaseAgentAgent-specific synchronous logic.- Specified by:
runLiveImplin classBaseAgent- Parameters:
invocationContext- Current invocation context.- Returns:
- stream of agent-generated events.
-
canonicalInstruction
public io.reactivex.rxjava3.core.Single<Map.Entry<String,Boolean>> canonicalInstruction(ReadonlyContext context) Constructs the text instruction for this agent based on theinstructionfield. Also returns a boolean indicating that state injection should be bypassed when the instruction is constructed with anInstruction.Provider.This method is only for use by Agent Development Kit.
- Parameters:
context- The context to retrieve the session state.- Returns:
- The resolved instruction as a
Singlewrapped Map.Entry. The key is the instruction string and the value is a boolean indicating if state injection should be bypassed.
-
canonicalGlobalInstruction
public io.reactivex.rxjava3.core.Single<Map.Entry<String,Boolean>> canonicalGlobalInstruction(ReadonlyContext context) Constructs the text global instruction for this agent based on theglobalInstructionfield. Also returns a boolean indicating that state injection should be bypassed when the instruction is constructed with anInstruction.Provider.This method is only for use by Agent Development Kit.
- Parameters:
context- The context to retrieve the session state.- Returns:
- The resolved global instruction as a
Singlewrapped Map.Entry. The key is the instruction string and the value is a boolean indicating if state injection should be bypassed.
-
canonicalTools
public io.reactivex.rxjava3.core.Flowable<BaseTool> canonicalTools(Optional<ReadonlyContext> context) Constructs the list of tools for this agent based on thetools()field.This method is only for use by Agent Development Kit.
- Parameters:
context- The context to retrieve the session state.- Returns:
- The resolved list of tools as a
Singlewrapped list ofBaseTool.
-
canonicalTools
Overload of canonicalTools that defaults to an empty context. -
canonicalTools
Convenience overload of canonicalTools that accepts a non-optional ReadonlyContext. -
instruction
-
globalInstruction
-
model
-
planning
public boolean planning() -
maxSteps
-
generateContentConfig
-
exampleProvider
-
includeContents
-
tools
-
toolsUnion
-
disallowTransferToParent
public boolean disallowTransferToParent() -
disallowTransferToPeers
public boolean disallowTransferToPeers() -
beforeModelCallback
-
afterModelCallback
-
beforeToolCallback
-
afterToolCallback
-
inputSchema
-
outputSchema
-
executor
-
outputKey
-
resolvedModel
-