子智能体

sub-agents

by bill492

Spawn and coordinate sub-agent sessions for parallel work. Use when delegating tasks (research, code, analysis), routing to appropriate models, or managing multi-agent workflows. Trigger on "spawn", "sub-agent", "delegate", "parallel tasks", or when a task would benefit from a different model.

3.7kAI 与智能体未扫描2026年3月23日

安装

claude skill add --url github.com/openclaw/skills/tree/main/skills/bill492/sub-agents

文档

Sub-Agent Orchestration

Spawn isolated sessions to execute tasks in parallel with appropriate model routing.

Critical: Sub-Agents Are Context-Blind

Sub-agents do not see AGENTS.md, SKILL.md, SOUL.md, MEMORY.md, or any workspace context files. They only see:

  1. The task string you provide
  2. Whatever files you tell them to read (via paths in the task)
  3. Inline attachments you pass at spawn time

Everything the sub-agent needs must be in the task spec or explicitly referenced as a file path. This includes output instructions, announce behavior, constraints, and domain knowledge.

When to Spawn

Spawn when:

  • Task benefits from a specialized model (code → Codex, research → Sonnet)
  • Work can run in parallel while you continue
  • Task is self-contained with clear success criteria
  • Will block you for >10 seconds (the 10-Second Rule)

Don't spawn when:

  • Trivial one-liner (just do it yourself)
  • Task requires real-time conversation with the user
  • Heavy coordination overhead exceeds benefit

Model Selection

Task TypeModel (alias)Full pathNotes
Browser automationgpt54openai-codex/gpt-5.4Default for all browser tasks. Native computer-use. thinking: high auto-applied.
Code implementationcodexopenai-codex/gpt-5.3-codexOptimized for code gen
Quick code/bugscodexopenai-codex/gpt-5.3-codex-sparkFaster, simpler tasks
Research, writing, quick tasksgpt5openai-codex/gpt-5.2Unlimited on Codex sub. Replaces sonnet/haiku for most work.
Complex reasoningopusanthropic/claude-opus-4-6Deep analysis (expensive)
Huge context (>200K tokens)sonnetanthropic/claude-sonnet-4-51M context window fallback

Use aliases when available. GPT-5.2 is unlimited on the Codex subscription — prefer it over Sonnet/Haiku for sub-agents unless you specifically need Sonnet's 1M context window.

sessions_spawn Parameters

ParameterRequiredDefaultDescription
taskThe full task description (only context the sub-agent gets)
modelparent modelModel alias or full provider/model path
thinkingoff | low | medium | high
labelLabel for logs/UI tracking
runTimeoutSecondsconfig default or 0Abort after N seconds
cleanupkeepdelete | keep — delete removes session after completion
threadfalseThread-bound routing (Discord/Slack)
moderunrun | session — defaults to session when thread=true
sandboxinheritinherit | require — require rejects if child isn't sandboxed
agentIdcurrent agentSpawn under another agent (must be in allowlist)
attachmentsInline files: [{ name, content, encoding?, mimeType? }]

Key behaviors

  • Always non-blocking. Returns { status: "accepted", runId, childSessionKey } immediately.
  • Sub-agents cannot spawn sub-agents. No nested spawning. Plan accordingly.
  • Sub-agents get all tools EXCEPT session tools (no sessions_list/history/send/spawn). Configurable via tools.subagents.tools.
  • Auto-archive: Sessions archive after agents.defaults.subagents.archiveAfterMinutes (default: 60).

Announce Mechanism

After a sub-agent completes, OpenClaw runs an announce step that posts results to the requester's chat channel.

  • Announce replies are normalized to Status / Result / Notes format
  • Status comes from runtime outcome (success/failure/timeout), not model text
  • If the assistant's final reply is empty, the latest toolResult is used as Result
  • Include a stats line (runtime, tokens, sessionKey, cost)

Controlling announce behavior

Sub-agent replies with...Effect
Normal textPosted to requester's channel as the announce
ANNOUNCE_SKIPAnnounce is suppressed — nothing posted
Empty replyLatest toolResult becomes the Result

⚠️ Use ANNOUNCE_SKIP, not NO_REPLY. ANNOUNCE_SKIP is the specific mechanism for sub-agent announce suppression. NO_REPLY is a general silent-reply convention that may not suppress the announce step.

Task Specification — Structured Handoff Protocol

Every spawn should follow this template. Remember: this is the only context the sub-agent receives.

Required Fields

  1. Objective — One sentence. What the sub-agent must accomplish.
  2. Context — Structured facts. File paths, API endpoints, constraints, relevant decisions. Not narrative — a reference sheet.
  3. Inputs — What files/data to read before starting. Be specific: paths, line ranges, sections.
  4. Success criteria — How to verify done. Testable, not subjective.
  5. Output contract — Where and how to deliver results. File path, format, schema.

Optional Fields

  1. Constraints — What NOT to do. Boundaries, things that already failed.
  2. Domain knowledge — Project-specific context files to load (e.g., projects/foo/CONTEXT.md).
  3. Decisions already made — Prevent re-litigating settled questions.

Announce instructions (include in every task)

For silent sub-agents (results consolidated by parent):

code
Write your full analysis to [path].
Your final reply after writing the file should be ONLY: ANNOUNCE_SKIP

For sub-agents that should announce their own results:

code
Write results to [path].
Your final reply should summarize what you found — this will be posted to the chat.

Example (Good)

code
OBJECTIVE: Analyze time-of-day patterns in Kalshi BTC spread bot single-fill losses.

CONTEXT:
- Bot code: projects/kalshi-arb/bot/spread_bot.py
- Trade log: projects/kalshi-arb/data/trades.csv (columns: timestamp, action, side, price, fill_type, pnl)
- Key finding: single-fills have 1.8% win rate vs ~83% for dual-fills
- Volume gate already exists at 150K trailing-1

INPUTS:
- Read trades.csv, filter to fill_type="single"
- Read spread_bot.py lines 180-220 (gating logic)

SUCCESS CRITERIA:
- Statistical breakdown of single-fill losses by hour (ET)
- Identify if specific time windows have >2x the loss rate
- Chi-squared or equivalent significance test

OUTPUT:
- Write analysis to projects/kalshi-arb/time-gating-analysis.md
- Include raw data table + recommendation

CONSTRAINTS:
- Don't modify bot code, analysis only
- Flag if sample size < 30 per bucket

Your final reply after writing the file should be ONLY: ANNOUNCE_SKIP

Example (Bad — Don't Do This)

code
Look at the Kalshi bot trades and figure out if time of day matters
for single fills. The bot is in the projects folder somewhere.
Write up what you find.

The bad example forces the sub-agent to guess file locations, decide its own success criteria, and has no announce instructions.

Monitoring & Management

subagents tool (primary orchestration)

code
subagents(action="list")                              // List active sub-agents
subagents(action="steer", target="<id>", message="...") // Send follow-up instructions
subagents(action="kill", target="<id>")               // Kill a running sub-agent

Session tools (for history/cross-session)

code
sessions_list({ kinds: ["other"], activeMinutes: 60 })  // Sub-agents are kind "other"
sessions_history({ sessionKey: "...", limit: 5 })        // Check output
sessions_send({ sessionKey: "...", message: "..." })     // Send to any session

Discovery

code
agents_list()  // Discover which agentIds are allowed for sessions_spawn

Don't poll in loops. Check on-demand, when prompted, or for debugging.

Fallback Rules

If a model is rate-limited:

  1. Codex/GPT-5.2 limited → Use sonnet for code/research tasks
  2. Sonnet limited → Use gpt5 for research tasks
  3. All limited → Use opus directly (last resort, expensive)

Rate limits typically reset in 30-90 minutes.

Anti-Patterns

Spawning for trivial tasks — Just do simple things yourself ❌ Vague task specs — "Look into X" without success criteria or output contract ❌ Over-parallelization — Too many concurrent spawns = memory pressure ❌ Forgetting announce instructions — Every task must specify ANNOUNCE_SKIP or what to say ❌ Assuming sub-agents have context — They don't see your workspace files ❌ Using kinds: ["isolated"] — The correct kind for sub-agents is "other"Using NO_REPLY for announce suppression — Use ANNOUNCE_SKIPExpecting sub-agents to spawn their own sub-agents — They can't

相关 Skills

Claude接口

by anthropics

Universal
热门

面向接入 Claude API、Anthropic SDK 或 Agent SDK 的开发场景,自动识别项目语言并给出对应示例与默认配置,快速搭建 LLM 应用。

想把Claude能力接进应用或智能体,用claude-api上手快、兼容Anthropic与Agent SDK,集成路径清晰又省心

AI 与智能体
未扫描109.6k

提示工程专家

by alirezarezvani

Universal
热门

覆盖Prompt优化、Few-shot设计、结构化输出、RAG评测与Agent工作流编排,适合分析token成本、评估LLM输出质量,并搭建可落地的AI智能体系统。

把提示优化、LLM评测到RAG与智能体设计串成一套方法,适合想系统提升AI开发效率的人。

AI 与智能体
未扫描9.0k

智能体流程设计

by alirezarezvani

Universal
热门

面向生产级多 Agent 编排,梳理顺序、并行、分层、事件驱动、共识五种工作流设计,覆盖 handoff、状态管理、容错重试、上下文预算与成本优化,适合搭建复杂 AI 协作系统。

帮你把多智能体流程设计、编排和自动化统一起来,复杂工作流也能更稳地落地,适合追求强控制力的团队。

AI 与智能体
未扫描9.0k

相关 MCP 服务

顺序思维

编辑精选

by Anthropic

热门

Sequential Thinking 是让 AI 通过动态思维链解决复杂问题的参考服务器。

这个服务器展示了如何让 Claude 像人类一样逐步推理,适合开发者学习 MCP 的思维链实现。但注意它只是个参考示例,别指望直接用在生产环境里。

AI 与智能体
82.9k

知识图谱记忆

编辑精选

by Anthropic

热门

Memory 是一个基于本地知识图谱的持久化记忆系统,让 AI 记住长期上下文。

帮 AI 和智能体补上“记不住”的短板,用本地知识图谱沉淀长期上下文,连续对话更聪明,数据也更可控。

AI 与智能体
82.9k

PraisonAI

编辑精选

by mervinpraison

热门

PraisonAI 是一个支持自反思和多 LLM 的低代码 AI 智能体框架。

如果你需要快速搭建一个能 24/7 运行的 AI 智能体团队来处理复杂任务(比如自动研究或代码生成),PraisonAI 的低代码设计和多平台集成(如 Telegram)让它上手极快。但作为非官方项目,它的生态成熟度可能不如 LangChain 等主流框架,适合愿意尝鲜的开发者。

AI 与智能体
6.4k

评论