Type-safe build method for agents with output schemas Provides better type inference for the ask method return type
Set the model for the agent
The model identifier (e.g., "gemini-2.5-flash")
This builder instance for chaining
Add tools to the agent
Rest...tools: BaseTool[]Tools to add to the agent
This builder instance for chaining
Set the planner for the agent
The planner to use
This builder instance for chaining
Set the code executor for the agent
The code executor to use for running code
This builder instance for chaining
Add sub-agents to the agent
Sub-agents to add to the agent
This builder instance for chaining
Set the before agent callback
Callback to invoke before agent execution
This builder instance for chaining
Set the after agent callback
Callback to invoke after agent execution
This builder instance for chaining
Set the before model callback for LLM interaction
Callback to invoke before calling the LLM
This builder instance for chaining
Set the after model callback for LLM interaction
Callback to invoke after receiving LLM response
This builder instance for chaining
Set the before tool callback for tool execution
Callback to invoke before running a tool
This builder instance for chaining
Set the after tool callback for tool execution
Callback to invoke after running a tool
This builder instance for chaining
Add plugins to the agent for lifecycle hooks and behavior extensions
Rest...plugins: BasePlugin[]Plugin instances to add to the agent
This builder instance for chaining
Provide an already constructed agent instance. Further definition-mutating calls (model/tools/instruction/etc.) will be ignored with a dev warning.
Configure as a sequential agent
Sub-agents to execute in sequence
This builder instance for chaining
Configure as a parallel agent
Sub-agents to execute in parallel
This builder instance for chaining
Configure as a loop agent
Sub-agents to execute iteratively
Maximum number of iterations
This builder instance for chaining
Configure as a LangGraph agent
Graph nodes defining the workflow
The starting node name
This builder instance for chaining
Configure session management with optional smart defaults
Session service to use
Session configuration options (userId and appName)
This builder instance for chaining
Configure with an existing session instance
Existing session to use
This builder instance for chaining
Configure memory service for the agent
Memory service to use for conversation history and context
This builder instance for chaining
Configure event compaction for automatic history management
Event compaction configuration
This builder instance for chaining
Configure with an in-memory session with custom IDs Note: In-memory sessions are created automatically by default, use this only if you need custom appName/userId
Session configuration options (userId and appName)
This builder instance for chaining
AgentBuilder with typed output schema