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

SOPEngine

class SOPEngine
源码Source agentscope/sop/_engine.py:24–174

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

Feed it, watch the events, and when something needs a person the stream simply ends — nothing stays suspended. Come back with the answer and it picks up from the state.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(sop: SOP, state: SOPRunState | None = None) -> None
初始化 `SOPEngine` 实例。
Initialize the engine.

属性摘要Property Summary

属性Property说明Description
phase
获取阶段。
Where the run stands overall.

方法摘要Method Summary

方法Method说明Description
async def reply_stream(inputs: Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultE…async
流式回复输入消息,并逐个产出事件或消息。
Run the procedure, streaming what happens.

构造器详情Constructor Detail

SOPEngine

def __init__(sop: SOP, state: SOPRunState | None = None) -> None

初始化 SOPEngine 实例。

Initialize the engine.

参数Parameters
名称Name类型Type说明Description
sopSOPSOP(类型 `SOP`)。The procedure to run. Never written to.
state默认default NoneSOPRunState | None状态对象(类型 `SOPRunState | None`)。A stored run to carry on from. Omit to start a new one. Only the SOP's own state is restored: an executor that keeps state of its own — an :class:`~..agent.Agent` does — is restored by whoever built it, before the SOP is handed here.
异常Raises
  • 可能抛出 `Exception`。`ValueError`:
  • 可能抛出 `Exception`。If the state has a different number of steps than the
  • 可能抛出 `Exception`。SOP, which means the procedure was edited since.
源码Source agentscope/sop/_engine.py:32–64

属性详情Property Detail

phase

def phase() -> SOPPhase

获取阶段。

Where the run stands overall.

返回Returns SOPPhase
返回SOPPhase。`SOPPhase`:
源码Source agentscope/sop/_engine.py:67–74

方法详情Method Detail

reply_stream

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

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

Named after :meth:~..agent.Agent.reply_stream so a SOP goes wherever an agent goes.

参数Parameters
名称Name类型Type说明Description
inputs默认default NoneMsg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None输入消息(类型 `Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None`)。What starts the run, or the answer a parked step was waiting for.
返回Returns AsyncGenerator[AgentEvent | Msg, None]
以异步流的形式返回AgentEvent|消息,None。`AgentEvent | Msg`:
源码Source agentscope/sop/_engine.py:76–153
基于官方固定版本源码静态生成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.