AS AgentScopeAPI 手册 / API Reference

Agent

public interface Agent extends CallableAgent, StreamableAgent, ObservableAgent
源码Source 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.

返回Returns String
返回字符串结果。Agent ID
源码Source io/agentscope/core/agent/Agent.java:54

getName

public String getName()

获取名称的此智能体。

Get the name of this agent.

返回Returns String
返回字符串结果。Agent name
源码Source io/agentscope/core/agent/Agent.java:61

getDescription

default public String getDescription()
default

获取 getDescription。

Get the description of this agent.

返回Returns String
返回字符串结果。Agent description
源码Source io/agentscope/core/agent/Agent.java:68–70

interrupt

public void interrupt()

请求中断当前执行。

Interrupt the current agent execution.

源码Source io/agentscope/core/agent/Agent.java:78

interrupt

public void interrupt(Msg msg)

请求中断当前执行。

Interrupt the current agent execution with a user message.

参数Parameters
名称Name类型Type说明Description
msgMsg消息(类型 `Msg`)。User message associated with the interruption
源码Source io/agentscope/core/agent/Agent.java:87

getAgentState

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.

返回Returns io.agentscope.core.state.AgentState
返回io.agentscope.核心.状态.AgentState。Returns io agentscope core state agent state.
源码Source io/agentscope/core/agent/Agent.java:97–99

getToolkit

default public Toolkit getToolkit()
default

获取工具包。

Returns the agent's live Toolkit, or null if this agent type does not maintain one.

返回Returns Toolkit
返回工具包。Returns toolkit.
源码Source io/agentscope/core/agent/Agent.java:111–113

继承成员Inherited Members

继承自Methods inherited from CallableAgent
继承自Methods inherited from ObservableAgent
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.