RequestStopEvent
public class RequestStopEvent extends AgentEvent
io/agentscope/core/event/RequestStopEvent.java:42–95请求停止事件,描述执行过程中的事件。位于 io.agentscope.core.event 包,继承自 AgentEvent。核心成员包括 getType、getReason、getGenerateReason、RequestStopEvent。
Requests the agent to pause execution after the current phase completes.
Emit this event from a io.agentscope.core.middleware.MiddlewareBase (e.g. inside
onReasoning or onActing) to stop the agent loop. The agent finishes the
in-flight step, then returns a Msg whose GenerateReason is set to
generateReason (defaults to GenerateReason#MIDDLEWARE_STOP_REQUESTED).
The pending state is persisted via io.agentscope.core.message.ToolCallState in
AgentState.context, so callers can resume by issuing a second agent.call(...)
— pending tool calls will be picked up automatically and execution continues.
Typical use cases:
-
Cost / budget guards (stop when token usage exceeds a threshold)
-
Audit / compliance checkpoints (manual review before destructive actions)
-
Debug stepping (pause every iteration)
-
Content moderation gates
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public RequestStopEvent(String id, String createdAt, String reason, GenerateReason generateReason) | 初始化 `RequestStopEvent` 实例。 Creates a new instance. |
public RequestStopEvent(String reason) | 创建停止请求使用默认`GenerateReason#MIDDLEWARE_STOP_REQUESTED`。 Create a stop request with the default `GenerateReason#MIDDLEWARE_STOP_REQUESTED`. |
public RequestStopEvent(String reason, GenerateReason generateReason) | 初始化 `RequestStopEvent` 实例。 Create a stop request with an explicit generate reason. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public AgentEventType getType() | 获取类型。 Returns the type. |
public String getReason() | 获取推理。 Human-readable description of why the stop was requested. |
public GenerateReason getGenerateReason() | 获取 `getGenerateReason`。 The `GenerateReason` to assign to the returned Msg. |
构造器详情Constructor Detail
RequestStopEvent
public RequestStopEvent(String id, String createdAt, String reason, GenerateReason generateReason)
初始化 RequestStopEvent 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
id | String | 标识(类型 `String`)。The id. |
createdAt | String | 已创建 At(类型 `String`)。The created at. |
reason | String | 原因(类型 `String`)。The reason. |
generateReason | GenerateReason | generate 推理(类型 `GenerateReason`)。The generate reason. |
io/agentscope/core/event/RequestStopEvent.java:47–57RequestStopEvent
public RequestStopEvent(String reason)
创建停止请求使用默认GenerateReason#MIDDLEWARE_STOP_REQUESTED。
Create a stop request with the default GenerateReason#MIDDLEWARE_STOP_REQUESTED.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
reason | String | 原因(类型 `String`)。human-readable description of why the stop was requested |
io/agentscope/core/event/RequestStopEvent.java:64–66RequestStopEvent
public RequestStopEvent(String reason, GenerateReason generateReason)
初始化 RequestStopEvent 实例。
Create a stop request with an explicit generate reason.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
reason | String | 原因(类型 `String`)。human-readable description |
generateReason | GenerateReason | generate 推理(类型 `GenerateReason`)。the reason to set on the returned Msg |
io/agentscope/core/event/RequestStopEvent.java:75–79方法详情Method Detail
getType
public AgentEventType getType()
获取类型。
Returns the type.
AgentEventTypeio/agentscope/core/event/RequestStopEvent.java:81–84getReason
public String getReason()
获取推理。
Human-readable description of why the stop was requested.
Stringio/agentscope/core/event/RequestStopEvent.java:87–89getGenerateReason
public GenerateReason getGenerateReason()
获取 getGenerateReason。
The GenerateReason to assign to the returned Msg.
GenerateReasonio/agentscope/core/event/RequestStopEvent.java:92–94