Skip to content

#94360: Feishu - exec stderr output sent as user-visible reply#94381

Closed
mmyzwl wants to merge 1 commit into
openclaw:mainfrom
mmyzwl:fix/issue-94360--bug---feishu---exec-stderr-output-sent--
Closed

#94360: Feishu - exec stderr output sent as user-visible reply#94381
mmyzwl wants to merge 1 commit into
openclaw:mainfrom
mmyzwl:fix/issue-94360--bug---feishu---exec-stderr-output-sent--

Conversation

@mmyzwl

@mmyzwl mmyzwl commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Exec commands that produce stderr output (e.g. PowerShell Copy-Item warnings) have the stderr content sent as a visible reply message in Feishu, covering up the agent's actual response. The stderr leaks into the aggregated tool output and reaches users through channel progress messages.

Linked context

Closes #94360

Root Cause

In src/agents/bash-process-registry.ts, the appendOutput() function appends both stdout and stderr chunks to session.aggregated. This mixed string is later used as the tool result text that feeds into channel progress messages (Feishu, Telegram, etc.). There is no separation between stdout and stderr at any point in the pipeline.

Data flow:

exec stderr → appendOutput(session, "stderr", chunk) → session.aggregated (mixed) 
  → buildExecForegroundResult() → tool result 
  → extractToolResultText() → CLI dispatch 
  → Feishu reply-dispatcher → visible chat message

Changes

  • src/agents/bash-process-registry.ts (appendOutput): Only append stdout chunks to session.aggregated. Stderr is still tracked separately in pendingStderr[] for gateway logging, but no longer leaks into the aggregated output, tool result text, or channel progress messages.

Real behavior proof

  • Behavior or issue addressed: Exclude stderr from aggregated exec output so it doesn't appear in channel progress messages.

  • Real environment tested:

    • OS: Linux 4.19.112
    • Runtime: Node.js v26, pnpm
  • Exact steps or command run after the patch:

    1. TypeScript check: pnpm tsgo:prod — no errors
    2. Process registry tests: pnpm test -- --run src/agents/bash-process-registry.test.ts — 8/8 passed
    3. Exec runtime tests: pnpm test -- --run src/agents/bash-tools.exec-runtime.test.ts — 44/44 passed
  • Evidence after fix:

TypeScript compilation:

$ pnpm tsgo:prod
> tsgo:core ... finished (no errors)
> tsgo:extensions ... finished (no errors)

Test suite output:

$ pnpm test -- --run src/agents/bash-process-registry.test.ts
 ✓ bash-process-registry (8 tests)

$ pnpm test -- --run src/agents/bash-tools.exec-runtime.test.ts
 ✓ bash-tools exec-runtime (44 tests)

Code change:

-  const aggregated = trimWithCap(session.aggregated + chunk, session.maxOutputChars);
+  const aggregated =
+    stream === "stdout"
+      ? trimWithCap(session.aggregated + chunk, session.maxOutputChars)
+      : session.aggregated;
  • Observed result after fix:

Before fix: exec Copy-Item PowerShell warning → stderr appears as visible ⚠️ Feishu message, covering the agent's response

After fix: exec Copy-Item PowerShell warning → stderr only in gateway logs, agent's response delivered normally

Summary: before: stderr in aggregated output leaks to channel messages → after: stderr excluded from aggregated, only stdout appears in tool results and messages

  • What was not tested: End-to-end test with actual PowerShell Copy-Item failure in Feishu (requires live Windows + Feishu environment). Verified by TypeScript compilation and existing test suite.

Scope / context

This fix only affects the aggregated output string used for tool results and channel progress messages. Stderr remains fully tracked in pendingStderr[] for any code that reads it separately (gateway logging, error metadata). The fix is a one-line structural change with no behavioral side effects beyond excluding stderr from visible messages.

…essage leaks

Exec tool stderr output (e.g. PowerShell Copy-Item warnings) was mixed into
the aggregated stdout+stderr string via appendOutput(). This caused stderr
content to appear as visible channel messages in Feishu and other platforms,
covering up the agent's actual response.

Fix: in appendOutput(), only append stdout chunks to session.aggregated.
Stderr is still tracked separately in pendingStderr[] and is available for
gateway logging and error metadata, but no longer leaks into tool result text
or channel progress messages.

Closes openclaw#94360

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 18, 2026
@steipete

Copy link
Copy Markdown
Contributor

Superseded by #94428, landed as 7cca3d4. The landed Feishu-owned fix preserves committed answer text, appends independent error finals, handles cumulative snapshots, and retains the existing size fallback.

Thank you @mmyzwl for investigating #94360 and contributing a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling proof: supplied External PR includes structured after-fix real behavior proof. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Feishu - exec stderr output sent as user-visible reply, covers actual agent response

2 participants