openclaw - 💡(How to fix) Fix sessions_spawn fails: Context engine "legacy" is not registered. Available engines: (none) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75798Fetched 2026-05-02 05:29:56
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
2
Timeline (top)
closed ×1commented ×1cross-referenced ×1

Every sessions_spawn (runtime=subagent, mode=run) call fails with:

Context engine subagent preparation failed: Context engine "legacy" is not registered. Available engines: (none)

Reproducible across 2026.4.23 → 2026.4.29 (npm openclaw@latest), surviving multiple gateway restarts and a fresh openclaw models auth login --provider anthropic --method cli --set-default. No third-party context-engine plugin is installed; this is the bare core path failing to register the built-in legacy engine on the spawn code path.

Error Message

"status": "error", "error": "Context engine subagent preparation failed: Context engine "legacy" is not registered. Available engines: (none)",

Root Cause

Every sessions_spawn (runtime=subagent, mode=run) call fails with:

Context engine subagent preparation failed: Context engine "legacy" is not registered. Available engines: (none)

Reproducible across 2026.4.23 → 2026.4.29 (npm openclaw@latest), surviving multiple gateway restarts and a fresh openclaw models auth login --provider anthropic --method cli --set-default. No third-party context-engine plugin is installed; this is the bare core path failing to register the built-in legacy engine on the spawn code path.

Fix Action

Fix / Workaround

  • Stale state: restarted gateway multiple times. No change.
  • Auth profile drift: ~/.openclaw/agents/main/agent/auth-profiles.json rebuilt; openclaw doctor reports profile OK.
  • 2026.4.27 alias-bridge fix (registerContextEngine root export, fixes #53497): upgrade to 2026.4.29 did not change the symptom.
  • Plugin engine registration race: no plugin registers a context engine here; the failure is on the core legacy registration path.

Workaround for affected users

Code Example

Context engine subagent preparation failed: Context engine "legacy" is not registered. Available engines: (none)

---

# From a Discord/Telegram/etc. agent, or any client that can call sessions_spawn:
mcp__openclaw__sessions_spawn({
  task: "echo ok",
  runtime: "subagent",
  mode: "run",
  lightContext: true,
  runTimeoutSeconds: 60
})

---

{
  "status": "error",
  "error": "Context engine subagent preparation failed: Context engine \"legacy\" is not registered. Available engines: (none)",
  "childSessionKey": "agent:main:subagent:<uuid>"
}
RAW_BUFFERClick to expand / collapse

Summary

Every sessions_spawn (runtime=subagent, mode=run) call fails with:

Context engine subagent preparation failed: Context engine "legacy" is not registered. Available engines: (none)

Reproducible across 2026.4.23 → 2026.4.29 (npm openclaw@latest), surviving multiple gateway restarts and a fresh openclaw models auth login --provider anthropic --method cli --set-default. No third-party context-engine plugin is installed; this is the bare core path failing to register the built-in legacy engine on the spawn code path.

Reproduction

# From a Discord/Telegram/etc. agent, or any client that can call sessions_spawn:
mcp__openclaw__sessions_spawn({
  task: "echo ok",
  runtime: "subagent",
  mode: "run",
  lightContext: true,
  runTimeoutSeconds: 60
})

Returns:

{
  "status": "error",
  "error": "Context engine subagent preparation failed: Context engine \"legacy\" is not registered. Available engines: (none)",
  "childSessionKey": "agent:main:subagent:<uuid>"
}

Environment

  • OpenClaw 2026.4.29 (a448042) — also reproduced on 2026.4.23 (a979721)
  • Linux 6.17.0-23-generic, Node 22.22.2
  • Service: systemd-managed openclaw-gateway (port 18790)
  • agents.list has one agent (main, claude-cli/claude-opus-4-6)
  • Default model resolves: claude-cli/claude-opus-4-7 (auth-profile OK after openclaw doctor)
  • acpx runtime registered cleanly at boot (embedded acpx runtime backend registered)
  • 71/117 stock plugins enabled; no plugin registers a context engine (legacy is core-owned)

What I ruled out

  • Stale state: restarted gateway multiple times. No change.
  • Auth profile drift: ~/.openclaw/agents/main/agent/auth-profiles.json rebuilt; openclaw doctor reports profile OK.
  • 2026.4.27 alias-bridge fix (registerContextEngine root export, fixes #53497): upgrade to 2026.4.29 did not change the symptom.
  • Plugin engine registration race: no plugin registers a context engine here; the failure is on the core legacy registration path.

What I traced in the dist (2026.4.29)

  • subagent-spawn-*.js: prepareContextEngineSubagentSpawn calls subagentSpawnDeps.resolveContextEngine(params.cfg) — wired to the bare resolveContextEngine from registry-*.js, NOT through resolveSubagentRegistryContextEngine (the wrapper that calls ensureContextEnginesInitialized() first).
  • subagent-registry-*.js does have a path (resolveSubagentRegistryContextEngine) that calls ensureContextEnginesInitialized() before resolving — but the spawn-prep code doesn't use that path.
  • pi-embedded-*.js calls ensureContextEnginesInitialized() at lines ~79 and ~1569 — but our agent runs through the ACPX runtime backend (embedded acpx runtime backend registered), not pi-embedded. So the init is not fired on this agent's boot path.

Net: on a non-pi agent, ensureContextEnginesInitialized() is never called before the first subagent spawn, so the registry is empty, and the bare resolveContextEngine correctly throws.

Suggested fix

Option A (smallest): in subagent-spawn-*.ts prepareContextEngineSubagentSpawn, call ensureContextEnginesInitialized() (or use resolveSubagentRegistryContextEngine) before the bare resolve.

Option B: ensure the gateway/agent boot path calls ensureContextEnginesInitialized() for every runtime backend, not just pi-embedded.

Happy to PR if helpful — let me know which path you'd prefer.

Workaround for affected users

We've been doing all subagent-style work directly from the parent session for now. No real blocker for our use case, just a missed parallelization opportunity.

extent analysis

TL;DR

The most likely fix is to call ensureContextEnginesInitialized() before resolving the context engine in the subagent-spawn-*.ts file.

Guidance

  • The issue is caused by the ensureContextEnginesInitialized() function not being called before the first subagent spawn, resulting in an empty registry and a failure to resolve the legacy context engine.
  • To verify the fix, check that the ensureContextEnginesInitialized() function is called before the resolveContextEngine function in the subagent-spawn-*.ts file.
  • Consider implementing Option A, which involves calling ensureContextEnginesInitialized() in the prepareContextEngineSubagentSpawn function, as it is the smallest change required to fix the issue.
  • Alternatively, Option B could be implemented to ensure the gateway/agent boot path calls ensureContextEnginesInitialized() for every runtime backend.

Example

// In subagent-spawn-*.ts
prepareContextEngineSubagentSpawn(params) {
  ensureContextEnginesInitialized(); // Add this line
  subagentSpawnDeps.resolveContextEngine(params.cfg);
}

Notes

The provided fix options assume that the ensureContextEnginesInitialized() function is correctly implemented and will initialize the context engines as expected.

Recommendation

Apply workaround Option A, as it is the smallest change required to fix the issue and can be easily implemented. This will ensure that the ensureContextEnginesInitialized() function is called before resolving the context engine, fixing the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix sessions_spawn fails: Context engine "legacy" is not registered. Available engines: (none) [1 comments, 2 participants]