Class Builder
- Direct Known Subclasses:
DefaultBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.ai.chat.client.advisor.observation.AdvisorObservationConventionprotected org.springframework.ai.chat.client.ChatClientprotected org.springframework.ai.chat.prompt.ChatOptionsprotected CompileConfigprotected org.springframework.ai.chat.client.observation.ChatClientObservationConventionprotected Stringprotected booleanprotected Executorprotected booleanprotected Stringprotected Typeprotected Stringprotected List<Interceptor>protected intprotected org.springframework.ai.chat.model.ChatModelprotected List<ModelInterceptor>protected Stringprotected io.micrometer.observation.ObservationRegistryprotected Stringprotected KeyStrategyprotected Stringprotected Class<?>protected booleanprotected booleanprotected org.springframework.ai.tool.resolution.ToolCallbackResolverprotected booleanprotected BaseCheckpointSaverprotected StateSerializerprotected Stringprotected org.springframework.ai.template.TemplateRendererprotected List<org.springframework.ai.tool.ToolCallbackProvider>protected org.springframework.ai.tool.execution.ToolExecutionExceptionProcessorprotected Durationprotected List<ToolInterceptor>protected List<org.springframework.ai.tool.ToolCallback>protected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadvisorObservationConvention(org.springframework.ai.chat.client.advisor.observation.AdvisorObservationConvention advisorObservationConvention) abstract ReactAgentbuild()protected CompileConfigchatClient(org.springframework.ai.chat.client.ChatClient chatClient) Deprecated.chatOptions(org.springframework.ai.chat.prompt.ChatOptions chatOptions) compileConfig(CompileConfig compileConfig) customObservationConvention(org.springframework.ai.chat.client.observation.ChatClientObservationConvention customObservationConvention) description(String description) enableLogging(boolean enableLogging) Sets the executor for parallel nodes.includeContents(boolean includeContents) inputSchema(String inputSchema) instruction(String instruction) interceptors(Interceptor... interceptors) interceptors(List<? extends Interceptor> interceptors) maxParallelTools(int max) Sets the maximum number of tools that can execute in parallel.methodTools(Object... toolObjects) model(org.springframework.ai.chat.model.ChatModel model) observationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry) outputKeyStrategy(KeyStrategy outputKeyStrategy) outputSchema(String outputSchema) outputType(Class<?> outputType) parallelToolExecution(boolean parallel) Enables or disables parallel tool execution.releaseThread(boolean releaseThread) resolver(org.springframework.ai.tool.resolution.ToolCallbackResolver resolver) returnReasoningContents(boolean returnReasoningContents) saver(BaseCheckpointSaver saver) stateSerializer(StateSerializer stateSerializer) Sets the state serializer for the agent.stateSerializer(SpringAIStateSerializer stateSerializer) Deprecated.systemPrompt(String systemPrompt) templateRenderer(org.springframework.ai.template.TemplateRenderer templateRenderer) toolCallbackProviders(org.springframework.ai.tool.ToolCallbackProvider... toolCallbackProviders) toolContext(Map<String, Object> toolContext) toolExecutionExceptionProcessor(org.springframework.ai.tool.execution.ToolExecutionExceptionProcessor toolExecutionExceptionProcessor) toolExecutionTimeout(Duration timeout) Sets the timeout for individual tool executions.tools(org.springframework.ai.tool.ToolCallback... tools) wrapSyncToolsAsAsync(boolean wrap) Enables or disables automatic wrapping of synchronous tools as async.
-
Field Details
-
name
-
description
-
instruction
-
systemPrompt
-
templateRenderer
protected org.springframework.ai.template.TemplateRenderer templateRenderer -
model
protected org.springframework.ai.chat.model.ChatModel model -
chatOptions
protected org.springframework.ai.chat.prompt.ChatOptions chatOptions -
chatClient
protected org.springframework.ai.chat.client.ChatClient chatClient -
tools
-
toolCallbackProviders
-
toolNames
-
resolver
protected org.springframework.ai.tool.resolution.ToolCallbackResolver resolver -
toolExecutionExceptionProcessor
protected org.springframework.ai.tool.execution.ToolExecutionExceptionProcessor toolExecutionExceptionProcessor -
toolContext
-
releaseThread
protected boolean releaseThread -
saver
-
compileConfig
-
hooks
-
interceptors
-
modelInterceptors
-
toolInterceptors
-
includeContents
protected boolean includeContents -
returnReasoningContents
protected boolean returnReasoningContents -
outputKey
-
outputKeyStrategy
-
inputSchema
-
inputType
-
outputSchema
-
outputType
-
observationRegistry
protected io.micrometer.observation.ObservationRegistry observationRegistry -
customObservationConvention
protected org.springframework.ai.chat.client.observation.ChatClientObservationConvention customObservationConvention -
advisorObservationConvention
protected org.springframework.ai.chat.client.advisor.observation.AdvisorObservationConvention advisorObservationConvention -
enableLogging
protected boolean enableLogging -
stateSerializer
-
executor
-
parallelToolExecution
protected boolean parallelToolExecution -
maxParallelTools
protected int maxParallelTools -
toolExecutionTimeout
-
wrapSyncToolsAsAsync
protected boolean wrapSyncToolsAsAsync
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
name
-
chatClient
Deprecated. -
model
-
chatOptions
-
tools
-
tools
-
methodTools
-
toolCallbackProviders
public Builder toolCallbackProviders(org.springframework.ai.tool.ToolCallbackProvider... toolCallbackProviders) -
toolNames
-
resolver
-
toolExecutionExceptionProcessor
public Builder toolExecutionExceptionProcessor(org.springframework.ai.tool.execution.ToolExecutionExceptionProcessor toolExecutionExceptionProcessor) -
toolContext
-
releaseThread
-
saver
-
compileConfig
-
description
-
instruction
-
systemPrompt
-
templateRenderer
-
outputKey
-
outputKeyStrategy
-
inputSchema
-
inputType
-
outputSchema
-
outputType
-
includeContents
-
returnReasoningContents
-
hooks
-
hooks
-
interceptors
-
interceptors
-
observationRegistry
public Builder observationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry) -
customObservationConvention
public Builder customObservationConvention(org.springframework.ai.chat.client.observation.ChatClientObservationConvention customObservationConvention) -
advisorObservationConvention
public Builder advisorObservationConvention(org.springframework.ai.chat.client.advisor.observation.AdvisorObservationConvention advisorObservationConvention) -
enableLogging
-
stateSerializer
Sets the state serializer for the agent.- Parameters:
stateSerializer- the state serializer to use- Returns:
- this builder instance
-
stateSerializer
Deprecated.UsestateSerializer(StateSerializer)insteadSets the state serializer for the agent.- Parameters:
stateSerializer- the SpringAI state serializer to use- Returns:
- this builder instance
-
executor
Sets the executor for parallel nodes.This executor will be used for all parallel nodes in the agent's execution graph. When a parallel node is executed, it will use this executor to run the parallel branches concurrently.
- Parameters:
executor- theExecutorto use for parallel nodes- Returns:
- this builder instance
-
parallelToolExecution
Enables or disables parallel tool execution.When enabled, multiple tool calls in a single response will be executed concurrently rather than sequentially. This can significantly improve performance when tools are I/O-bound or have long execution times.
- Parameters:
parallel- true to enable parallel execution, false for sequential- Returns:
- this builder instance
-
maxParallelTools
Sets the maximum number of tools that can execute in parallel.This limit helps prevent resource exhaustion when many tools are called simultaneously. The default is 5.
- Parameters:
max- the maximum number of parallel tool executions (must be at least 1)- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if max is less than 1
-
toolExecutionTimeout
Sets the timeout for individual tool executions.If a tool execution exceeds this timeout, it will be cancelled and an error will be returned. The default is 5 minutes.
- Parameters:
timeout- the maximum duration for a single tool execution- Returns:
- this builder instance
- Throws:
NullPointerException- if timeout is null
-
wrapSyncToolsAsAsync
Enables or disables automatic wrapping of synchronous tools as async.When enabled, tools that implement only
ToolCallback(synchronous) will be automatically wrapped in anAsyncToolCallbackAdapterto enable async execution. This allows parallel execution without requiring tool implementations to be modified.- Parameters:
wrap- true to wrap sync tools as async, false to leave them as-is- Returns:
- this builder instance
-
buildConfig
-
build
-
stateSerializer(StateSerializer)instead