Skip to content

fix: toast only when the resident agent actually acted - #46

Merged
YoungSx merged 1 commit into
mainfrom
fix/idle-agent-toast-noise
Sep 26, 2026
Merged

YoungSx merged 1 commit into
mainfrom
fix/idle-agent-toast-noise

Conversation

@YoungSx

@YoungSx YoungSx commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

What

The resident agent wakes on every observed event. Under a whole-home-directory
file-I/O flood, a small model often narrates "no user request; nothing to act
on"
instead of staying silent as its prompt asks — and the watch loop toasted
on any non-empty reply, so that became a desktop popup every few seconds.
This is the same anti-pattern the notify path already guards against for failed
turns; it just wasn't guarding against idle narration.

Now the desktop toast fires only when the turn ran a world-changing tool.
The panel and the JSON log still record every reply — only the one desktop
interruption is gated.

How

  • turnActionTracker (in resident-agent.ts) hooks Pi's tool_call event and
    latches "acted" only for side-effecting built-ins (bash/edit/write).
    Read-only orientation — query_recent_events (whose own description invites
    the model to "check what happened while you were thinking") and Pi's read —
    does not count, so an orient-then-narrate turn no longer toasts either.
  • The real session resets the latch at the top of each prompt() and exposes it
    as ResidentSession.actedInLastTurn(); the watch loop reads it after the turn
    and gates notifier.notify on it.
  • O(1) per event — deliberately not getSessionStats().toolCalls, which
    rescans the whole unbounded continue-d history on every read (a real
    per-turn cost on a 24/7 resident agent).

The read/act distinction

An adversarial review flagged that counting any tool call would let a
read-only orientation call (query_recent_events) re-open the exact spam this
change targets — the model orients, finds nothing, narrates anyway, and still
toasts. The ACTING_TOOL_NAMES allowlist fixes that: unknown/new tools fail
safe toward silence, matching the goal of the change.

Testing

  • bun run typecheck (src + tests): clean.
  • Full bun test: 816 pass / 0 fail (7 skip) on Linux.
  • New coverage: the tracker latches on bash/edit but not query_recent_events/read;
    createResidentAgent delegates actedInLastTurn; the watch loop toasts when
    acted and stays quiet (panel line still broadcast) when the turn acted on nothing.

Backend-only (no ui/ changes), so the Rust panel binary does not need rebuilding.

🤖 Generated with Claude Code

…rates

The resident agent wakes on every observed event, and a small model often
narrates "no user request; nothing to act on" instead of staying silent as its
prompt asks. The watch loop toasted on any non-empty reply, so under a home-dir
file-I/O flood that became a popup every few seconds — the anti-pattern the
notify path already guarded against for failed turns.

Gate the toast on whether the turn ran a world-changing tool. Pi fires
`tool_call` before each tool; a new `turnActionTracker` latches only the
side-effecting built-ins (bash/edit/write) and ignores read-only orientation —
`query_recent_events` (whose own description invites the model to look back) and
Pi's `read`. The real session resets it at the top of each `prompt()` and
exposes it as `ResidentSession.actedInLastTurn()`. O(1) per event, deliberately
not `getSessionStats().toolCalls`, which rescans the whole unbounded continue-d
history on every read.

The panel and the JSON log still record every reply — only the desktop's one
interruption is gated. A pure-narration or read-only-orientation turn stays on
the panel and in the log, where a no-op is read; it no longer rings the doorbell.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@YoungSx
YoungSx merged commit e4cabce into main Sep 26, 2026
0 of 3 checks passed
@YoungSx
YoungSx deleted the fix/idle-agent-toast-noise branch September 26, 2026 17:20
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.

1 participant