Skip to content

[Feature/Bug]: Isolate subagent completion from parent context; return status + child session link only by default #96975

Description

@itanyplus

Problem

Subagent completion currently injects too much child-session content back into the parent/main agent input path. For heavy subagent workloads, this can include long final reports, tool output fragments, or large completion payloads. That makes the parent session inherit the subagent's token pressure and can trigger:

  • parent context overflow;
  • compaction storms/timeouts;
  • session write-lock contention;
  • subagent completion announce failures;
  • duplicated or stale child output leaking into the user-facing channel;
  • parent workflows appearing stalled even when the child work has finished and artifacts exist on disk.

This defeats one of the main reasons to use subagents: isolating large work from the main conversation.

Desired behavior

Subagent execution, transcript, tool outputs, and final verbose content should stay isolated from the parent/main agent by default.

When a subagent finishes, the parent should receive only a small completion envelope, for example:

{
  "type": "subagent_completed",
  "status": "completed|failed|blocked",
  "childSessionKey": "agent:main:subagent:...",
  "childSessionId": "...",
  "runId": "...",
  "taskName": "...",
  "sessionLink": "openclaw://sessions/... or UI URL",
  "summary": "optional short bounded summary, e.g. <= 500-1000 chars"
}

The parent/main agent can then choose whether to inspect the child session with an explicit tool call (sessions_history, subagents, or a future dedicated child-result reader). Large child outputs should not be automatically appended to, injected into, or replayed inside the parent prompt.

Proposed default policy

  1. No raw child transcript injection into parent input.

    • Do not inject child assistant messages, tool results, logs, or full final reports into the parent model context automatically.
  2. Completion event is metadata-only by default.

    • Include status, run/session identifiers, task name, timestamps, and a link/handle to the child session.
    • Include at most a small bounded summary.
  3. Large result transfer must be explicit.

    • If the parent needs details, it should explicitly read a file/artifact or fetch child history with a bounded limit.
    • Child tasks should be encouraged to write large outputs to files/artifacts and return only the path/handle.
  4. Delivery to user channel should also be bounded.

    • Auto-announced child completion should not leak raw tool output or long child reports into Feishu/Telegram/Discord/etc.
    • A user-facing completion card/message can show status + child session link + short summary.
  5. Configurable compatibility mode if needed.

    • Existing behavior could remain opt-in with something like subagents.completion.includeResultPayload=true, but the safe default should be isolation.

Why this matters

Large subagent outputs can be tens of thousands of tokens. If those are injected into the parent, the main session pays the cost and risk:

  • every later parent turn drags the child payload forward;
  • compaction may run at exactly the wrong time while completion delivery is pending;
  • parent write locks and delivery lanes become fragile;
  • a long-running research/coding workflow can appear to stop even though child output exists.

A subagent should behave more like an isolated worker with a result handle, not like a giant hidden paste into the supervisor prompt.

Related issues / prior art

This request is related to, but more specific than:

Acceptance criteria

  • Parent prompt/input does not automatically include raw child transcript or large child result payloads.
  • Parent receives a bounded completion envelope with session/run identifiers and a child session link/handle.
  • User-channel auto-announce is bounded and does not include raw tool output by default.
  • Parent can explicitly inspect child results when needed via bounded tools or file/artifact handles.
  • Large subagent workflows no longer cause parent context overflow merely because the child completed with a long result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions