oclaw/openclaw/extensions/open-prose/skills/prose/examples/19-advanced-parallel.prose
oliver dbbe3add6a 重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。

Made-with: Cursor
2026-04-26 08:34:33 +08:00

71 lines
2.3 KiB
Text

# Advanced Parallel Execution (Tier 7)
#
# Demonstrates join strategies and failure policies
# for parallel blocks.
agent researcher:
model: haiku
prompt: "You are a research assistant. Provide concise information."
# 1. Race Pattern: First to Complete Wins
# ----------------------------------------
# Use parallel ("first") when you want the fastest result
# and don't need all branches to complete.
parallel ("first"):
session: researcher
prompt: "Find information via approach A"
session: researcher
prompt: "Find information via approach B"
session: researcher
prompt: "Find information via approach C"
session "Summarize: only the fastest approach completed"
# 2. Any-N Pattern: Get Multiple Quick Results
# --------------------------------------------
# Use parallel ("any", count: N) when you need N results
# but not necessarily all of them.
parallel ("any", count: 2):
a = session "Generate a creative headline for a tech blog"
b = session "Generate a catchy headline for a tech blog"
c = session "Generate an engaging headline for a tech blog"
d = session "Generate a viral headline for a tech blog"
session "Choose the best from the 2 headlines that finished first"
context: { a, b, c, d }
# 3. Continue on Failure: Gather All Results
# ------------------------------------------
# Use on-fail: "continue" when you want all branches
# to complete and handle failures afterwards.
parallel (on-fail: "continue"):
session "Fetch data from primary API"
session "Fetch data from secondary API"
session "Fetch data from backup API"
session "Combine all available data, noting any failures"
# 4. Ignore Failures: Best-Effort Enrichment
# ------------------------------------------
# Use on-fail: "ignore" for optional enrichments
# where failures shouldn't block progress.
parallel (on-fail: "ignore"):
session "Get optional metadata enrichment 1"
session "Get optional metadata enrichment 2"
session "Get optional metadata enrichment 3"
session "Continue with whatever enrichments succeeded"
# 5. Combined: Race with Resilience
# ---------------------------------
# Combine join strategies with failure policies.
parallel ("first", on-fail: "continue"):
session "Fast but might fail"
session "Slow but reliable"
session "Got the first result, even if it was a handled failure"