AS AgentScopeAPI 手册 / API Reference
类class agentscope.app.middleware

SOPStepSubmitMiddleware

class SOPStepSubmitMiddleware(MiddlewareBase)
源码Source agentscope/app/middleware/_sop_step_middleware.py:15–169

SOP 步骤提交中间件,在智能体执行流程中提供横切扩展。位于 agentscope.app.middleware 包,继承自 MiddlewareBase。核心成员包括 on_reply。

A reply-end with nothing submitted is swallowed with a nudge, and failed after max_nudges so it costs an attempt instead of hanging.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(max_nudges: int = 3) -> None
初始化 `SOPStepSubmitMiddleware` 实例。
Initialize the middleware.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
TOOLS—
工具字段。
('SubmitHandover', 'SubmitVerdict')

方法摘要Method Summary

方法Method说明Description
async def on_reply(agent: 'Agent', input_kwargs: dict, next_handler: Callable[..., AsyncGenerator]) -> AsyncGeneratorasync
拦截并扩展回复流程。
Discard reply-ends until the submit tool has been called.

构造器详情Constructor Detail

SOPStepSubmitMiddleware

def __init__(max_nudges: int = 3) -> None

初始化 SOPStepSubmitMiddleware 实例。

Initialize the middleware.

参数Parameters
名称Name类型Type说明Description
max_nudges默认default 3int最大 nudges(类型 `int`)。How many times one reply may be sent back before it is failed instead.
源码Source agentscope/app/middleware/_sop_step_middleware.py:25–34

属性详情Attribute Detail

TOOLS

 = ('SubmitHandover', 'SubmitVerdict')

工具字段。

The TOOLS field.

源码Source agentscope/app/middleware/_sop_step_middleware.py:23

方法详情Method Detail

on_reply

async def on_reply(agent: 'Agent', input_kwargs: dict, next_handler: Callable[..., AsyncGenerator]) -> AsyncGenerator
async

拦截并扩展回复流程。

Discard reply-ends until the submit tool has been called.

参数Parameters
名称Name类型Type说明Description
agent'Agent'智能体(类型 `'Agent'`)。The replying agent.
input_kwargsdict输入关键字参数(类型 `dict`)。The reply arguments, forwarded unchanged.
next_handlerCallable[..., AsyncGenerator]下一个处理器(类型 `Callable[..., AsyncGenerator]`)。The rest of the middleware chain.
返回Returns AsyncGenerator
返回AsyncGenerator。`AgentEvent | Msg`:
源码Source agentscope/app/middleware/_sop_step_middleware.py:84–169

继承成员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.