AS AgentScopeAPI 手册 / API Reference

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
源码Source 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_ID
staticfinal
String
元数据任务标识字段。
Well-known `#metadata` key correlating a forwarded subagent event to a harness `TaskRecord` / remote Agent Protocol task id.
METADATA_PARENT_SESSION_ID
staticfinal
String
元数据父级会话标识字段。
Well-known `#metadata` key identifying the parent agent's session that initiated a remote subagent run.
METADATA_GENERATE_REASON
staticfinal
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
staticfinal

元数据任务标识字段。声明为 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.

源码Source io/agentscope/core/event/AgentEvent.java:80

METADATA_PARENT_SESSION_ID

public static final String METADATA_PARENT_SESSION_ID
staticfinal

元数据父级会话标识字段。声明为 public static final String METADATA_PARENT_SESSION_ID。

Well-known #metadata key identifying the parent agent's session that initiated a remote subagent run.

源码Source io/agentscope/core/event/AgentEvent.java:87

METADATA_GENERATE_REASON

public static final String METADATA_GENERATE_REASON
staticfinal

元数据 GENERATE 推理字段。声明为 public static final String METADATA_GENERATE_REASON。

Well-known #metadata key carrying the GenerateReason name behind a text projection.

源码Source io/agentscope/core/event/AgentEvent.java:96

构造器详情Constructor Detail

AgentEvent

protected AgentEvent()

初始化 AgentEvent 实例。

Creates a new instance.

源码Source io/agentscope/core/event/AgentEvent.java:105–108

AgentEvent

protected AgentEvent(String id, String createdAt)

初始化 AgentEvent 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
createdAtString已创建 At(类型 `String`)。The created at.
源码Source io/agentscope/core/event/AgentEvent.java:110–113

方法详情Method Detail

getType

public abstract AgentEventType getType()
abstract

获取类型。

Returns the type.

返回Returns AgentEventType
返回AgentEventType。Returns agent event type.
源码Source io/agentscope/core/event/AgentEvent.java:115

getId

public String getId()

获取标识。

Returns the id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/event/AgentEvent.java:117–119

getCreatedAt

public String getCreatedAt()

获取已创建 At。

Returns the created at.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/event/AgentEvent.java:121–123

getSource

public String getSource()

获取来源。

Returns the source path identifying the originating agent.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/core/event/AgentEvent.java:130–132

withSource

public AgentEvent withSource(String source)

执行使用来源相关操作。

Sets the source path and returns this event.

参数Parameters
名称Name类型Type说明Description
sourceString来源(类型 `String`)。The source.
返回Returns AgentEvent
返回AgentEvent。Returns agent event.
源码Source io/agentscope/core/event/AgentEvent.java:138–141

getMetadata

public Map<String, Object> getMetadata()

获取元数据。

Returns optional metadata attached to this event.

返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/core/event/AgentEvent.java:146–148

withMetadata

public AgentEvent withMetadata(Map<String, Object> metadata)

执行使用元数据相关操作。

Attaches arbitrary key-value metadata to this event and returns it for chaining.

参数Parameters
名称Name类型Type说明Description
metadataMap<String, Object>元数据(类型 `Map`)。The metadata.
返回Returns AgentEvent
返回AgentEvent。Returns agent event.
源码Source io/agentscope/core/event/AgentEvent.java:153–156

withMetadataEntry

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.

参数Parameters
名称Name类型Type说明Description
keyString键(类型 `String`)。The key.
valueObject值(类型 `Object`)。The value.
返回Returns AgentEvent
返回AgentEvent。Returns agent event.
源码Source io/agentscope/core/event/AgentEvent.java:162–177

toString

public String toString()

返回 toString 结果。

Returns the to string.

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