Agent
public interface Agent extends CallableAgent, StreamableAgent, ObservableAgent
io/agentscope/core/agent/Agent.java:47–114定义智能体契约的接口。位于 io.agentscope.core.agent 包,实现 CallableAgent、StreamableAgent、ObservableAgent。核心成员包括 getAgentId、getName、getDescription、interrupt、getAgentState、getToolkit。
Complete agent interface combining all capabilities.
This interface defines the core contract for agents, combining:
-
CallableAgent- Process messages and generate responses -
StreamableAgent- Stream events during execution -
ObservableAgent- Observe messages without responding
Design Philosophy:
-
Memory management is NOT part of the core Agent interface - it's the responsibility of specific agent implementations (e.g., ReActAgent)
-
Structured output is a specialized capability provided by specific agents
-
Observe pattern allows agents to receive messages without generating a reply, enabling multi-agent collaboration
All agents in the AgentScope framework should implement this interface.
Reply contract: a single call(...) invocation produces exactly one
terminal Msg. Streaming variants (see StreamableAgent) may emit
many events but resolve to a single terminal Msg. This is enforced by the
Mono<Msg> return type on the call methods.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public String getAgentId() | 获取智能体标识。 Get the unique identifier for this agent. |
public String getName() | 获取名称的此智能体。 Get the name of this agent. |
default public String getDescription()default | 获取 `getDescription`。 Get the description of this agent. |
public void interrupt() | 请求中断当前执行。 Interrupt the current agent execution. |
public void interrupt(Msg msg) | 请求中断当前执行。 Interrupt the current agent execution with a user message. |
default public io.agentscope.core.state.AgentState getAgentState()default | 获取智能体状态。 Returns the agent's runtime `io.agentscope.core.state.AgentState`, or `null` if
this agent type does not maintain one. |
default public Toolkit getToolkit()default | 获取工具包。 Returns the agent's live `Toolkit`, or `null` if this agent type does not
maintain one. |
方法详情Method Detail
getAgentId
public String getAgentId()
获取智能体标识。
Get the unique identifier for this agent.
Stringio/agentscope/core/agent/Agent.java:54getName
public String getName()
获取名称的此智能体。
Get the name of this agent.
Stringio/agentscope/core/agent/Agent.java:61getDescription
default public String getDescription()
获取 getDescription。
Get the description of this agent.
Stringio/agentscope/core/agent/Agent.java:68–70interrupt
public void interrupt()
请求中断当前执行。
Interrupt the current agent execution.
io/agentscope/core/agent/Agent.java:78interrupt
public void interrupt(Msg msg)
请求中断当前执行。
Interrupt the current agent execution with a user message.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
msg | Msg | 消息(类型 `Msg`)。User message associated with the interruption |
io/agentscope/core/agent/Agent.java:87getAgentState
default public io.agentscope.core.state.AgentState getAgentState()
获取智能体状态。
Returns the agent's runtime io.agentscope.core.state.AgentState, or null if this agent type does not maintain one.
io.agentscope.core.state.AgentStateio/agentscope/core/agent/Agent.java:97–99getToolkit
default public Toolkit getToolkit()
获取工具包。
Returns the agent's live Toolkit, or null if this agent type does not maintain one.
Toolkitio/agentscope/core/agent/Agent.java:111–113