AS AgentScopeAPI 手册 / API Reference
类class agentscope.sop

SOPStep

class SOPStep(SOPStepBase)
源码Source agentscope/sop/_schema.py:193–412

SOP 步骤,把复杂任务拆分为可执行步骤并驱动流程。位于 agentscope.sop 包,继承自 SOPStepBase。核心成员包括 reply_stream。

One call is one attempt — work, then judgement. Parking in either half ends the call; the next one picks up where it stopped, told apart by whether anything was handed over yet.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(subject: str, description: str, executor: AgentLike, verifier: AgentLike | None = None, max_attempts: int…
初始化 `SOPStep` 实例。
Initialize the step.

方法摘要Method Summary

方法Method说明Description
async def reply_stream(inputs: Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultE…async
流式回复输入消息,并逐个产出事件或消息。
Make one attempt: do the work, then have it judged.

构造器详情Constructor Detail

SOPStep

def __init__(subject: str, description: str, executor: AgentLike, verifier: AgentLike | None = None, max_attempts: int = 3) -> None

初始化 SOPStep 实例。

Initialize the step.

参数Parameters
名称Name类型Type说明Description
subjectstr主题(类型 `str`)。A brief, actionable name.
descriptionstr描述(类型 `str`)。What this step must achieve.
executorAgentLike执行器(类型 `AgentLike`)。Does the work. Reuse one across steps and they share its context; give each its own and they do not.
verifier默认default NoneAgentLike | None校验器(类型 `AgentLike | None`)。Judges it. `None` accepts whatever comes back, which is right for a step that only has to happen.
max_attempts默认default 3int最大尝试次数(类型 `int`)。How many refusals before the run gives up on it.
源码Source agentscope/sop/_schema.py:201–227

方法详情Method Detail

reply_stream

async def reply_stream(inputs: Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None, state: SOPStepRunState) -> AsyncGenerator[AgentEvent | Msg, None]
async

流式回复输入消息,并逐个产出事件或消息。

Make one attempt: do the work, then have it judged.

参数Parameters
名称Name类型Type说明Description
inputsMsg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None输入消息(类型 `Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None`)。The inputs.
stateSOPStepRunState状态对象(类型 `SOPStepRunState`)。The state.
返回Returns AsyncGenerator[AgentEvent | Msg, None]
以异步流的形式返回AgentEvent|消息,None。Returns a stream of agent event msg none.
源码Source agentscope/sop/_schema.py:229–329

继承成员Inherited Members

继承自Inherited from SOPStepBase
基于官方固定版本源码静态生成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.