Skip to content

[Bug]: aborted/timeout embedded runs can leak commentary/internal partial assistant content to user-facing channels (Feishu repro) #59536

Closed

Description

@xisheng687

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When an embedded run times out after partially completing real work, OpenClaw can deliver an aborted partial assistant message to the user-facing channel instead of a clean timeout/error response. In my repro, internal commentary text and a reply directive leaked into a Feishu DM.

Steps to reproduce

  1. Run OpenClaw 2026.4.1 with Feishu connected.
  2. In a normal main agent session, trigger a longer multi-step task that:
    • reads memory/session state
    • performs several tool/exec steps
    • then prepares a final user-facing summary
  3. Let the run reach the embedded timeout path.
  4. Observe logs showing:
    • embedded run timeout
    • embedded_run_failover_decision ... decision=surface_error reason=timeout
  5. Observe the channel user receives a partial assistant reply that includes internal-looking text instead of only a clean failure/degraded response.

Expected behavior

After timeout/abort, the user-facing channel should receive either:

  • a clean synthesized timeout/degraded response, or
  • a clean partial completion summary written for the user

It should never deliver:

  • commentary-phase text
  • internal drafting notes
  • reply directives such as [[reply_to_current]]
  • truncated half-finished assistant output

Actual behavior

In my Feishu repro, the run partially succeeded, then timed out, and OpenClaw delivered an aborted assistant message containing internal text.

Observed leaked content included:

  • Need answer concise mention not fully E2E tested tomorrow.
  • [[reply_to_current]]

The leaked message was recorded in the session JSONL as an aborted assistant response, not as a clean final user reply.

OpenClaw version

2026.4.1

Operating system

Ubuntu Linux (Tencent Cloud server)

Install method

npm / pnpm global install

Model

openai-codex/gpt-5.4

Provider / routing chain

openclaw -> gateway embedded agent runtime -> Feishu channel delivery

Additional provider/model setup details

  • Repro happened in a Feishu DM with the main / CEO-style agent.
  • The same run had already completed meaningful work before timeout.
  • This does not look Feishu-only from prior issue history; Feishu is just the channel used in this repro.
  • Logs suggest the problem is in the embedded timeout / abort / final-delivery path, not in business logic of the task itself.

Logs, screenshots, and evidence

Gateway/session evidence from my environment:

Session file:
`/root/.openclaw/agents/main/sessions/b2253668-a725-4944-9ace-e50ae7e8ab7a.jsonl`

Relevant entries:
- an `openclaw:prompt-error` with `error: "request timed out"`
- immediately followed by an assistant message with:
  - commentary-phase text:
    `Need answer concise mention not fully E2E tested tomorrow.`
  - and visible reply directive text:
    `[[reply_to_current]] ...`
- the assistant message has `stopReason: "aborted"` and `errorMessage: "This operation was aborted"`

Representative log sequence:
- `embedded run timeout`
- `embedded_run_failover_decision ... decision=surface_error reason=timeout`
- channel dispatch completes and the user sees the bad partial reply

This suggests the aborted partial assistant payload was still eligible for delivery.

Impact and severity

Affected:

  • user-facing messaging channels when an embedded run times out after partial progress

Severity:

  • High for UX / trust; users can see internal commentary or half-finished content

Frequency:

  • Intermittent / edge-case, but reproducible under longer multi-step runs that hit timeout

Consequence:

  • confusing user-visible garbage
  • loss of trust in the assistant
  • unclear whether the task actually succeeded
  • channel users may see internal framework-only text that should never surface

Additional information

This looks related to other timeout / delivery / leakage bugs in OpenClaw, for example:

My repro is specifically about:

  • timeout/abort
  • aborted partial assistant content
  • commentary/internal text leaking to the user-facing channel

Suggested fix

A likely fix would be one or both of:

  1. On timeout/abort, discard commentary-phase / internal partial assistant blocks before channel delivery.
  2. If surface_error is chosen after timeout, prefer a clean synthesized user-facing error/degraded response over any aborted partial assistant payload.

A regression test could assert that after an embedded timeout:

  • no phase="commentary" text is delivered to the channel
  • no [[reply_to_current]] or other internal directive tags reach the final user-visible message
Image

log:
2026-04-02T14:57:36+08:00 [agent/embedded] embedded run timeout: runId= sessionId= timeoutMs=
2026-04-02T14:57:36+08:00 [agent/embedded] embedded_run_failover_decision: stage=assistant decision=surface_error failoverReason=timeout timedOut=true aborted=true
2026-04-02T14:57:36+08:00 [session] openclaw:prompt-error error="request timed out"
2026-04-02T14:57:36+08:00 [session] aborted assistant response contained leaked text:

  • "Need answer concise mention not fully E2E tested tomorrow."
  • "[[reply_to_current]] ..."

Activity

  1. added
    bug
    on Apr 2, 2026
  2. mbelinky commented on Apr 5, 2026

    @mbelinky
    Contributor

    Related update: #61282 is now merged in commit 4175cae.

    What #61282 fixes:

    • commentary-phase assistant text is now suppressed at the shared embedded subscribe delivery boundary before user-visible delivery

    Why this issue stays open:

    • This timeout/abort report includes more than commentary leakage. It also includes aborted partial delivery and visible internal directive text such as [[reply_to_current]] on the timeout / surface_error path.
    • fix(agents): suppress commentary-phase output leaks #61282 likely reduces part of the symptom if the leaked content is commentary-tagged, but it does not prove the abort/failover delivery path is fully clean.

    Leaving this issue open for the timeout/abort-specific remainder.

  3. miguelmanlyx commented on Apr 5, 2026

    @miguelmanlyx

    Looks like this looks like a timeout problem on ai api. Maybe try npx ai-doctor. It can fix missing timeout guards with safe request timeouts plus timeout and retry protection.

  4. steipete commented on Apr 25, 2026

    @steipete
    Contributor

    Closing this as implemented after Codex review.

    Current main suppresses commentary-phase partials before channel delivery, strips [[reply_to_current]]/other reply directives from visible outbound text, and synthesizes a clean timeout error when a timed-out embedded run has no safe assistant payload. The timeout/abort remainder called out after #61282 appears covered on main and shipped in v2026.4.7.

    What I checked:

    • Embedded subscribe now blocks commentary partial delivery: handleMessageUpdate resolves assistant phase, returns early for commentary, and never flushes text_end block replies for that phase. (src/agents/pi-embedded-subscribe.handlers.messages.ts:457, ec3dbd22a4de)
    • Regression tests cover commentary suppression on partials and text_end: Tests assert no agent event, no partial reply, and no block-reply flush for commentary-only text_delta/text_end updates, including phase carried only in textSignature metadata. (src/agents/pi-embedded-subscribe.handlers.messages.test.ts:414, ec3dbd22a4de)
    • Payload builder no longer falls back to commentary-only assistant text: buildEmbeddedRunPayloads derives answer text from extractAssistantVisibleText(...) / final_answer and parses reply directives before emitting payload text; the matching test expects no payload when only commentary text exists and Done. when a final_answer block exists. (src/agents/pi-embedded-runner/run/payloads.ts:233, ec3dbd22a4de)
    • Reply directives are stripped from visible outbound text: parseReplyDirectives removes reply tags from text while preserving reply metadata, and reply-tag tests verify [[reply_to_current]]\nHello is delivered as text Hello with replyToCurrent=true instead of leaking the directive. (src/auto-reply/reply/reply-directives.ts:16, ec3dbd22a4de)
    • Timed-out runs now synthesize a clean timeout payload when no safe assistant payload exists: run.ts explicitly returns an error payload with timeout text when timedOut && !timedOutDuringCompaction && !payloadsWithToolMedia.length, and timeout-compaction tests assert the returned payload is an error containing timed out. (src/agents/pi-embedded-runner/run.ts:1776, ec3dbd22a4de)
    • Release notes show the partial fix first, then the broader shipped follow-up: v2026.4.5 notes the earlier #61282 commentary buffering fix, while v2026.4.7 adds the later #61829/related history-and-replies hardening that matches the issue comment saying #61282 was only partial. (CHANGELOG.md:1130, ec3dbd22a4de)

    So I’m closing this as already implemented rather than keeping a duplicate issue open.

    Review notes: reviewed against ec3dbd22a4de; fix evidence: release v2026.4.7.

  5. locked as resolved and limited conversation to collaborators on Apr 28, 2026
  6. added a commit that references this issue on Apr 30, 2026
    70ba69c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions