Package com.alibaba.cloud.ai.graph.agent
Class ReactAgent
java.lang.Object
com.alibaba.cloud.ai.graph.agent.Agent
com.alibaba.cloud.ai.graph.agent.BaseAgent
com.alibaba.cloud.ai.graph.agent.ReactAgent
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.alibaba.cloud.ai.graph.agent.BaseAgent
includeContents, inputSchema, inputType, outputKey, outputKeyStrategy, outputSchema, outputType, returnReasoningContentsFields inherited from class com.alibaba.cloud.ai.graph.agent.Agent
compileConfig, compiledGraph, description, executor, graph, name -
Constructor Summary
ConstructorsConstructorDescriptionReactAgent(AgentLlmNode llmNode, AgentToolNode toolNode, CompileConfig compileConfig, Builder builder) -
Method Summary
Modifier and TypeMethodDescriptionasNode(boolean includeContents, boolean returnReasoningContents) static Builderbuilder()static Builderbuilder(AgentBuilderFactory agentBuilderFactory) org.springframework.ai.chat.messages.AssistantMessageorg.springframework.ai.chat.messages.AssistantMessagecall(String message, RunnableConfig config) org.springframework.ai.chat.messages.AssistantMessageorg.springframework.ai.chat.messages.AssistantMessagecall(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) org.springframework.ai.chat.messages.AssistantMessagecall(org.springframework.ai.chat.messages.UserMessage message) org.springframework.ai.chat.messages.AssistantMessagecall(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config) getThreadState(String threadId) protected StateGraphvoidinterrupt(RunnableConfig config) voidinterrupt(String userMessage, RunnableConfig config) voidinterrupt(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) voidsetInstruction(String instruction) voidupdateAgentState(Object state, RunnableConfig config) Updates the agent thread state with interruption feedback.Methods inherited from class com.alibaba.cloud.ai.graph.agent.BaseAgent
getOutputKey, getOutputKeyStrategy, isIncludeContents, isReturnReasoningContents, setOutputKey, setOutputKeyStrategy, setReturnReasoningContentsMethods inherited from class com.alibaba.cloud.ai.graph.agent.Agent
applyExecutorConfig, buildMessageInput, buildNonStreamConfig, buildStreamConfig, description, doInvoke, doInvokeAndGetOutput, doStream, getAndCompileGraph, getCurrentState, getGraph, invoke, invoke, invoke, invoke, invoke, invoke, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, invokeAndGetOutput, name, schedule, schedule, stream, stream, stream, stream, stream, stream
-
Constructor Details
-
ReactAgent
public ReactAgent(AgentLlmNode llmNode, AgentToolNode toolNode, CompileConfig compileConfig, Builder builder)
-
-
Method Details
-
builder
-
builder
-
call
public org.springframework.ai.chat.messages.AssistantMessage call(String message) throws GraphRunnerException - Throws:
GraphRunnerException
-
call
public org.springframework.ai.chat.messages.AssistantMessage call(String message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
call
public org.springframework.ai.chat.messages.AssistantMessage call(org.springframework.ai.chat.messages.UserMessage message) throws GraphRunnerException - Throws:
GraphRunnerException
-
call
public org.springframework.ai.chat.messages.AssistantMessage call(org.springframework.ai.chat.messages.UserMessage message, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
call
public org.springframework.ai.chat.messages.AssistantMessage call(List<org.springframework.ai.chat.messages.Message> messages) throws GraphRunnerException - Throws:
GraphRunnerException
-
call
public org.springframework.ai.chat.messages.AssistantMessage call(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) throws GraphRunnerException - Throws:
GraphRunnerException
-
interrupt
-
interrupt
public void interrupt(List<org.springframework.ai.chat.messages.Message> messages, RunnableConfig config) -
interrupt
-
updateAgentState
Updates the agent thread state with interruption feedback. This method is thread-safe and can be called concurrently with apply() in InterruptionHook. Thread-safety guarantees: - threadIdStateMap is a ConcurrentHashMap, ensuring thread-safe access - computeIfAbsent ensures atomic creation of the inner map if it doesn't exist - The inner map is always a ConcurrentHashMap, ensuring thread-safe put() operations Concurrency behavior: - If called before apply() processes feedback: the new value will be processed - If called after apply() removes feedback: the new value will be set for next iteration - If called concurrently with apply(): the atomic operations ensure no data loss -
getStateGraph
-
getCompiledGraph
-
asNode
-
initGraph
- Specified by:
initGraphin classAgent- Throws:
GraphStateException
-
instruction
-
setInstruction
-
getThreadState
-