Package com.alibaba.cloud.ai.graph.agent
Class Agent
java.lang.Object
com.alibaba.cloud.ai.graph.agent.Agent
Abstract base class for all agents in the graph system. Contains common properties and
methods shared by different agent implementations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CompileConfigprotected CompiledGraphprotected StringOne line description about the agent's capability.protected Executorprotected StateGraphprotected StringThe agent's name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidApplies executor configuration to the RunnableConfig builder.buildMessageInput(Object message) protected RunnableConfigbuildNonStreamConfig(RunnableConfig config) protected RunnableConfigbuildStreamConfig(RunnableConfig config) Gets the one-line description of the agent's capability.protected Optional<OverAllState>doInvoke(Map<String, Object> input, RunnableConfig runnableConfig) protected Optional<NodeOutput>doInvokeAndGetOutput(Map<String, Object> input, RunnableConfig runnableConfig) protected reactor.core.publisher.Flux<NodeOutput>doStream(Map<String, Object> input, RunnableConfig runnableConfig) getCurrentState(RunnableConfig config) getGraph()protected abstract StateGraphinvoke(String message, RunnableConfig config) invoke(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) invoke(org.springframework.ai.chat.messages.UserMessage message) invoke(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config) invokeAndGetOutput(String message) invokeAndGetOutput(String message, RunnableConfig config) invokeAndGetOutput(List<org.springframework.ai.chat.messages.Message> messages) invokeAndGetOutput(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) invokeAndGetOutput(org.springframework.ai.chat.messages.UserMessage message) invokeAndGetOutput(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config) name()Gets the agent's unique name.schedule(ScheduleConfig scheduleConfig) Schedule the agent task with trigger.Schedule the agent task with trigger.reactor.core.publisher.Flux<NodeOutput>reactor.core.publisher.Flux<NodeOutput>stream(String message, RunnableConfig config) reactor.core.publisher.Flux<NodeOutput>reactor.core.publisher.Flux<NodeOutput>stream(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) reactor.core.publisher.Flux<NodeOutput>stream(org.springframework.ai.chat.messages.UserMessage message) reactor.core.publisher.Flux<NodeOutput>stream(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config)
-
Field Details
-
name
The agent's name. Must be a unique identifier within the graph. -
description
One line description about the agent's capability. The system can use this for decision-making when delegating control to different agents. -
compileConfig
-
compiledGraph
-
graph
-
executor
-
-
Constructor Details
-
Agent
Protected constructor for initializing all base agent properties.- Parameters:
name- the unique name of the agentdescription- the description of the agent's capability
-
Agent
protected Agent()Default protected constructor for subclasses that need to initialize properties differently.
-
-
Method Details
-
name
Gets the agent's unique name.- Returns:
- the unique name of the agent.
-
description
Gets the one-line description of the agent's capability.- Returns:
- the description of the agent.
-
getGraph
-
getAndCompileGraph
-
schedule
public ScheduledAgentTask schedule(org.springframework.scheduling.Trigger trigger, Map<String, Object> input) throws GraphStateException, GraphRunnerExceptionSchedule the agent task with trigger.- Parameters:
trigger- the schedule configurationinput- the agent input- Returns:
- a ScheduledAgentTask instance for managing the scheduled task
- Throws:
GraphStateExceptionGraphRunnerException
-
schedule
Schedule the agent task with trigger.- Parameters:
scheduleConfig- the schedule configuration- Returns:
- a ScheduledAgentTask instance for managing the scheduled task
- Throws:
GraphStateException
-
getCurrentState
- Throws:
GraphRunnerException
-
invoke
- Throws:
GraphRunnerException
-
invoke
public Optional<OverAllState> invoke(String message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
invoke
public Optional<OverAllState> invoke(org.springframework.ai.chat.messages.UserMessage message) throws GraphRunnerException - Throws:
GraphRunnerException
-
invoke
public Optional<OverAllState> invoke(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
invoke
public Optional<OverAllState> invoke(List<org.springframework.ai.chat.messages.Message> messages) throws GraphRunnerException - Throws:
GraphRunnerException
-
invoke
public Optional<OverAllState> invoke(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
invokeAndGetOutput
- Throws:
GraphRunnerException
-
invokeAndGetOutput
public Optional<NodeOutput> invokeAndGetOutput(String message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
invokeAndGetOutput
public Optional<NodeOutput> invokeAndGetOutput(org.springframework.ai.chat.messages.UserMessage message) throws GraphRunnerException - Throws:
GraphRunnerException
-
invokeAndGetOutput
public Optional<NodeOutput> invokeAndGetOutput(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
invokeAndGetOutput
public Optional<NodeOutput> invokeAndGetOutput(List<org.springframework.ai.chat.messages.Message> messages) throws GraphRunnerException - Throws:
GraphRunnerException
-
invokeAndGetOutput
public Optional<NodeOutput> invokeAndGetOutput(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
stream
- Throws:
GraphRunnerException
-
stream
public reactor.core.publisher.Flux<NodeOutput> stream(String message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
stream
public reactor.core.publisher.Flux<NodeOutput> stream(org.springframework.ai.chat.messages.UserMessage message) throws GraphRunnerException - Throws:
GraphRunnerException
-
stream
public reactor.core.publisher.Flux<NodeOutput> stream(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
stream
public reactor.core.publisher.Flux<NodeOutput> stream(List<org.springframework.ai.chat.messages.Message> messages) throws GraphRunnerException - Throws:
GraphRunnerException
-
stream
public reactor.core.publisher.Flux<NodeOutput> stream(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
doInvoke
-
doInvokeAndGetOutput
protected Optional<NodeOutput> doInvokeAndGetOutput(Map<String, Object> input, RunnableConfig runnableConfig) -
doStream
protected reactor.core.publisher.Flux<NodeOutput> doStream(Map<String, Object> input, RunnableConfig runnableConfig) -
buildNonStreamConfig
-
buildStreamConfig
-
applyExecutorConfig
Applies executor configuration to the RunnableConfig builder. This method sets the default executor for parallel nodes from the agent's configuration.- Parameters:
builder- the RunnableConfig builder to apply executor configuration to
-
buildMessageInput
-
initGraph
- Throws:
GraphStateException
-