Class LlmAgent

java.lang.Object
com.google.adk.agents.BaseAgent
com.google.adk.agents.LlmAgent

public class LlmAgent extends BaseAgent
The LLM-based agent.
  • Constructor Details

  • Method Details

    • builder

      public static LlmAgent.Builder builder()
      Returns a LlmAgent.Builder for LlmAgent.
    • determineLlmFlow

      protected BaseLlmFlow 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 class BaseAgent
      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 class BaseAgent
      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 the instruction field. Also returns a boolean indicating that state injection should be bypassed when the instruction is constructed with an Instruction.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 the globalInstruction field. Also returns a boolean indicating that state injection should be bypassed when the instruction is constructed with an Instruction.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 the tools() 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 of BaseTool.
    • canonicalTools

      public io.reactivex.rxjava3.core.Flowable<BaseTool> canonicalTools()
      Overload of canonicalTools that defaults to an empty context.
    • canonicalTools

      public io.reactivex.rxjava3.core.Flowable<BaseTool> canonicalTools(ReadonlyContext context)
      Convenience overload of canonicalTools that accepts a non-optional ReadonlyContext.
    • instruction

      public Instruction instruction()
    • globalInstruction

      public Instruction globalInstruction()
    • model

      public Optional<Model> model()
    • planning

      public boolean planning()
    • maxSteps

      public Optional<Integer> maxSteps()
    • generateContentConfig

      public Optional<com.google.genai.types.GenerateContentConfig> generateContentConfig()
    • exampleProvider

      public Optional<BaseExampleProvider> exampleProvider()
    • includeContents

      public LlmAgent.IncludeContents includeContents()
    • tools

      public List<BaseTool> tools()
    • toolsUnion

      public List<Object> toolsUnion()
    • disallowTransferToParent

      public boolean disallowTransferToParent()
    • disallowTransferToPeers

      public boolean disallowTransferToPeers()
    • beforeModelCallback

      public Optional<List<Callbacks.BeforeModelCallback>> beforeModelCallback()
    • afterModelCallback

      public Optional<List<Callbacks.AfterModelCallback>> afterModelCallback()
    • beforeToolCallback

      public Optional<List<Callbacks.BeforeToolCallback>> beforeToolCallback()
    • afterToolCallback

      public Optional<List<Callbacks.AfterToolCallback>> afterToolCallback()
    • inputSchema

      public Optional<com.google.genai.types.Schema> inputSchema()
    • outputSchema

      public Optional<com.google.genai.types.Schema> outputSchema()
    • executor

      public Optional<Executor> executor()
    • outputKey

      public Optional<String> outputKey()
    • resolvedModel

      public Model resolvedModel()