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 class
Builder forLlmAgent
.static enum
Enum 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.Builder
builder()
Returns aLlmAgent.Builder
forLlmAgent
.Constructs the text global instruction for this agent based on theglobalInstruction
field.canonicalInstruction
(ReadonlyContext context) Constructs the text instruction for this agent based on theinstruction
field.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 BaseLlmFlow
boolean
boolean
executor()
Optional
<com.google.genai.types.GenerateContentConfig> Optional
<com.google.genai.types.Schema> maxSteps()
model()
Optional
<com.google.genai.types.Schema> boolean
planning()
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.Builder
forLlmAgent
. -
determineLlmFlow
-
runAsyncImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext) Description copied from class:BaseAgent
Agent-specific asynchronous logic.- Specified by:
runAsyncImpl
in 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:BaseAgent
Agent-specific synchronous logic.- Specified by:
runLiveImpl
in 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 theinstruction
field. 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
Single
wrapped 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 theglobalInstruction
field. 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
Single
wrapped 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
Single
wrapped 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
-