Event
@Deprecated(since = "2.0.0") @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public class Event
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).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
type | EventType | 类型(类型 `EventType`)。The event type (REASONING, TOOL_RESULT, etc.) |
message | Msg | 消息内容。The message content |
isLast | boolean | 是最后(类型 `boolean`)。Whether this is the last/complete message for this event |
io/agentscope/core/agent/Event.java:80–82Event
public Event(EventType type, Msg message, boolean isLast, EventSource source)
创建新的事件使用可选来源。
Creates a new event with optional source.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
type | EventType | 事件类型。The event type |
message | Msg | 消息内容。The message content |
isLast | boolean | 是最后(类型 `boolean`)。Whether this is the last/complete message |
source | EventSource | 来源(类型 `EventSource`)。The originating subagent, or `null` for the top-level agent |
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
source | EventSource | 来源(类型 `EventSource`)。the originating subagent descriptor |
Eventio/agentscope/core/agent/Event.java:111–113getType
public EventType getType()
获取事件类型。
Get the event type.
EventTypeio/agentscope/core/agent/Event.java:122–124getMessage
public Msg getMessage()
获取消息内容。
Get the message content.
Msgio/agentscope/core/agent/Event.java:134–136isLast
public boolean isLast()
判断是否最后。
Check if this is the last/complete message for this event.
booleanio/agentscope/core/agent/Event.java:178–181getSource
public EventSource getSource()
获取来源。
Returns the originating subagent descriptor, or null if this event was emitted by the top-level agent.
EventSourceio/agentscope/core/agent/Event.java:192–194getMessageId
public String getMessageId()
获取消息标识。
Get the message ID (delegates to Msg#getId()).
Stringio/agentscope/core/agent/Event.java:204–206toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/agentscope/core/agent/Event.java:208–218