openclaw - 💡(How to fix) Fix Bug: subagent initial visible message hides delegated task [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#73656Fetched 2026-04-29 06:16:51
View on GitHub
Comments
1
Participants
2
Timeline
1
Reactions
0
Timeline (top)
commented ×1

Subagent sessions currently begin with a visible user message that does not include the delegated task:

[Subagent Context] You are running as a subagent (depth 1/1). Results auto-announce to your requester; do not busy-poll for status.

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

That is confusing in channel UIs and makes it look like the subagent was started without instructions. It is also brittle: if prompt composition drops or misplaces the hidden task block, the subagent has no visible fallback and can start doing generic discovery instead of the assigned task.

This is related to, but distinct from, #73624. #73624 is the functional bug where systemPromptOverride can drop extraSystemPrompt. This issue is about making the initial visible subagent message self-diagnosing and robust by including the delegated task text.

Root Cause

  • Makes subagent starts auditable from the visible transcript
  • Reduces confusion when a channel UI only exposes user/assistant messages
  • Provides a fallback against prompt-composition regressions like #73624
  • Helps users and maintainers distinguish "task hidden but present" from "task actually missing"

Fix Action

Fix / Workaround

  • OpenClaw 2026.4.26
  • macOS
  • Native subagent spawn, observed through Discord/WebUI channel transcript
  • Gateway rebooted after local patches for #73624; new Maverick subagent still showed the visible bootstrap-only message

Local Patch Shape That Worked

The local mitigation was to pass task into buildSubagentInitialUserMessage(...) and include it visibly:

Code Example

[Subagent Context] You are running as a subagent (depth 1/1). Results auto-announce to your requester; do not busy-poll for status.

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

---

[Subagent Context] You are running as a subagent (depth 1/1). Results auto-announce to your requester; do not busy-poll for status.

[Subagent Task]
<delegated task text>

Begin. Execute the assigned task to completion.

---

function buildSubagentInitialUserMessage(params) {
  const lines = [
    `[Subagent Context] You are running as a subagent (depth ${params.childDepth}/${params.maxSpawnDepth}). Results auto-announce to your requester; do not busy-poll for status.`
  ];

  if (params.persistentSession) {
    lines.push("[Subagent Context] This subagent session is persistent and remains available for thread follow-up messages.");
  }

  const task = typeof params.task === "string" ? params.task.trim() : "";
  if (task) {
    lines.push(`[Subagent Task]\n${task}`);
  }

  lines.push("Begin. Execute the assigned task to completion.");
  return lines.join("\n\n");
}

---

const childTaskMessage = buildSubagentInitialUserMessage({
  task,
  childDepth,
  maxSpawnDepth,
  persistentSession: spawnMode === "session"
});
RAW_BUFFERClick to expand / collapse

Summary

Subagent sessions currently begin with a visible user message that does not include the delegated task:

[Subagent Context] You are running as a subagent (depth 1/1). Results auto-announce to your requester; do not busy-poll for status.

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

That is confusing in channel UIs and makes it look like the subagent was started without instructions. It is also brittle: if prompt composition drops or misplaces the hidden task block, the subagent has no visible fallback and can start doing generic discovery instead of the assigned task.

This is related to, but distinct from, #73624. #73624 is the functional bug where systemPromptOverride can drop extraSystemPrompt. This issue is about making the initial visible subagent message self-diagnosing and robust by including the delegated task text.

Environment

  • OpenClaw 2026.4.26
  • macOS
  • Native subagent spawn, observed through Discord/WebUI channel transcript
  • Gateway rebooted after local patches for #73624; new Maverick subagent still showed the visible bootstrap-only message

Observed Behavior

A subagent chat visibly starts with only the bootstrap text and tells the model that the assigned task is hidden in the system prompt under Your Role.

In the inspected run, the compiled context did contain the delegated task under Your Role, and the agent behaved on-task. So this instance was not a task-loss failure. However, from the requester/channel perspective, the transcript still looked like the subagent received no actual assignment.

This makes postmortems and user confidence much worse, especially because #73624 showed there are real cases where the hidden task can be dropped.

Expected Behavior

The first visible subagent message should include the delegated task as a visible fail-safe, for example:

[Subagent Context] You are running as a subagent (depth 1/1). Results auto-announce to your requester; do not busy-poll for status.

[Subagent Task]
<delegated task text>

Begin. Execute the assigned task to completion.

The canonical task/context can still be carried in the system prompt, but the visible first message should make the task obvious in channel UIs and provide a fallback if system-prompt composition changes or fails.

Affected Code Path

Likely source file:

  • src/agents/subagent-initial-user-message.ts

Relevant behavior in current generated dist:

  • buildSubagentInitialUserMessage(...) builds the visible bootstrap message
  • spawnSubagent(...) already has access to task when constructing the child task message
  • The visible message currently omits the task and points to hidden Your Role

Local Patch Shape That Worked

The local mitigation was to pass task into buildSubagentInitialUserMessage(...) and include it visibly:

function buildSubagentInitialUserMessage(params) {
  const lines = [
    `[Subagent Context] You are running as a subagent (depth ${params.childDepth}/${params.maxSpawnDepth}). Results auto-announce to your requester; do not busy-poll for status.`
  ];

  if (params.persistentSession) {
    lines.push("[Subagent Context] This subagent session is persistent and remains available for thread follow-up messages.");
  }

  const task = typeof params.task === "string" ? params.task.trim() : "";
  if (task) {
    lines.push(`[Subagent Task]\n${task}`);
  }

  lines.push("Begin. Execute the assigned task to completion.");
  return lines.join("\n\n");
}

And at the call site:

const childTaskMessage = buildSubagentInitialUserMessage({
  task,
  childDepth,
  maxSpawnDepth,
  persistentSession: spawnMode === "session"
});

Why This Matters

  • Makes subagent starts auditable from the visible transcript
  • Reduces confusion when a channel UI only exposes user/assistant messages
  • Provides a fallback against prompt-composition regressions like #73624
  • Helps users and maintainers distinguish "task hidden but present" from "task actually missing"

Suggested Fix

Include the delegated task in the initial visible subagent user message, while keeping the generated ## Your Role block in the system prompt as the canonical instruction source.

Add a regression test that asserts a spawned subagent's first visible user message includes the delegated task text, or at least that a channel transcript contains enough assignment text to diagnose the run without inspecting hidden compiled context.

extent analysis

TL;DR

Modify the buildSubagentInitialUserMessage function to include the delegated task in the initial visible subagent message.

Guidance

  • Pass the task parameter to buildSubagentInitialUserMessage and include it visibly in the message.
  • Update the spawnSubagent function to pass the task to buildSubagentInitialUserMessage.
  • Add a regression test to assert that the first visible user message includes the delegated task text.
  • Consider adding a fallback mechanism to handle cases where the system prompt composition fails or changes.

Example

function buildSubagentInitialUserMessage(params) {
  // ...
  const task = typeof params.task === "string" ? params.task.trim() : "";
  if (task) {
    lines.push(`[Subagent Task]\n${task}`);
  }
  // ...
}

Notes

The suggested fix assumes that the task parameter is available when constructing the child task message. If this is not the case, additional modifications may be necessary.

Recommendation

Apply the workaround by modifying the buildSubagentInitialUserMessage function to include the delegated task in the initial visible subagent message, as this provides a clear and robust solution to 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