接口 Agent
- 所有超级接口:
CallableAgent,ObservableAgent,StreamableAgent
- 所有已知实现类:
AgentBase,ReActAgent,UserAgent
This interface defines the core contract for agents, combining:
CallableAgent- Process messages and generate responsesStreamableAgent- Stream events during executionObservableAgent- 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.
-
方法概要
修饰符和类型方法说明Get the unique identifier for this agent.default AgentStateReturns the agent's runtimeAgentState, ornullif this agent type does not maintain one.default StringGet the description of this agent.getName()Get the name of this agent.default ToolkitReturns the agent's liveToolkit, ornullif this agent type does not maintain one.voidInterrupt the current agent execution.voidInterrupt the current agent execution with a user message.从接口继承的方法 io.agentscope.core.agent.CallableAgent
call, call, call, call, call, call, call, call, call, call, call, call, call从接口继承的方法 io.agentscope.core.agent.ObservableAgent
observe, observe
-
方法详细资料
-
getAgentId
String getAgentId()Get the unique identifier for this agent.- 返回:
- Agent ID
-
getName
String getName()Get the name of this agent.- 返回:
- Agent name
-
getDescription
Get the description of this agent.- 返回:
- Agent description
-
interrupt
void interrupt()Interrupt the current agent execution. This method sets an interrupt flag that will be checked by the agent at appropriate checkpoints during execution. The interruption is cooperative and may not take effect immediately. -
interrupt
Interrupt the current agent execution with a user message. This method sets an interrupt flag and associates a user message with the interruption. The interruption is cooperative and may not take effect immediately.- 参数:
msg- User message associated with the interruption
-
getAgentState
Returns the agent's runtimeAgentState, ornullif this agent type does not maintain one.This is the canonical access point used by tool methods declared with
@Tool(stateInjected=true): the framework binds the live state to theAgentStateparameter at invocation time. -
getToolkit
Returns the agent's liveToolkit, ornullif this agent type does not maintain one.This is the runtime toolkit — the same instance the agent uses when listing available tools for the model and dispatching tool calls. Middleware that needs to register tools dynamically (e.g., skill loaders) must use this accessor rather than any toolkit reference captured at build time, because agents may deep-copy the toolkit during construction.
-