Feature Request: Add sessions.spawn gateway method for direct subagent spawning

Resolved 💬 2 comments Opened Feb 6, 2026 by fox-openclaw Closed Feb 6, 2026

Summary

Add a sessions.spawn gateway method that allows spawning subagent sessions directly without requiring an LLM in the loop.

Motivation

Currently, spawning subagents requires using the sessions_spawn tool from within an agent session, which means:

  1. Every spawn operation requires an LLM call (~$0.01+ per spawn)
  2. External automation (systemd timers, cron scripts, CI/CD) cannot spawn subagents directly
  3. Task orchestration systems must go through expensive LLM intermediaries

For autonomous agent systems that need to spawn many workers (e.g., task dispatchers, build systems, test runners), this creates unnecessary cost and latency.

Proposed Solution

Add sessions.spawn as a gateway method that:

  • Accepts the same parameters as the sessions_spawn tool (task, label, model, thinking, timeout, cleanup)
  • Validates permissions (only main/cron sessions can spawn, not subagents)
  • Creates the subagent session and triggers the agent run
  • Returns the childSessionKey and runId

Use Cases

  1. Task Dispatchers: Automated systems that pick tasks from a queue and spawn workers
  2. CI/CD Integration: External build systems triggering agent runs
  3. Scheduled Jobs: Cron-like systems spawning workers without LLM overhead
  4. Cost Optimization: Reducing per-spawn cost from ~$0.01 to ~$0 for high-volume orchestration

Implementation Notes

The implementation would largely mirror the existing sessions_spawn tool logic in src/agents/tools/sessions-spawn-tool.ts, adapted for the gateway context. Key additions:

  • Schema validation in params-schema.ts
  • Add to METHOD_LIST in server-methods-list.ts
  • Handler in src/gateway/server-methods/sessions.ts

I've prototyped this locally and can submit a PR with the implementation.

---
*Submitted on behalf of @DeviousCham

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗