openclaw - ✅(Solved) Fix Bug: subagent spawns drop task instructions when systemPromptOverride is set [1 pull requests, 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#73624Fetched 2026-04-29 06:17:17
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
cross-referenced ×3referenced ×2commented ×1subscribed ×1

Root Cause

…but the actual ## Your Role block containing the delegated task is missing from the compiled system prompt. This causes subagents to search context/memory and behave confused because they were never given the real delegated task.

Fix Action

Fix / Workaround

Local patch that fixed it

This local patch fixed the behavior while preserving the agent-level override:

Local file patched

PR fix notes

PR #73637: fix(agents): preserve extraSystemPrompt under systemPromptOverride (#73624)

Description (problem / solution / changelog)

What

Fixes #73624. Subagent spawns under agents configured with an agent-level systemPromptOverride silently drop the per-run extraSystemPrompt (the ## Your Role block built by buildSubagentSystemPrompt). The spawned child then gets the bootstrap user message ("Begin. Your assigned task is in the system prompt under Your Role; execute it to completion.") with no ## Your Role to read, and behaves confused — searching context/memory for a task that was never delivered.

Root cause

subagent-spawn.ts:1073 plumbs the subagent role/task block through the extraSystemPrompt parameter. Three call sites then assemble the final system prompt with the same shape:

const builtSystemPrompt =
  resolveSystemPromptOverride({ config, agentId }) ??
  buildEmbeddedSystemPrompt({ ..., extraSystemPrompt, ... });

When the override is non-null, buildEmbeddedSystemPrompt is short-circuited and extraSystemPrompt is discarded.

The reporter (@jarviskar) localized the regression to dist/selection-D9uTvvsw.js line 433 of buildLogger-era bundling, which corresponds to this ?? chain at three production call sites:

  • src/agents/pi-embedded-runner/run/attempt.ts — embedded-runner per-attempt system prompt
  • src/agents/pi-embedded-runner/compact.ts — compaction-driven retry system prompt
  • src/agents/cli-runner/prepare.ts — CLI agent-harness system prompt

Fix

Add a small combineSystemPromptOverrideWithExtra({ override, extraSystemPrompt }) helper next to resolveSystemPromptOverride and use it at all three call sites:

combineSystemPromptOverrideWithExtra({
  override: resolveSystemPromptOverride({ config, agentId }),
  extraSystemPrompt: params.extraSystemPrompt,
}) ??
buildEmbeddedSystemPrompt({ ..., extraSystemPrompt, ... });

Behavior:

  • No override → returns undefined, falls back to existing buildEmbeddedSystemPrompt / buildSystemPrompt (no behavior change for agents without an override).
  • Override + no extra → returns the trimmed override unchanged (matches today's behavior for non-subagent runs).
  • Override + extra → returns "<override>\n\n<extra>" so the spawned subagent's compiled system prompt contains both the agent persona and the ## Your Role block.

Pre-implement audit

  1. Existing-helper check (vincentkoc #57341). grep finds resolveSystemPromptOverride co-located in system-prompt-override.ts. The new combineSystemPromptOverrideWithExtra ships next to it as the natural extension, not in a new helper module. ✅
  2. Shared-helper caller check (steipete #60623). All three call sites already compose resolveSystemPromptOverride against buildEmbeddedSystemPrompt / buildSystemPrompt and already accept extraSystemPrompt in their builder params, so the contract change is consistent across them. The existing builders' extraSystemPrompt handling is unchanged — only the override branch now folds it in. ✅
  3. Broader-fix rival scan (steipete #68270). Zero rival PRs reference #73624. ✅

Test changes

Three new cases in src/agents/system-prompt-override.test.ts:

  • returns undefined when no override is present so callers fall back — pins the no-override path so the existing fallback to buildEmbeddedSystemPrompt keeps working.
  • returns the override alone when extraSystemPrompt is missing or blank — covers non-subagent runs (no behavior change).
  • appends the trimmed extraSystemPrompt with a blank line separator — pins the regression case from #73624 so ## Your Role is preserved when the override is set.

Verified locally

npx oxlint src/agents/system-prompt-override.ts src/agents/system-prompt-override.test.ts \
  src/agents/pi-embedded-runner/run/attempt.ts src/agents/pi-embedded-runner/compact.ts \
  src/agents/cli-runner/prepare.ts
# Found 0 warnings and 0 errors.

npx vitest run src/agents/system-prompt-override.test.ts \
  src/agents/cli-runner/prepare.test.ts \
  src/agents/pi-embedded-runner/run/attempt.prompt-helpers.test.ts
# Tests  34 passed (34)

lobster-biscuit: 73624-subagent-extra-system-prompt-fold

Sign-Off:

  • I have read and agree to the OpenClaw Contributor License Agreement.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/cli-runner/prepare.ts (modified, +13/-4)
  • src/agents/pi-embedded-runner/compact.ts (modified, +13/-4)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +15/-4)
  • src/agents/system-prompt-override.test.ts (modified, +67/-1)
  • src/agents/system-prompt-override.ts (modified, +55/-0)

Code Example

resolveSystemPromptOverride(...) ?? buildEmbeddedSystemPrompt(...)

---

const systemPromptOverride = resolveSystemPromptOverride(...);
const builtAppendPrompt = systemPromptOverride
  ? [systemPromptOverride, params.extraSystemPrompt?.trim()].filter(Boolean).join("\n\n")
  : buildEmbeddedSystemPrompt(...);

---

/opt/homebrew/lib/node_modules/openclaw/dist/selection-D9uTvvsw.js

---

/Users/jarviskar/.openclaw/backups/selection-D9uTvvsw.js.bak-subagent-extra-system-20260428

---

node --check /opt/homebrew/lib/node_modules/openclaw/dist/selection-D9uTvvsw.js
node --check /Users/jarviskar/.openclaw/plugin-runtime-deps/openclaw-2026.4.26-da6bdffc3d96/dist/selection-D9uTvvsw.js
RAW_BUFFERClick to expand / collapse

Bug

Subagent spawns for agents with an agent-level systemPromptOverride drop task-specific subagent instructions from params.extraSystemPrompt.

Impact

Affected agents include Billy, Farber, Scout, and likely any future agent configured with systemPromptOverride.

The subagent receives only the bootstrap user message:

Begin. Your assigned task is in the system prompt under Your Role; execute it to completion.

…but the actual ## Your Role block containing the delegated task is missing from the compiled system prompt. This causes subagents to search context/memory and behave confused because they were never given the real delegated task.

Suspected cause

The runner appears to choose the system prompt with logic equivalent to:

resolveSystemPromptOverride(...) ?? buildEmbeddedSystemPrompt(...)

When resolveSystemPromptOverride(...) returns a prompt, buildEmbeddedSystemPrompt(...) is skipped entirely, so params.extraSystemPrompt is not appended.

Expected behavior

Agent-level systemPromptOverride should be preserved, but task-specific params.extraSystemPrompt should still be appended for subagent runs.

Local patch that fixed it

This local patch fixed the behavior while preserving the agent-level override:

const systemPromptOverride = resolveSystemPromptOverride(...);
const builtAppendPrompt = systemPromptOverride
  ? [systemPromptOverride, params.extraSystemPrompt?.trim()].filter(Boolean).join("\n\n")
  : buildEmbeddedSystemPrompt(...);

Local file patched

/opt/homebrew/lib/node_modules/openclaw/dist/selection-D9uTvvsw.js

Backup created locally:

/Users/jarviskar/.openclaw/backups/selection-D9uTvvsw.js.bak-subagent-extra-system-20260428

Verification

After patching locally, syntax checks passed:

node --check /opt/homebrew/lib/node_modules/openclaw/dist/selection-D9uTvvsw.js
node --check /Users/jarviskar/.openclaw/plugin-runtime-deps/openclaw-2026.4.26-da6bdffc3d96/dist/selection-D9uTvvsw.js

Notes

This was observed after reviewing subagent chat logs where the compiled system prompt started with the generic agent role prompt and did not contain ## Your Role or the delegated task. Agents without systemPromptOverride should not be affected by this specific branch.

extent analysis

TL;DR

Apply a patch to modify the system prompt resolution logic to append params.extraSystemPrompt when systemPromptOverride is present.

Guidance

  • Verify that the issue is indeed caused by the systemPromptOverride logic by checking subagent chat logs for missing ## Your Role blocks.
  • Apply the provided local patch to the selection-D9uTvvsw.js file to fix the behavior.
  • Run syntax checks using node --check to ensure the patched file is valid.
  • Test subagent runs to confirm that task-specific instructions are now correctly included in the compiled system prompt.

Example

The local patch provided in the issue can be used as a starting point:

const systemPromptOverride = resolveSystemPromptOverride(...);
const builtAppendPrompt = systemPromptOverride
  ? [systemPromptOverride, params.extraSystemPrompt?.trim()].filter(Boolean).join("\n\n")
  : buildEmbeddedSystemPrompt(...);

Notes

This fix assumes that the resolveSystemPromptOverride and buildEmbeddedSystemPrompt functions are correctly implemented and only modifies the logic for appending params.extraSystemPrompt.

Recommendation

Apply the workaround by patching the selection-D9uTvvsw.js file with the provided local patch, as it correctly preserves the agent-level override while appending task-specific instructions for subagent runs.

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

Agent-level systemPromptOverride should be preserved, but task-specific params.extraSystemPrompt should still be appended for subagent runs.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING