AgentEvent
@JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = AgentStartEvent.class, name = "AGENT_START"), @JsonSubTypes.Type(value = AgentEndEvent.class, name = "AGENT_END"), @JsonSubTypes.Type(value = AgentResultEvent.class, name = "AGENT_RESULT"), @JsonSubTypes.Type(value = ModelCallStartEvent.class, name = "MODEL_CALL_START"), @JsonSubTypes.Type(value = ModelCallEndEvent.class, name = "MODEL_CALL_END"), @JsonSubTypes.Type(value = TextBlockStartEvent.class, name = "TEXT_BLOCK_START"), @JsonSubTypes.Type(value = TextBlockDeltaEvent.class, name = "TEXT_BLOCK_DELTA"), @JsonSubTypes.Type(value = TextBlockEndEvent.class, name = "TEXT_BLOCK_END"), @JsonSubTypes.Type(value = ThinkingBlockStartEvent.class, name = "THINKING_BLOCK_START"), @JsonSubTypes.Type(value = ThinkingBlockDeltaEvent.class, name = "THINKING_BLOCK_DELTA"), @JsonSubTypes.Type(value = ThinkingBlockEndEvent.class, name = "THINKING_BLOCK_END"), @JsonSubTypes.Type(value = DataBlockStartEvent.class, name = "DATA_BLOCK_START"), @JsonSubTypes.Type(value = DataBlockDeltaEvent.class, name = "DATA_BLOCK_DELTA"), @JsonSubTypes.Type(value = DataBlockEndEvent.class, name = "DATA_BLOCK_END"), @JsonSubTypes.Type(value = ToolCallStartEvent.class, name = "TOOL_CALL_START"), @JsonSubTypes.Type(value = ToolCallDeltaEvent.class, name = "TOOL_CALL_DELTA"), @JsonSubTypes.Type(value = ToolCallEndEvent.class, name = "TOOL_CALL_END"), @JsonSubTypes.Type(value = ToolResultStartEvent.class, name = "TOOL_RESULT_START"), @JsonSubTypes.Type(value = ToolResultTextDeltaEvent.class, name = "TOOL_RESULT_TEXT_DELTA"), @JsonSubTypes.Type(value = ToolResultDataDeltaEvent.class, name = "TOOL_RESULT_DATA_DELTA"), @JsonSubTypes.Type(value = ToolResultEndEvent.class, name = "TOOL_RESULT_END"), @JsonSubTypes.Type(value = ExceedMaxItersEvent.class, name = "EXCEED_MAX_ITERS"), @JsonSubTypes.Type(value = RequireUserConfirmEvent.class, name = "REQUIRE_USER_CONFIRM"), @JsonSubTypes.Type( value = RequireExternalExecutionEvent.class, name = "REQUIRE_EXTERNAL_EXECUTION"), @JsonSubTypes.Type(value = UserConfirmResultEvent.class, name = "USER_CONFIRM_RESULT"), @JsonSubTypes.Type( value = ExternalExecutionResultEvent.class, name = "EXTERNAL_EXECUTION_RESULT"), @JsonSubTypes.Type(value = RequestStopEvent.class, name = "REQUEST_STOP"), @JsonSubTypes.Type(value = SubagentExposedEvent.class, name = "SUBAGENT_EXPOSED"), @JsonSubTypes.Type(value = HintBlockEvent.class, name = "HINT_BLOCK"), @JsonSubTypes.Type(value = AllToolsDeniedEvent.class, name = "ALL_TOOLS_DENIED"), @JsonSubTypes.Type(value = CustomEvent.class, name = "CUSTOM") }) public abstract class AgentEvent
io/agentscope/core/event/AgentEvent.java:33–183智能体事件,描述执行过程中的事件。位于 io.agentscope.core.event 包。核心成员包括 getType、getId、getCreatedAt、getSource、withSource、getMetadata。
Base class for all fine-grained agent events.
Each event carries a unique ID, creation timestamp, and type discriminator. Events are emitted during agent execution and can be consumed via reactive streams.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
METADATA_TASK_IDstaticfinal | String | 元数据任务标识字段。 Well-known `#metadata` key correlating a forwarded subagent event to a harness
`TaskRecord` / remote Agent Protocol task id. |
METADATA_PARENT_SESSION_IDstaticfinal | String | 元数据父级会话标识字段。 Well-known `#metadata` key identifying the parent agent's session that initiated a
remote subagent run. |
METADATA_GENERATE_REASONstaticfinal | String | 元数据 GENERATE 推理字段。 Well-known `#metadata` key carrying the `GenerateReason` name behind a text
projection. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
protected AgentEvent() | 初始化 `AgentEvent` 实例。 Creates a new instance. |
protected AgentEvent(String id, String createdAt) | 初始化 `AgentEvent` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public abstract AgentEventType getType()abstract | 获取类型。 Returns the type. |
public String getId() | 获取标识。 Returns the id. |
public String getCreatedAt() | 获取已创建 At。 Returns the created at. |
public String getSource() | 获取来源。 Returns the source path identifying the originating agent. |
public AgentEvent withSource(String source) | 执行使用来源相关操作。 Sets the source path and returns this event. |
public Map<String, Object> getMetadata() | 获取元数据。 Returns optional metadata attached to this event. |
public AgentEvent withMetadata(Map<String, Object> metadata) | 执行使用元数据相关操作。 Attaches arbitrary key-value metadata to this event and returns it for chaining. |
public AgentEvent withMetadataEntry(String key, Object value) | 执行使用元数据条目相关操作。 Merges a single metadata entry into this event (creates the map if absent) and returns it
for chaining. |
public String toString() | 返回 `toString` 结果。 Returns the to string. |
字段详情Field Detail
METADATA_TASK_ID
public static final String METADATA_TASK_ID
元数据任务标识字段。声明为 public static final String METADATA_TASK_ID。
Well-known #metadata key correlating a forwarded subagent event to a harness TaskRecord / remote Agent Protocol task id.
io/agentscope/core/event/AgentEvent.java:80METADATA_PARENT_SESSION_ID
public static final String METADATA_PARENT_SESSION_ID
元数据父级会话标识字段。声明为 public static final String METADATA_PARENT_SESSION_ID。
Well-known #metadata key identifying the parent agent's session that initiated a remote subagent run.
io/agentscope/core/event/AgentEvent.java:87METADATA_GENERATE_REASON
public static final String METADATA_GENERATE_REASON
元数据 GENERATE 推理字段。声明为 public static final String METADATA_GENERATE_REASON。
Well-known #metadata key carrying the GenerateReason name behind a text projection.
io/agentscope/core/event/AgentEvent.java:96构造器详情Constructor Detail
AgentEvent
protected AgentEvent()
初始化 AgentEvent 实例。
Creates a new instance.
io/agentscope/core/event/AgentEvent.java:105–108AgentEvent
protected AgentEvent(String id, String createdAt)
初始化 AgentEvent 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。The id. |
createdAt | String | 已创建 At(类型 `String`)。The created at. |
io/agentscope/core/event/AgentEvent.java:110–113方法详情Method Detail
getType
public abstract AgentEventType getType()
获取类型。
Returns the type.
AgentEventTypeio/agentscope/core/event/AgentEvent.java:115getId
public String getId()
获取标识。
Returns the id.
Stringio/agentscope/core/event/AgentEvent.java:117–119getCreatedAt
public String getCreatedAt()
获取已创建 At。
Returns the created at.
Stringio/agentscope/core/event/AgentEvent.java:121–123getSource
public String getSource()
获取来源。
Returns the source path identifying the originating agent.
Stringio/agentscope/core/event/AgentEvent.java:130–132withSource
public AgentEvent withSource(String source)
执行使用来源相关操作。
Sets the source path and returns this event.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
source | String | 来源(类型 `String`)。The source. |
AgentEventio/agentscope/core/event/AgentEvent.java:138–141getMetadata
public Map<String, Object> getMetadata()
获取元数据。
Returns optional metadata attached to this event.
Map<String, Object>io/agentscope/core/event/AgentEvent.java:146–148withMetadata
public AgentEvent withMetadata(Map<String, Object> metadata)
执行使用元数据相关操作。
Attaches arbitrary key-value metadata to this event and returns it for chaining.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
metadata | Map<String, Object> | 元数据(类型 `Map`)。The metadata. |
AgentEventio/agentscope/core/event/AgentEvent.java:153–156withMetadataEntry
public AgentEvent withMetadataEntry(String key, Object value)
执行使用元数据条目相关操作。
Merges a single metadata entry into this event (creates the map if absent) and returns it for chaining.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
value | Object | 值(类型 `Object`)。The value. |
AgentEventio/agentscope/core/event/AgentEvent.java:162–177toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/agentscope/core/event/AgentEvent.java:179–182