chain

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MANDATORY PREPARATION

强制准备

Invoke {{command_prefix}}agent-workflow — it contains workflow principles, anti-patterns, and the Context Gathering Protocol. Follow the protocol before proceeding — if no workflow context exists yet, you MUST run {{command_prefix}}teach-maestro first. Consult the tool-orchestration reference in the agent-workflow skill for composition patterns and error handling.

Design tool chains that do complex work reliably. A chain is only as strong as its weakest link.
调用 {{command_prefix}}agent-workflow —— 它包含了工作流原则、反模式,以及上下文收集协议。在继续操作前请遵循该协议——如果还不存在任何工作流上下文,你必须先运行 {{command_prefix}}teach-maestro。 请参考 agent-workflow 技能中的工具编排参考文档,了解编排模式和错误处理方案。

设计能够可靠完成复杂工作的工具链。工具链的强度取决于其最薄弱的环节。

Chain Patterns

链模式

Sequential: A → B → C (each step depends on the previous) Parallel: [A, B, C] → Merge (independent steps run simultaneously) Conditional: A → (if X then B, else C) → D (branching based on results) Iterative: A → Check → (if not done) → A again (loop until convergence)
串行: A → B → C (每个步骤依赖前一步的结果) 并行: [A, B, C] → 合并 (独立步骤同时运行) 条件分支: A → (如果满足X则执行B,否则执行C) → D (基于结果进行分支) 迭代: A → 检查 → (如果未完成) → 重新执行A (循环直到达到收敛条件)

Chain Design Process

链设计流程

For each chain, define:
markdown
undefined
对于每个工具链,需要定义:
markdown
undefined

Chain: [Name]

Chain: [Name]

Steps

Steps

  1. [Tool A] — [what it does] — Input: [schema] — Output: [schema]
  2. [Tool B] — [what it does] — Input: [output of step 1] — Output: [schema]
  3. [Tool C] — [what it does] — Input: [output of step 2] — Output: [schema]
  1. [Tool A] — [what it does] — Input: [schema] — Output: [schema]
  2. [Tool B] — [what it does] — Input: [output of step 1] — Output: [schema]
  3. [Tool C] — [what it does] — Input: [output of step 2] — Output: [schema]

Data Flow

Data Flow

Step 1 output.field_a → Step 2 input.source_data Step 2 output.results → Step 3 input.items
Step 1 output.field_a → Step 2 input.source_data Step 2 output.results → Step 3 input.items

Error Handling

Error Handling

Step 1 failure → [retry 3x, then return error] Step 2 failure → [return partial results from step 1] Step 3 failure → [retry with simplified input]
Step 1 failure → [retry 3x, then return error] Step 2 failure → [return partial results from step 1] Step 3 failure → [retry with simplified input]

Constraints

Constraints

Max total execution time: 60s Max retries per step: 3
undefined
Max total execution time: 60s Max retries per step: 3
undefined

Chain Validation

链验证

  • Data schemas are compatible between connected steps
  • Every step has error handling
  • Total chain timeout is set
  • Maximum iteration count is set for loops
  • Partial results are handled (what if step 2 of 4 fails?)
  • 关联步骤之间的数据 schema 互相兼容
  • 每个步骤都配置了错误处理逻辑
  • 设置了整个工具链的总超时时间
  • 为循环设置了最大迭代次数
  • 处理了部分结果的场景(如果4个步骤中的第2步失败了怎么办?)

Recommended Next Step

推荐后续步骤

After building the chain, run
{{command_prefix}}fortify
to add error handling at each step, then
{{command_prefix}}evaluate
to test the full pipeline.
NEVER:
  • Build chains without defining data contracts between steps
  • Create loops without maximum iteration counts
  • Skip error handling at any step (the chain breaks at the weakest link)
  • Assume output of step N is always valid input for step N+1
  • Build long chains when a single prompt could handle the task
构建完工具链后,运行
{{command_prefix}}fortify
为每个步骤添加错误处理逻辑,然后运行
{{command_prefix}}evaluate
测试完整流水线。
严禁:
  • 未定义步骤间的数据契约就构建工具链
  • 创建没有最大迭代次数的循环
  • 任意步骤跳过错误处理(工具链会在最薄弱的环节断裂)
  • 假设第N步的输出永远是第N+1步的合法输入
  • 当单个prompt就能完成任务时,反而构建冗长的工具链