AS AgentScopeAPI 手册 / API Reference

Event

@Deprecated(since = "2.0.0") @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public class Event
源码Source io/agentscope/core/agent/Event.java:57–219

事件,描述执行过程中的事件。位于 io.agentscope.core.agent 包。核心成员包括 withSource、getType、getMessage、isLast、getSource、getMessageId。

An event emitted during streaming agent execution.

Events provide a structured way to observe agent execution, with clear type identification and completion status for each message.

Example usage:

`agent.stream(userMsg, options)
.subscribe(event -> {
switch (event.getType()) {
case REASONING -> {
if (event.isLast()) {
System.out.println("✓ Reasoning complete");
} else {
System.out.print("..."); // Progress indicator
}
}
case TOOL_RESULT -> {
System.out.println("Tool: " + event.getMessage().getTextContent());
}
}
});
`

构造器摘要Constructor Summary

构造器Constructor说明Description
public Event(EventType type, Msg message, boolean isLast)
初始化 `Event` 实例。
Creates a new event (top-level agent — no source).
public Event(EventType type, Msg message, boolean isLast, EventSource source)
创建新的事件使用可选来源。
Creates a new event with optional source.

方法摘要Method Summary

方法Method说明Description
public Event withSource(EventSource source)
执行使用来源相关操作。
Returns a copy of this event with the given source attached.
public EventType getType()
获取事件类型。
Get the event type.
public Msg getMessage()
获取消息内容。
Get the message content.
public boolean isLast()
判断是否最后。
Check if this is the last/complete message for this event.
public EventSource getSource()
获取来源。
Returns the originating subagent descriptor, or `null` if this event was emitted by the top-level agent.
public String getMessageId()
获取消息标识。
Get the message ID (delegates to `Msg#getId()`).
public String toString()
返回 `toString` 结果。
Returns the to string.

构造器详情Constructor Detail

Event

public Event(EventType type, Msg message, boolean isLast)

初始化 Event 实例。

Creates a new event (top-level agent — no source).

参数Parameters
名称Name类型Type说明Description
typeEventType类型(类型 `EventType`)。The event type (REASONING, TOOL_RESULT, etc.)
messageMsg消息内容。The message content
isLastboolean是最后(类型 `boolean`)。Whether this is the last/complete message for this event
源码Source io/agentscope/core/agent/Event.java:80–82

Event

public Event(EventType type, Msg message, boolean isLast, EventSource source)

创建新的事件使用可选来源。

Creates a new event with optional source.

参数Parameters
名称Name类型Type说明Description
typeEventType事件类型。The event type
messageMsg消息内容。The message content
isLastboolean是最后(类型 `boolean`)。Whether this is the last/complete message
sourceEventSource来源(类型 `EventSource`)。The originating subagent, or `null` for the top-level agent
源码Source io/agentscope/core/agent/Event.java:92–102

方法详情Method Detail

withSource

public Event withSource(EventSource source)

执行使用来源相关操作。

Returns a copy of this event with the given source attached.

参数Parameters
名称Name类型Type说明Description
sourceEventSource来源(类型 `EventSource`)。the originating subagent descriptor
返回Returns Event
返回事件。new Event with `source` set
源码Source io/agentscope/core/agent/Event.java:111–113

getType

public EventType getType()

获取事件类型。

Get the event type.

返回Returns EventType
事件类型。The event type
源码Source io/agentscope/core/agent/Event.java:122–124

getMessage

public Msg getMessage()

获取消息内容。

Get the message content.

返回Returns Msg
消息。The message
源码Source io/agentscope/core/agent/Event.java:134–136

isLast

public boolean isLast()

判断是否最后。

Check if this is the last/complete message for this event.

返回Returns boolean
返回布尔值,表示判断结果。true if this is the last chunk, false if more chunks will follow
源码Source io/agentscope/core/agent/Event.java:178–181

getSource

public EventSource getSource()

获取来源。

Returns the originating subagent descriptor, or null if this event was emitted by the top-level agent.

返回Returns EventSource
返回EventSource。the event source, or `null` for the top-level agent
源码Source io/agentscope/core/agent/Event.java:192–194

getMessageId

public String getMessageId()

获取消息标识。

Get the message ID (delegates to Msg#getId()).

返回Returns String
消息标识。The message ID
源码Source io/agentscope/core/agent/Event.java:204–206

toString

public String toString()

返回 toString 结果。

Returns the to string.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/agent/Event.java:208–218
基于官方固定版本源码静态生成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.