Skip to content

fix(shared): hide tool_progress heartbeat events from chat delivery - #1094

Merged
tiann merged 1 commit into
tiann:mainfrom
junmo-kim:fix/tool-progress-heartbeat-leak
Jul 29, 2026
Merged

fix(shared): hide tool_progress heartbeat events from chat delivery#1094
tiann merged 1 commit into
tiann:mainfrom
junmo-kim:fix/tool-progress-heartbeat-leak

Conversation

@junmo-kim

Copy link
Copy Markdown
Contributor

Problem

While a sidechain (subagent, Task tool) runs a long Bash command, the Claude
Agent SDK periodically emits a tool_progress heartbeat event on the
transcript/stream. isClaudeChatVisibleMessage() (shared/src/messages.ts)
only special-cases system and rate_limit_event message types and defaults
everything else to visible, so this new event type falls through and its raw
JSON body renders directly in the chat, e.g.:

{ "type": "output", "data": { "type": "tool_progress", "uuid": "...", "parentUuid": "...", "isSidechain": true, "tool_use_id": "...", "elapsed_time_seconds": 32, "message": "Bash tool running for 32s..." } }

Solution

Same pattern as the existing rate_limit_event filter (#423, fix: filter rate_limit_event from Claude Remote/Local chat paths): add an explicit
tool_progress deny branch to isClaudeChatVisibleMessage(). Because this
function is the single gate consumed by the CLI local launcher, the CLI
chat-visibility re-export, and both web normalizeAgent.ts call sites, the
fix propagates to local- and remote-mode sessions alike without touching any
of those call sites.

Screenshots

Before After
raw JSON leaking into chat before the fix heartbeat hidden after the fix

The Task subagent card renders identically running in both (spinner + elapsed timer) — the only difference is the raw JSON heartbeat text underneath it.

Tests

  • Added hides tool_progress heartbeat messages from chat delivery next to
    the existing rate_limit_event case in
    cli/src/claude/utils/chatVisibility.test.ts.
  • bun run test (root): cli 1364 tests / hub 499 tests / web 1297 tests /
    shared 114 tests, all passing.
  • bun typecheck: clean across cli/web/hub.
  • Isolated E2E stack (fake CLI over Socket.IO /cli namespace + Playwright):
    injected an assistant message with a running Task (subagent) tool_use block
    (no tool_result yet, so the ToolCard renders in its running state — the
    spinner + elapsed timer) followed by a tool_progress heartbeat for that
    subagent's sidechain, once with the fix reverted and once with the fix
    applied. Screenshots above reproduce the shape of the original bug report
    (a running subagent tool card with raw JSON leaking underneath it) — the
    Task card renders identically running in both captures, and the only
    difference between before/after is that the heartbeat JSON text underneath
    it disappears once the fix is applied.

서브에이전트(sidechain)가 오래 걸리는 도구를 실행할 때 SDK가 주기적으로
내보내는 tool_progress heartbeat 이벤트가 isClaudeChatVisibleMessage()의
기본 통과 분기를 거쳐 raw JSON 그대로 채팅에 노출되던 문제를 고친다.
rate_limit_event 필터링(tiann#423)과 동일한 패턴으로 타입 전체를 deny한다.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No issues found.

Questions

  • None.

Summary

  • Review mode: initial. Reviewed the full diff for shared/src/messages.ts and cli/src/claude/utils/chatVisibility.test.ts; no high-confidence correctness, security, regression, performance, or maintainability issues found. Residual risk: runtime behavior of tool_progress payloads could not be exercised locally in this workflow environment.

Testing

  • Not run: bun run test cli/src/claude/utils/chatVisibility.test.ts failed because bun is not installed in this runner shell.

HAPI Bot

swear01 added a commit to swear01/hapi that referenced this pull request Jul 28, 2026
fix(shared): hide tool_progress heartbeat events from chat delivery
swear01 added a commit to swear01/hapi that referenced this pull request Jul 29, 2026
fix(shared): hide tool_progress heartbeat events from chat delivery
@tiann
tiann merged commit 659913c into tiann:main Jul 29, 2026
2 checks passed
@junmo-kim
junmo-kim deleted the fix/tool-progress-heartbeat-leak branch July 29, 2026 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants