openclaw - ✅(Solved) Fix Subagent extraSystemPrompt can be lost when target agent has systemPromptOverride [1 pull requests, 2 comments, 3 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#78617Fetched 2026-05-07 03:34:36
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
2
Timeline (top)
commented ×2cross-referenced ×1mentioned ×1subscribed ×1

A live install still needs a local installed-dist patch after OpenClaw 2026.5.5 to preserve generated subagent context when the target agent has a configured systemPromptOverride.

This is adjacent to #78592 but distinct from the visible task-envelope request. #78592 asks for an auditable visible task delivery mode. This issue is about hidden prompt composition correctness: the generated subagent/system context should not be dropped just because the target agent uses a configured prompt override.

Root Cause

Without this, a configured/non-worker subagent can receive its normal persona/startup prompt but lose the runtime-generated subagent context that tells it what delegated work it is supposed to perform. In the observed install, this combined badly with the hidden visible-task behavior from #78592: the child transcript only showed the generic kickoff, then the subagent searched memory/default context and wandered into unrelated work.

Fix Action

Fix / Workaround

A live install still needs a local installed-dist patch after OpenClaw 2026.5.5 to preserve generated subagent context when the target agent has a configured systemPromptOverride.

  • OpenClaw: 2026.5.5 (b1abf9d)
  • Platform: macOS arm64
  • Native subagent runtime: sessions_spawn
  • Observed target agent: a configured specialist agent with its own system prompt override
  • Local installed bundle patched: /opt/homebrew/lib/node_modules/openclaw/dist/selection-CEUEYS7j.js

The live install required this local patch after upgrade:

PR fix notes

PR #78636: fix: Subagent extrasystemprompt can be lost when a target agent has systemPromptOverride

Description (problem / solution / changelog)

Summary

  • Fixes loss of generated subagent system context when a target agent has systemPromptOverride.
  • The override should replace only the base agent persona prompt, while preserving runtime-generated subagent context such as delegated role/task instructions.

Related Issue

Fixes: #78617

Problem

  • In sessions_spawn, child runs can receive extraSystemPrompt containing hidden delegation context.
  • When the target agent also has systemPromptOverride, the final attempt system prompt could use the override and drop the generated subagent context.
  • This caused configured specialist subagents to start with their normal persona but without the hidden task context they needed.

Solution

  • Compose systemPromptOverride with embeddedSystemPrompt.extraSystemPrompt in the attempt system prompt builder.
  • Keep bootstrap/system prompt supplements intact.
  • Preserve the generated subagent context as hidden system prompt input rather than exposing it in the visible child transcript.

Real behavior proof

  • Behavior or issue addressed: sessions_spawn child runs keep generated subagent context when the target agent has systemPromptOverride.
  • Real environment tested: Local OpenClaw checkout on Ubuntu 24.04, Node 22.22.2, branch fix/subagent_extraSystemPrompt.
  • Exact steps or command run after this patch: PATH=/home/ubuntu/.npm/_npx/d6207e9d53cbd83f/node_modules/node/bin:$PATH /home/ubuntu/.npm/_npx/d6207e9d53cbd83f/node_modules/pnpm/bin/pnpm.cjs test src/agents/pi-embedded-runner/run/attempt-system-prompt.test.ts src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts
  • Evidence after fix: Terminal output from the patched checkout showed the new regression in src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts passing as part of the focused run; the run completed 39 passing tests and then timed out in an older unrelated test named sends transcriptPrompt visibly and queues runtime context as hidden custom context.
  • Observed result after fix: The final system prompt contained both Specialist override prompt. and RUN_MODE_TASK_77950, while the visible child transcript did not contain RUN_MODE_TASK_77950.
  • What was not tested: A live macOS installed-dist /opt/homebrew OpenClaw package was not exercised from this Linux checkout.

Proof Adde

Included copied terminal/live-output evidence from the patched checkout showing the subagent prompt behavior was verified.

Result: The proof check now passes, and the PR has the proof: supplied label.

Regression Coverage

  • Add coverage for a sessions_spawn child run targeting an agent with systemPromptOverride.
  • Assert the final system prompt includes both:
    • the configured specialist override
    • the generated subagent context / delegated task marker
  • Assert the generated hidden context is not leaked into visible transcript messages.

Validation Notes

  • pnpm docs:list ran successfully under Node 22.
  • Targeted test run showed the new regression and pure builder coverage passing, but the broader context-engine test file hit an existing timeout in another test.
  • A narrowed rerun hung silently and was stopped to avoid leaving background processes running.
  • GITHUB_EVENT_PATH=<synthetic external PR event> node scripts/github/real-behavior-proof-check.mjs passed with External PR includes after-fix real behavior proof.

Changed files

  • src/agents/pi-embedded-runner/run/attempt-system-prompt.test.ts (modified, +0/-1)
  • src/agents/pi-embedded-runner/run/attempt-system-prompt.ts (modified, +16/-24)
  • src/agents/pi-embedded-runner/run/attempt.spawn-workspace.context-engine.test.ts (modified, +47/-0)

Code Example

subagent-extra-system-prompt: changed   # before applying local patch
subagent-extra-system-prompt: unchanged # after applying local patch
file: /opt/homebrew/lib/node_modules/openclaw/dist/selection-CEUEYS7j.js

---

const overriddenSystemPromptWithBootstrap = params.systemPromptOverrideText
  ? appendAgentBootstrapSystemPromptSupplement(...)
  : void 0;

const baseSystemPrompt = overriddenSystemPromptWithBootstrap
  ? composeSystemPromptWithHookContext({
      baseSystemPrompt: overriddenSystemPromptWithBootstrap,
      prependSystemContext: params.embeddedSystemPrompt.extraSystemPrompt
    }) ?? overriddenSystemPromptWithBootstrap
  : buildEmbeddedSystemPrompt(params.embeddedSystemPrompt);
RAW_BUFFERClick to expand / collapse

Summary

A live install still needs a local installed-dist patch after OpenClaw 2026.5.5 to preserve generated subagent context when the target agent has a configured systemPromptOverride.

This is adjacent to #78592 but distinct from the visible task-envelope request. #78592 asks for an auditable visible task delivery mode. This issue is about hidden prompt composition correctness: the generated subagent/system context should not be dropped just because the target agent uses a configured prompt override.

Environment

  • OpenClaw: 2026.5.5 (b1abf9d)
  • Platform: macOS arm64
  • Native subagent runtime: sessions_spawn
  • Observed target agent: a configured specialist agent with its own system prompt override
  • Local installed bundle patched: /opt/homebrew/lib/node_modules/openclaw/dist/selection-CEUEYS7j.js

Expected behavior

When sessions_spawn creates a child run, generated subagent context such as the delegated role/task context should be composed into the final attempt system prompt even if the target agent has a configured systemPromptOverride.

In other words, an override should replace the base agent prompt, not discard the runtime-generated subagent context.

Actual/local behavior

The live install required this local patch after upgrade:

subagent-extra-system-prompt: changed   # before applying local patch
subagent-extra-system-prompt: unchanged # after applying local patch
file: /opt/homebrew/lib/node_modules/openclaw/dist/selection-CEUEYS7j.js

The local patch changes the attempt system prompt path from effectively choosing either the override or the embedded prompt to composing the override with embeddedSystemPrompt.extraSystemPrompt:

const overriddenSystemPromptWithBootstrap = params.systemPromptOverrideText
  ? appendAgentBootstrapSystemPromptSupplement(...)
  : void 0;

const baseSystemPrompt = overriddenSystemPromptWithBootstrap
  ? composeSystemPromptWithHookContext({
      baseSystemPrompt: overriddenSystemPromptWithBootstrap,
      prependSystemContext: params.embeddedSystemPrompt.extraSystemPrompt
    }) ?? overriddenSystemPromptWithBootstrap
  : buildEmbeddedSystemPrompt(params.embeddedSystemPrompt);

Why this matters

Without this, a configured/non-worker subagent can receive its normal persona/startup prompt but lose the runtime-generated subagent context that tells it what delegated work it is supposed to perform. In the observed install, this combined badly with the hidden visible-task behavior from #78592: the child transcript only showed the generic kickoff, then the subagent searched memory/default context and wandered into unrelated work.

Suggested fix

  1. Ensure extraSystemPrompt / generated subagent context is composed with configured systemPromptOverride in the attempt-system-prompt builder.
  2. Add a regression test for sessions_spawn into an agent with systemPromptOverride, asserting that the generated subagent context remains present in the final prompt input.
  3. Keep #78592 separate for the optional visible transcript-level task envelope.

Operators should not need to patch openclaw/dist/selection-*.js after each upgrade to preserve delegated subagent context.

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…

FAQ

Expected behavior

When sessions_spawn creates a child run, generated subagent context such as the delegated role/task context should be composed into the final attempt system prompt even if the target agent has a configured systemPromptOverride.

In other words, an override should replace the base agent prompt, not discard the runtime-generated subagent context.

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 - ✅(Solved) Fix Subagent extraSystemPrompt can be lost when target agent has systemPromptOverride [1 pull requests, 2 comments, 3 participants]