openclaw - 💡(How to fix) Fix Native sessions_spawn task can be hidden from child transcript; request visible task-envelope option/hook [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#78592Fetched 2026-05-07 03:34:59
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
2
Author
Timeline (top)
commented ×2cross-referenced ×1mentioned ×1subscribed ×1

Native sessions_spawn currently places the full child task in the subagent extra/system prompt and sends a first visible user message that only says:

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

This can fail for configured/non-worker agents that have their own bootstrap/startup/wake behavior: the child transcript may never contain the actual assigned task text or expected task ID, and the agent may proceed with its default startup workflow instead of the spawned task.

Request: add a supported way for callers/operators to make the spawned task visible in the child’s first user-visible message, or provide a plugin/config extension point that can transform the initial child message / task envelope for native sessions_spawn.

Root Cause

For delegation/orchestration, the parent needs a reliable and auditable task-delivery contract. Hidden-only task delivery makes it difficult to validate that:

  • the child actually received the task,
  • the task text survived runtime/bootstrap behavior,
  • the child’s output corresponds to the intended task rather than startup/default context,
  • enforcement tests can reliably classify failures.

Fix Action

Fix / Workaround

The key requirement is that operators should not need to patch bundled dist files to make spawned-task delivery visible and auditable.

Code Example

/**
* First user turn for a native `sessions_spawn` / subagent run.
*
* Keep the full task out of this message: `buildSubagentSystemPrompt` already
* places it under **Your Role**, and repeating it here doubles first-request
* input tokens (#72019).
*/
function buildSubagentInitialUserMessage(params) {
  const lines = [`[Subagent Context] You are running as a subagent ...`];
  if (params.persistentSession) lines.push(...);
  lines.push("Begin. Your assigned task is in the system prompt under **Your Role**; execute it to completion.");
  return lines.join("\n\n");
}

---

params: {
  message: childTaskMessage,
  sessionKey: childSessionKey,
  lane: AGENT_LANE_SUBAGENT,
  extraSystemPrompt: childSystemPrompt,
  timeout: runTimeoutSeconds,
  ...
}
RAW_BUFFERClick to expand / collapse

Summary

Native sessions_spawn currently places the full child task in the subagent extra/system prompt and sends a first visible user message that only says:

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

This can fail for configured/non-worker agents that have their own bootstrap/startup/wake behavior: the child transcript may never contain the actual assigned task text or expected task ID, and the agent may proceed with its default startup workflow instead of the spawned task.

Request: add a supported way for callers/operators to make the spawned task visible in the child’s first user-visible message, or provide a plugin/config extension point that can transform the initial child message / task envelope for native sessions_spawn.

Environment

  • OpenClaw package: openclaw
  • Version observed: 2026.5.2
  • Install path observed: Homebrew global package (/home/linuxbrew/.linuxbrew/lib/node_modules/openclaw)
  • Native subagent runtime: sessions_spawn with runtime="subagent", mode="run"

Relevant implementation observed

In the built package, native subagent spawn is implemented in the bundled subagent-spawn module.

The initial user-visible child message is built by buildSubagentInitialUserMessage(...) and intentionally omits the full task:

/**
* First user turn for a native `sessions_spawn` / subagent run.
*
* Keep the full task out of this message: `buildSubagentSystemPrompt` already
* places it under **Your Role**, and repeating it here doubles first-request
* input tokens (#72019).
*/
function buildSubagentInitialUserMessage(params) {
  const lines = [`[Subagent Context] You are running as a subagent ...`];
  if (params.persistentSession) lines.push(...);
  lines.push("Begin. Your assigned task is in the system prompt under **Your Role**; execute it to completion.");
  return lines.join("\n\n");
}

Later the child run is started with roughly:

params: {
  message: childTaskMessage,
  sessionKey: childSessionKey,
  lane: AGENT_LANE_SUBAGENT,
  extraSystemPrompt: childSystemPrompt,
  timeout: runTimeoutSeconds,
  ...
}

childSystemPrompt contains the actual task, but the transcript-visible first user message does not.

Reproduction shape

  1. Configure one or more agents with normal startup/bootstrap/wake behavior.
  2. Spawn them via native sessions_spawn with a task containing a unique TASK_ID and required output marker.
  3. Inspect child transcripts and final replies.

Expected:

  • The child receives and follows the spawned task.
  • The child transcript contains the unique TASK_ID or task envelope, so parent/harness validation can prove delivery.
  • Startup/wake behavior does not override an explicit spawned task.

Observed:

  • Worker-like agents may complete correctly.
  • Some configured/non-worker agents can instead run/default into startup or unrelated persisted context behavior.
  • Failed child transcripts do not contain the expected TASK_ID or task text; they only contain the generic “assigned task is in the system prompt” visible message and then unrelated/default behavior.
  • This makes it hard to distinguish delivery failure, prompt-prioritization failure, and persisted-context contamination from the parent transcript alone.

Why this matters

For delegation/orchestration, the parent needs a reliable and auditable task-delivery contract. Hidden-only task delivery makes it difficult to validate that:

  • the child actually received the task,
  • the task text survived runtime/bootstrap behavior,
  • the child’s output corresponds to the intended task rather than startup/default context,
  • enforcement tests can reliably classify failures.

Existing hooks/config do not appear to solve this cleanly

I found plugin hooks for prompt mutation (agent_turn_prepare, before_prompt_build) and subagent lifecycle/routing (subagent_spawning, subagent_delivery_target, subagent_spawned, subagent_ended). However, the typed subagent_spawning event appears to include routing/session metadata, not the task text or initial user message, and does not appear to allow transforming the native child initial message.

Prompt mutation hooks can add system/dynamic context later in the child run, but they do not make the original task transcript-visible as the first user task envelope, and relying on additional custom hooks for this would be harder to audit than a supported sessions_spawn option.

Requested solution

Any of these would work:

  1. Add a supported sessions_spawn option, e.g. visibleTaskEnvelope: true / taskDelivery: "system" | "visible" | "both", causing the initial child user message to include the task text and any task ID.
  2. Add config under tools.sessions_spawn / agents.defaults.subagents to choose the task-delivery style globally or per agent.
  3. Extend the plugin hook surface so subagent_spawning (or a new hook) receives the task and initial child message and can return a transformed initial child message/task envelope.
  4. Adjust the default native subagent first user message to include a compact task envelope while still keeping a token-conscious mode available for callers that want hidden/system-only task delivery.

The key requirement is that operators should not need to patch bundled dist files to make spawned-task delivery visible and auditable.

Suggested acceptance test

Add a test that spawns a configured native subagent with a unique TASK_ID and an output marker, then asserts:

  • the child transcript contains the TASK_ID in a user-visible message when visible delivery is enabled,
  • the child final answer includes the expected marker,
  • startup/default wake instructions do not override the explicit spawned task.

Thanks!

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 Native sessions_spawn task can be hidden from child transcript; request visible task-envelope option/hook [2 comments, 3 participants]