Skip to content

[Bug]: 2026.5.19 Discord shows failed file reads in chat #85310

Closed

Description

@jasonftl

[Bug]: 2026.5.19 Discord shows failed file reads in chat

Existing issue check:

Bug type

Behavior bug

Beta release blocker

No

Summary

Discord can show internal failed file-read messages such as print lines 1-220 from memory/2026-05-22.md (agent) failed or print lines 1-220 from ~/.openclaw/workspace/skills/gemini/SKILL.md (agent) failed as normal app output.

Steps to reproduce

  1. Run OpenClaw 2026.5.19 with Discord enabled.
  2. Start an agent turn from a Discord-delivered workflow where the agent tries to read a missing workspace file.
  3. In this install, the observed workflow was a scheduled Discord channel turn.
  4. Observe the Discord channel after the turn finishes.

Expected behavior

Discord should show the user-facing reply or job output only. Failed internal file-read attempts should stay in logs or diagnostics and should not appear as app messages in the channel.

Actual behavior

Discord showed this internal failed tool message:

⚠️ 🛠️ `print lines 1-180 from memory/2026-05-20.md (agent)` failed

The same bug is still present after upgrading to 2026.5.20:

⚠️ 🛠️ `print lines 1-220 from memory/2026-05-22.md (agent)` failed

The same visible-failure shape was also observed for a skill instruction file:

⚠️ 🛠️ `print lines 1-220 from ~/.openclaw/workspace/skills/gemini/SKILL.md (agent)` failed

OpenClaw version

2026.5.19 (a185ca2)

Operating system

macOS 26.5 (25F71)

Install method

Source checkout with pnpm build. Gateway runs from the built source checkout.

Model

openai/gpt-5.5

Provider / routing chain

Discord -> OpenClaw Gateway -> Codex runtime -> openai/gpt-5.5

Additional provider/model setup details

Relevant local config:

agents.defaults.model.primary = openai/gpt-5.5
agents.defaults.models.openai/gpt-5.5.agentRuntime.id = codex
channels.discord.streaming.mode = off
messages.groupChat.visibleReplies = message_tool

Logs, screenshots, and evidence

OpenClaw version and source state at the time of the primary observed failure:

$ openclaw --version
OpenClaw 2026.5.19 (a185ca2)

$ node --version
v22.22.3

$ git -C openclaw-src describe --tags --exact-match
v2026.5.19

$ git -C openclaw-src rev-parse --short=12 HEAD
a185ca283a74

The primary 2026.5.19 failure came from an agent attempt to read a missing memory file:

sed -n '1,220p' memory/2026-05-20.md
sed: memory/2026-05-20.md: No such file or directory

The relevant file was missing on disk:

$ ls -l ~/.openclaw/workspace/memory/2026-05-20.md
ls: ~/.openclaw/workspace/memory/2026-05-20.md: No such file or directory

A later 2026.5.20 run showed the bug is still present. Local launchd job log shows the user-facing scheduled summary followed by the failed internal read message:

**Scheduled summary: 3 item(s) need attention**

Summary body omitted here because it contains site-specific operational details.

[normal user-facing summary content]

⚠️ 🛠️ `print lines 1-220 from memory/2026-05-22.md (agent)` failed
delivered scheduled summary

Gateway log for the same event:

<timestamp> ⚠️ 🛠️ `print lines 1-220 from memory/2026-05-22.md (agent)` failed

Impact and severity

Affected: Discord channels on this install.

Severity: Medium annoyance. The main work can still complete, but Discord shows internal failed tool messages that look like app errors.

Frequency: Seen on this install across 2026.5.19 and still present in 2026.5.20, with different memory files.

Consequence: Users see noisy implementation details in chat, and routine automation or skill-backed turns can look broken even when the useful output was delivered.

Additional information

This looks related to the broader Discord internal-output leak tracked in #44905, but the visible symptom here is narrower and easy to search for: failed file reads are rendered as print lines ... failed app messages.

Local workaround for the scheduled job was to stop using an agent turn for a simple summary and send the formatted summary directly. That avoids this one job path, but it does not address Discord showing failed file-read messages from other agent turns.

Activity

  1. clawsweeper commented on May 22, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Latest ClawSweeper review: 2026-05-22 10:42 UTC / May 22, 2026, 6:42 AM ET.

    Workflow note: Future ClawSweeper reviews update this same comment in place.

    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

    Summary
    Keep open: the report is source-plausible on current main because scheduled heartbeat/cron-style Discord runs do not fully reuse the group/channel visible-reply policy or model-specific runtime policy that normally keeps message-tool-only output private.

    Reproducibility: yes. at source level: the reported config can bypass heartbeat message-tool-only source delivery even though normal group/channel dispatch honors it. I did not live-replay the Discord scheduled turn.

    Next step
    The source path is clear, but the issue is a security-sensitive Discord output leak that overlaps an existing broader leak thread, so maintainers should choose whether to fold it into that work or authorize a narrow heartbeat fix.

    Security
    Needs attention: The report describes internal file-read failure details leaking into a Discord channel, which is a concrete information-exposure concern.

    Review details

    Best possible solution:

    Align heartbeat scheduled runs with the same source-reply visibility and runtime policy used for normal group/channel turns, including groupChat visibleReplies and model-specific Codex runtime overrides, then add regression coverage for Discord/channel scheduled turns with failed text-only tool progress.

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

    Yes at source level: the reported config can bypass heartbeat message-tool-only source delivery even though normal group/channel dispatch honors it. I did not live-replay the Discord scheduled turn.

    Is this the best way to solve the issue?

    No patch is proposed yet; the maintainable fix is to share or mirror the existing source visibility/runtime resolution for heartbeat runs rather than adding a Discord-only sanitizer special case.

    Label changes:

    • add P1: Internal failed tool/file-read details can leak into real Discord channels during scheduled agent workflows.
    • add impact:security: The visible failed-read messages can expose local file paths and operational context to chat participants.
    • add impact:message-loss: The issue is about internal runtime messages being delivered to the wrong user-visible channel surface.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.
    • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.
    • add clawsweeper:needs-security-review: Current issue advisory state selects this label.

    Label justifications:

    • P1: Internal failed tool/file-read details can leak into real Discord channels during scheduled agent workflows.
    • impact:security: The visible failed-read messages can expose local file paths and operational context to chat participants.
    • impact:message-loss: The issue is about internal runtime messages being delivered to the wrong user-visible channel surface.

    Security concerns:

    • [medium] Internal tool failure details can reach shared Discord chat — src/infra/heartbeat-runner.ts:471
      A scheduled run can expose file paths and failed internal reads as ordinary chat messages, so the fix should be reviewed as a channel-output privacy boundary issue.
      Confidence: 0.83

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/infra/heartbeat-runner.tool-response.test.ts
    • node scripts/run-vitest.mjs src/auto-reply/reply/dispatch-from-config.test.ts

    What I checked:

    • Reporter evidence: The issue reports visible Discord messages like print lines ... failed in both v2026.5.19 and v2026.5.20, with messages.groupChat.visibleReplies = message_tool and a model-specific Codex runtime override.
    • Documented group/channel contract: The docs say messages.groupChat.visibleReplies: "message_tool" lets the agent decide when to speak by calling message(action=send) and keeps normal final text private when the model misses that tool. Public docs: docs/channels/groups.md. (docs/channels/groups.md:48, ff79299d68e3)
    • Heartbeat visibility gap: Current heartbeat prompt selection only checks messages.visibleReplies before falling back to usesCodexHarness, so a group-only messages.groupChat.visibleReplies setting does not by itself force heartbeat message-tool-only delivery. (src/infra/heartbeat-runner.ts:471, ff79299d68e3)
    • Heartbeat suppression depends on that decision: Heartbeat runs pass sourceReplyDeliveryMode: "message_tool_only" only when usesHeartbeatResponseTool is true, so the reported configuration can leave the dispatch-level source-suppression path disabled. (src/infra/heartbeat-runner.ts:1723, ff79299d68e3)
    • Model-specific runtime policy exists elsewhere: The harness runtime resolver supports model-specific agents.defaults.models.<model>.agentRuntime, but usesCodexHarness in the heartbeat runner does not consult that canonical policy path. (src/agents/harness-runtimes.ts:63, ff79299d68e3)
    • Dispatch already has the needed private-error behavior once in message-tool-only mode: Current dispatch suppresses text-only error progress when sourceReplyDeliveryMode is message_tool_only, which matches the intended outcome for failed file-read progress. (src/auto-reply/reply/dispatch-from-config.ts:1464, ff79299d68e3)

    Likely related people:

    • Vincent Koc: Git blame attributes the heartbeat response-tool decision, source-reply delivery policy, and dispatch text-error suppression to the current implementation commit. (role: current implementation author; confidence: high; commits: 0a4b30191df0; files: src/infra/heartbeat-runner.ts, src/auto-reply/reply/source-reply-delivery-mode.ts, src/auto-reply/reply/dispatch-from-config.ts)
    • Kaspre: Recent main history includes heartbeat event-routing work in the same runner, so this person is a plausible routing reviewer for heartbeat delivery behavior. (role: recent adjacent contributor; confidence: medium; commits: e53612a639b2; files: src/infra/heartbeat-runner.ts, src/infra/heartbeat-runner.subagent-session-guard.test.ts)

    Remaining risk / open question:

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

  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.
    on May 22, 2026
  3. martingarramon commented on May 22, 2026

    @martingarramon
    Contributor

    Root cause confirmed on current main (ab1fedb63f1). The gap is at src/infra/heartbeat-runner.ts:470-471:

    const visibleReplies = params.cfg.messages?.visibleReplies;
    if (visibleReplies === "message_tool") {
      return true;
    }

    resolveUsesHeartbeatResponseTool reads only messages.visibleReplies and not messages.groupChat.visibleReplies. When a Discord group sets messages.groupChat.visibleReplies: "message_tool" but leaves the global messages.visibleReplies unset, the heartbeat runner falls through to usesCodexHarness(). With a non-Codex model that returns false, usesHeartbeatResponseTool stays false and the dispatch layer at dispatch-from-config.ts:1230 never activates the message_tool_only suppression gate — so failed tool-progress lines reach the channel unchanged.

    Minimal code change: one line at :470 to resolve the more-specific group setting first:

    const visibleReplies = params.cfg.messages?.groupChat?.visibleReplies ?? params.cfg.messages?.visibleReplies;

    messages.groupChat.visibleReplies overrides the global setting for group contexts per the JSDoc at src/config/types.messages.ts:107.

    The dispatch-level suppression at dispatch-from-config.ts:1230 already handles message_tool_only correctly once activated, so no change is needed there.

    Leaving security review to maintainers given the clawsweeper:needs-security-review label.

    Test target: src/infra/heartbeat-runner.tool-response.test.ts.

  4. neeravmakwana commented on May 22, 2026

    @neeravmakwana
    Contributor

    Opened a focused fix PR: #85357

    It keeps scheduled heartbeat turns in message_tool_only delivery when group/channel visible replies or model-specific Codex runtime policy require it, with redacted before/after behavior proof in the PR body.

  5. self-assigned this
    on May 22, 2026
  6. joshavant commented on May 22, 2026

    @joshavant
    Collaborator

    Thanks @jasonftl for the detailed report and concrete release evidence. The config snippets and visible print lines ... failed examples made this tractable.

    The bug was in the scheduled heartbeat path: it could decide whether to use heartbeat response-tool delivery before carrying forward the group/channel delivery policy and before consulting model-specific Codex runtime config. In the reported Discord setup, that meant messages.groupChat.visibleReplies = "message_tool" and the model-specific Codex runtime override were not reliably enough to put the heartbeat turn into message_tool_only, so failed internal file-read/tool progress could surface as normal Discord output.

    PR #85357 fixed that path by making heartbeat runs honor the resolved group/channel chat type and model-specific runtime policy, reusing the existing message_tool_only dispatch suppression rather than adding a Discord-specific sanitizer. The issue was closed by that merged PR.

    We verified the fix with focused regression tests and a live AWS Crabbox Discord E2E run. The live run seeded a real Discord heartbeat session, executed runHeartbeatOnce, read the Discord channel back through the Discord API, and confirmed the expected heartbeat message was visible while internal failed-tool markers were not leaked.

    Fixed by #85357, merged as bd9c78f.

  7. locked as resolved and limited conversation to collaborators on May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions