Skip to content

fix: hide subagent announce handoff prompts - #79618

Merged
joshavant merged 2 commits into
mainfrom
fix/79071-subagent-announce-transcript
May 9, 2026
Merged

joshavant merged 2 commits into
mainfrom
fix/79071-subagent-announce-transcript

Conversation

@joshavant

Copy link
Copy Markdown
Collaborator

Summary

  • Problem: subagent completion announces were persisted as requester user turns and could surface [Inter-session message] ... sourceTool=subagent_announce runtime context in Control UI/WebChat history.
  • Why it matters: completed subagent results should reach the requester without exposing internal handoff metadata or polluting the requester transcript.
  • What changed: suppress transcript persistence for internal subagent task-completion handoff prompts, and filter legacy subagent announce inter-session rows from chat.history projection.
  • What did NOT change (scope boundary): normal user-authored inter-session messages, subagent child transcripts, and assistant completion delivery remain intact.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: live sessions_spawn completion announce into a requester WebChat session.
  • Real environment tested: local contained Gateway, live OpenAI Responses model openai/gpt-5.4-mini, branch release/2026.5.7 at abffed82d8 before and after applying this patch.
  • Exact steps or command run after this patch: started Gateway with contained state/config, connected over Gateway WebSocket as an operator client, created a dashboard session, sent a parent prompt that calls sessions_spawn with an isolated child and then sessions_yield, then inspected both raw JSONL transcript messages and chat.history.
  • Evidence after fix (copied live output):
{
  "marker": "CHILD-79071-RELEASE-FIX",
  "chatSendOk": true,
  "rawMessageCount": 10,
  "rawUserCount": 1,
  "historyCount": 8,
  "rawUserHasInternalBegin": false,
  "rawUserHasInterSession": false,
  "rawUserHasSubagentAnnounce": false,
  "rawAssistantHasChildToken": true,
  "historyHasInternalBegin": false,
  "historyHasInterSession": false,
  "historyHasSubagentAnnounce": false,
  "historyAssistantHasChildToken": true,
  "rawUserSnippets": [],
  "historySnippets": []
}
  • Observed result after fix: child result delivered to the requester, while neither the raw requester transcript nor chat.history contains the internal announce wrapper.
  • What was not tested: Discord thread-bound UI rendering and non-OpenAI providers.
  • Before evidence:
{
  "marker": "CHILD-79071-RELEASE-BASE",
  "chatSendOk": true,
  "rawMessageCount": 11,
  "rawUserCount": 2,
  "historyCount": 9,
  "rawUserHasInternalBegin": true,
  "rawUserHasInterSession": true,
  "rawUserHasSubagentAnnounce": true,
  "rawAssistantHasChildToken": true,
  "historyHasInternalBegin": false,
  "historyHasInterSession": true,
  "historyHasSubagentAnnounce": true,
  "historyAssistantHasChildToken": true
}

Root Cause (if applicable)

  • Root cause: the subagent announce path handed runtime-generated task-completion context back through the requester agent as a normal prompt, so Pi persisted it as a requester user message; chat.history then projected the persisted inter-session wrapper.
  • Missing detection / guardrail: tests covered delivery mechanics but not the transcript/display hygiene for internal subagent_announce completion handoffs.
  • Contributing context (if known): older affected transcripts may already contain these wrapper rows, so display projection also needs a legacy filter.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/gateway/server-methods/agent.test.ts, src/gateway/session-history-state.test.ts, src/agents/agent-command.live-model-switch.test.ts.
  • Scenario the test should lock in: internal subagent task-completion announces set prompt persistence suppression, legacy subagent announce rows are hidden from history projection, and fallback/model-switch retries preserve suppression.
  • Why this is the smallest reliable guardrail: it covers the Gateway handoff seam, the persisted-history projection seam, and the agent-command retry seam without requiring a live model for every CI run.
  • Existing test that already covers this (if any): src/agents/session-tool-result-guard.test.ts remains adjacent guard coverage for tool result/session handling.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

Completed subagent results still appear, but internal subagent_announce handoff prompts no longer appear as requester user turns in WebChat history.

Diagram (if applicable)

Before:
subagent completion -> internal announce prompt -> requester transcript user row -> WebChat wrapper leak

After:
subagent completion -> internal announce prompt -> requester assistant result, no persisted internal user row
legacy stored wrapper row -> chat.history projection filter -> hidden from WebChat

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS local host
  • Runtime/container: local Gateway with contained state/config; release branch validation used release/2026.5.7 at abffed82d8
  • Model/provider: OpenAI Responses, openai/gpt-5.4-mini
  • Integration/channel (if any): WebChat/Gateway WebSocket; channels disabled for isolation
  • Relevant config (redacted): token-auth loopback Gateway, coding tool profile, sessions_spawn available, OpenAI API key supplied via redacted env file

Steps

  1. Start Gateway from release/2026.5.7 without this patch and connect over WebSocket.
  2. Create a dashboard session and send a parent prompt that calls sessions_spawn with an isolated child and then sessions_yield.
  3. Confirm the child marker reaches the requester.
  4. Inspect the raw requester transcript and chat.history for sourceTool=subagent_announce / [Inter-session message].
  5. Apply this patch to the same release worktree and repeat the same live flow with fresh contained state.

Expected

  • Child result reaches the requester.
  • Raw requester transcript has no internal subagent_announce user prompt after the initial user turn.
  • chat.history has no inter-session wrapper row for the subagent announce.

Actual

  • Before patch: raw transcript and chat.history exposed the internal announce wrapper.
  • After patch: child result delivered; no internal announce wrapper in raw transcript or chat.history.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What I personally verified:

  • Focused tests: pnpm test src/gateway/server-methods/agent.test.ts src/gateway/session-history-state.test.ts src/agents/agent-command.live-model-switch.test.ts src/agents/session-tool-result-guard.test.ts
  • Formatting: pnpm exec oxfmt --check --threads=1 src/gateway/server-methods/agent.ts src/agents/command/types.ts src/agents/agent-command.ts src/gateway/chat-display-projection.ts src/gateway/server-methods/agent.test.ts src/gateway/session-history-state.test.ts src/agents/agent-command.live-model-switch.test.ts
  • Changelog attribution: pnpm check:changelog-attributions
  • Changed gate: pnpm check:changed in Blacksmith Testbox, run https://github.com/openclaw/openclaw/actions/runs/25589137355
  • Live validation on current feature branch with OpenAI: passed with no internal announce wrapper in raw transcript or chat.history.
  • Live validation on release/2026.5.7: reproduced before patch, passed after patch.

Edge cases checked:

  • Legacy persisted subagent announce row filtering.
  • Fallback/model-switch retry path keeps prompt persistence suppression.
  • Assistant completion still reaches the requester.

What I did not verify:

  • Full pnpm check / full pnpm test after the final rebase.
  • Discord thread-bound UI rendering.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: filtering too broadly could hide legitimate inter-session user content.
    • Mitigation: suppression and display filtering are scoped to sourceTool=subagent_announce plus subagent task-completion provenance, not all inter-session messages.
  • Risk: suppressing persistence could drop child results.
    • Mitigation: live tests verify child assistant result still reaches requester, and regression tests cover the handoff/retry seams.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 9, 2026
@clawsweeper

clawsweeper Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR suppresses requester transcript persistence for internal subagent_announce task-completion handoff prompts, filters legacy announce wrapper rows from chat history, and adds regression coverage plus a changelog entry.

Reproducibility: yes. Current main has a high-confidence source reproduction path through subagent-announce-delivery into the Gateway agent prompt without initial persistence suppression, and the linked report plus PR body provide live WebChat/Gateway before evidence.

Real behavior proof
Sufficient (live_output): The PR body includes copied live before/after Gateway/WebSocket output showing the internal announce wrapper removed from raw transcript and chat.history while the child result still arrives.

Next step before merge
The protected maintainer label makes this a human review/landing decision rather than a ClawSweeper repair job; I did not find a concrete patch defect for automation to fix.

Security
Cleared: The diff does not add dependencies, permissions, network calls, secret handling, or code execution surfaces; it narrows internal transcript exposure.

Review details

Best possible solution:

Land a maintainer-approved backend transcript-boundary fix that suppresses only internal subagent completion handoff persistence and keeps history projection filtering as legacy defense in depth.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main has a high-confidence source reproduction path through subagent-announce-delivery into the Gateway agent prompt without initial persistence suppression, and the linked report plus PR body provide live WebChat/Gateway before evidence.

Is this the best way to solve the issue?

Yes. The proposed direction fixes the persistence boundary and adds a narrow history projection filter for legacy rows, which is safer than a UI-only rendering filter and does not require a new config option.

What I checked:

  • Protected label: The live PR metadata shows the maintainer label on this open external PR, so this review should not close or otherwise clean it up automatically. (6c30c35fee33)
  • Current announce path: Current main sends subagent completion announces through the Gateway agent method as message: params.triggerMessage with inputProvenance.sourceTool defaulting to subagent_announce, matching the reported leak boundary. (src/agents/subagent-announce-delivery.ts:774, 8562aa8ab2f3)
  • Current persistence behavior: Current main only suppresses prompt persistence on fallback retries after a user turn was already persisted; it has no initial suppression knob for internal handoff prompts. (src/agents/agent-command.ts:1049, 8562aa8ab2f3)
  • Current history projection gap: Current chat history projection drops empty and heartbeat messages, but it does not specifically drop legacy inter-session subagent_announce wrapper rows after envelope stripping. (src/gateway/chat-display-projection.ts:508, 8562aa8ab2f3)
  • Related report context: The linked regression report and comments describe the same Control UI/WebChat path on v2026.5.7, including visible [Inter-session message] ... sourceTool=subagent_announce wrapper text and a prior ClawSweeper source review that kept the bug open.
  • Posted real behavior proof: The PR body includes copied live before/after JSON output from a local contained Gateway/WebSocket run showing rawUserHasSubagentAnnounce and historyHasSubagentAnnounce true before the patch and false after the patch, while the child result still reaches the requester. (6c30c35fee33)

Likely related people:

  • steipete: Recent file history and prior related fixes show substantial work on subagent announce delivery, inter-session prompt marking, and the earlier internal-completion leak fix. (role: recent maintainer; confidence: high; commits: 6df120fb3987, c5c08c074a44, e74347bbe72d; files: src/agents/subagent-announce-delivery.ts, src/sessions/input-provenance.ts, src/gateway/chat-display-projection.ts)
  • vincentkoc: Recent merged work touched the same subagent completion and gateway routing surfaces, including preserving subagent announce output and grouped completions. (role: adjacent owner; confidence: medium; commits: e80de466e5e1, b6f9b5f21e84, c6d4f1fab806; files: src/agents/subagent-announce-delivery.ts, src/gateway/server-methods/agent.ts)
  • roshanasingh4: Authored the structured subagent announce output work that shaped the completion announce payload surface involved in this path. (role: introduced adjacent feature history; confidence: medium; commits: 1baa55c1456b; files: src/agents/subagent-announce.ts, src/agents/subagent-announce-output.ts)

Remaining risk / open question:

  • Discord thread-bound UI rendering and non-OpenAI providers are outside the posted live proof, though the changed suppression path is Gateway/agent-side and covered by focused tests.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8562aa8ab2f3.

Re-review progress:

@joshavant
joshavant force-pushed the fix/79071-subagent-announce-transcript branch from b3965a5 to 3bda49c Compare May 9, 2026 03:14
@joshavant
joshavant merged commit b30ead9 into main May 9, 2026
34 checks passed
@joshavant
joshavant deleted the fix/79071-subagent-announce-transcript branch May 9, 2026 03:15
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix: hide subagent announce handoff prompts

* chore: update subagent announce changelog entry
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix: hide subagent announce handoff prompts

* chore: update subagent announce changelog entry
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix: hide subagent announce handoff prompts

* chore: update subagent announce changelog entry
orswn added a commit to getboon/openclaw that referenced this pull request Oct 30, 2026
…ielding (#314)

A parent agent that spawns sub-agents and calls sessions_yield is idle
while the children run. When a child finishes, the gateway agent method
runs a parent turn with the child result. That turn did not save its
prompt to the parent transcript. The model saw the result once, in that
turn only. On the next wake the result was gone, so the parent waited
for children that had already finished and never sent its final answer.

The suppression came from upstream "fix: hide subagent announce
handoff prompts" (openclaw#79618). Its goal was to hide the handoff prompt in
chat history. The chat display projection already hides user rows with
subagent_announce provenance, so dropping the transcript row is not
needed for that goal. Upstream removed the same suppression in
openclaw#181673.

Remove the automatic suppression for sub-agent completion handoffs. The
completion turn now saves a user row with inter_session /
subagent_announce provenance that carries the child result. Callers that
pass suppressPromptPersistence explicitly keep their behavior.

Trade-off: when a completion delivery stays pending, for example in a
session with no deliverable channel, the agent steering queue replays it
on each wake, and a sessions_yield abort returns the leased items to the
queue. That replay is now saved in each wake row too. A TODO marks the
release on the yield abort; fixing it changes the steering lease rules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR proof: sufficient ClawSweeper judged the real behavior proof convincing. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Subagent announce still leaks internal context to Control UI — 2026.5.6 regression (partial fix of #62306)

1 participant