类class
agentscope.app.middlewareSOPStepSubmitMiddleware
class SOPStepSubmitMiddleware(MiddlewareBase)
源码Source
agentscope/app/middleware/_sop_step_middleware.py:15–169SOP 步骤提交中间件,在智能体执行流程中提供横切扩展。位于 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 3 | int | 最大 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_kwargs | dict | 输入关键字参数(类型 `dict`)。The reply arguments, forwarded unchanged. |
next_handler | Callable[..., AsyncGenerator] | 下一个处理器(类型 `Callable[..., AsyncGenerator]`)。The rest of the middleware chain. |
AsyncGenerator
返回AsyncGenerator。`AgentEvent | Msg`:
源码Source
agentscope/app/middleware/_sop_step_middleware.py:84–169