类class
agentscope.sopSOPStep
class SOPStep(SOPStepBase)
源码Source
agentscope/sop/_schema.py:193–412SOP 步骤,把复杂任务拆分为可执行步骤并驱动流程。位于 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 |
|---|---|---|
subject | str | 主题(类型 `str`)。A brief, actionable name. |
description | str | 描述(类型 `str`)。What this step must achieve. |
executor | AgentLike | 执行器(类型 `AgentLike`)。Does the work. Reuse one across steps and they share its context; give each its own and they do not. |
verifier默认default None | AgentLike | None | 校验器(类型 `AgentLike | None`)。Judges it. `None` accepts whatever comes back, which is right for a step that only has to happen. |
max_attempts默认default 3 | int | 最大尝试次数(类型 `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 |
|---|---|---|
inputs | Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None | 输入消息(类型 `Msg | list[Msg] | UserConfirmResultEvent | UserInterruptEvent | ExternalExecutionResultEvent | None`)。The inputs. |
state | SOPStepRunState | 状态对象(类型 `SOPStepRunState`)。The state. |
AsyncGenerator[AgentEvent | Msg, None]
以异步流的形式返回AgentEvent|消息,None。Returns a stream of agent event msg none.
源码Source
agentscope/sop/_schema.py:229–329