AS AgentScopeAPI 手册 / API Reference

RequestStopEvent

public class RequestStopEvent extends AgentEvent
源码Source 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.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
createdAtString已创建 At(类型 `String`)。The created at.
reasonString原因(类型 `String`)。The reason.
generateReasonGenerateReasongenerate 推理(类型 `GenerateReason`)。The generate reason.
源码Source io/agentscope/core/event/RequestStopEvent.java:47–57

RequestStopEvent

public RequestStopEvent(String reason)

创建停止请求使用默认GenerateReason#MIDDLEWARE_STOP_REQUESTED。

Create a stop request with the default GenerateReason#MIDDLEWARE_STOP_REQUESTED.

参数Parameters
名称Name类型Type说明Description
reasonString原因(类型 `String`)。human-readable description of why the stop was requested
源码Source io/agentscope/core/event/RequestStopEvent.java:64–66

RequestStopEvent

public RequestStopEvent(String reason, GenerateReason generateReason)

初始化 RequestStopEvent 实例。

Create a stop request with an explicit generate reason.

参数Parameters
名称Name类型Type说明Description
reasonString原因(类型 `String`)。human-readable description
generateReasonGenerateReasongenerate 推理(类型 `GenerateReason`)。the reason to set on the returned Msg
源码Source io/agentscope/core/event/RequestStopEvent.java:75–79

方法详情Method Detail

getType

public AgentEventType getType()

获取类型。

Returns the type.

返回Returns AgentEventType
返回AgentEventType。Returns agent event type.
源码Source io/agentscope/core/event/RequestStopEvent.java:81–84

getReason

public String getReason()

获取推理。

Human-readable description of why the stop was requested.

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

getGenerateReason

public GenerateReason getGenerateReason()

获取 getGenerateReason。

The GenerateReason to assign to the returned Msg.

返回Returns GenerateReason
返回GenerateReason。Returns generate reason.
源码Source io/agentscope/core/event/RequestStopEvent.java:92–94

继承成员Inherited Members

基于官方固定版本源码静态生成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.