Skip to content

fix(runtime-host): silence assistant background turn notifications - #6220

Merged
me2seeks merged 2 commits into
apache:mainfrom
me2seeks:fix/assistant-background-notifications
Oct 22, 2026
Merged

me2seeks merged 2 commits into
apache:mainfrom
me2seeks:fix/assistant-background-notifications

Conversation

@me2seeks

Copy link
Copy Markdown
Contributor

Summary

Assistant background Sessions could emit native system notifications whenever an internal turn completed, failed or waited for input. A durable task can span many such turns, and its coordinator already owns user-facing feedback.

Suppress catalog attention for Sessions carrying the durable personal-assistant-background label at the Host publication boundary. Keep catalog updates, terminal results and interaction state intact. This applies to Bot, delegated-task, index and discovery workers, independently of sidebar visibility, and covers both Owner and shared-session feeds without changing the wire protocol. Ordinary conversation attention and the existing incognito policy retain their behavior.

Fixes #6218

Verification

  • Runtime Host build/typecheck and prerequisite workspace builds pass.
  • Complete execution-host-message integration suite: 13 tests pass, using real temporary Host processes and protocol clients with the deterministic backend.
  • New cases cover completed and failed background turns, normal notifications after removing the background label, and background waiting-for-user state without attention. Existing ordinary completion, question, sandbox, privacy, steering and queued-message cases pass.
  • Removing the label gate makes the background notification regression cases fail; restoring it passes.
  • Biome check on both changed files and git diff --check pass.

OS toast rendering and packaged Desktop were not exercised. Existing installed Hosts and user tasks were not changed. User-facing task results and decisions continue through the coordinating assistant; this only silences worker turn notifications.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex inspected the notification flow, authored the filter and integration tests, and ran the local checks.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/S Under 100 readable lines label Oct 21, 2026

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Reviewed 0b0837d9 (one commit, +70/-5, against main 9826db1b). No P0–P2 finding.

The catalog publication callback in execution-composition.ts:1180 now also clears attention when the Session header carries ASSISTANT_BACKGROUND_SESSION_LABEL, using the same branch that already handles incognito. Catalog changes, terminal results and the waiting_for_user state are still published; only the native notification payload is removed. The label is the durable one that Bot, delegated-task, index and discovery workers already set (assistant/background-sessions.ts, bot/controller.ts, index-initiative/controller.ts), so suppression does not depend on sidebar visibility. No protocol change.

The concern I checked was whether a background worker that waits for user input could now stall silently. Its coordinators already watch for waiting_for_user/blocked with pending interactions and report them through the assistant (bot/controller.ts:230, proactive-matters/delivery.ts:110, index-initiative/controller.ts:168), so the user-facing signal still exists.

P3: the header read is inside the same try, so if it fails, attention is dropped for that event, including for an ordinary Session. That fails quiet rather than noisy, and the log message was updated to match. It is acceptable, but a header-read failure now silences ordinary notifications as well as private ones.

The tests use real temporary Host processes. They cover completed and failed background turns, a background waiting_for_user without attention, and normal attention returning once the label is removed.

I read the diff and the related paths and did not rerun tests. CI test is still running on this head. A trial merge with #6219, which also edits execution-composition.ts, is clean.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[kabi-sol]

Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.

Reviewed 0b0837d96d8d3c886bb95fc269bcdfd0d296b4fa: one P2 in the new regression tests (inline). No demonstrated production notification loss.

Design: silencing internal assistant turns is appropriate. The PR deliberately filters at the Host publication boundary, whereas #6218 suggested Desktop filtering while preserving Host attention. These are different contracts: all catalog clients lose the background attention field, while canonical terminal/interaction facts and catalog invalidations remain. The single publication seam covers owner/scoped feeds structurally; this is reasonable for the intended globally quiet workers, but should not be described as preserving the raw Host attention signal.

Verification: clean install/patches and prerequisite + Runtime Host builds pass. The unmodified 13-test execution-host-message suite returns 11 pass / 2 fail; both new completed/failed cases fail after label removal with 0 !== 1. Running those two alone reproduces both failures. Changing only the compiled test to await the positive attention event makes both pass, with production code untouched. Background waiting, ordinary attention and privacy cases pass in the original suite. See inline for the synchronization defect.

No packaged Desktop/OS toast, Windows, actual assistant job, or shared-principal end-to-end test was run. I saw another reviewer's summary before reviewing. The earlier CI attempt failed a separate Desktop Windows Chrome store-page test; a rerun is now queued. COMMENT only.

Ablation strengthens the finding: removing only the compiled background-label guard makes the waiting case fail (1 !== 0), but both completed/failed cases incorrectly pass. The latter are not synchronized well enough to protect their claimed negative behavior. All compiled mutations were restored.

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Update to our earlier review of 0b0837d9. It now has one P2. Our previous "no P0–P2" conclusion is withdrawn. The production change itself is unchanged in our view.

P2: the new completed/failed background-turn tests race the notification and do not guard the behaviour (execution-host-message.test.ts, the assistant background turns keep catalog and … facts without attention loop). The test asserts catalogChanges and attention.length as soon as waitForTerminalTurn returns. On the Host side, the catalog/attention frame is published only after the callback awaits readHeaderSnapshot and the runtime-policy snapshot, so the frame can arrive after the terminal turn event.

The other review on this PR (kabi-sol, review 5598165007) reproduced the consequences. The test failed twice as written; a control that waits for the notification to arrive passes. And with the background-label filter removed, these two cases still pass, so they do not protect the intended suppression. Please make the assertions wait for the catalog frame for that turn (or another explicit publication signal) before counting attention, in both the labelled and unlabelled iterations.

This is a test-only defect. We do not see a production path that drops ordinary notifications. The CI failure on this head is a separate test, opencli-chrome.test.js, which this PR does not touch; that job has been re-run.

@me2seeks
me2seeks requested a review from xxhZs October 21, 2026 10:22

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Incremental review of 0b0837d9..7e19a88e. The first commit is unchanged (git range-diff), and the new commit is test-only. Our P2 is fixed; no P0–P2 remains.

The completed/failed background-turn test now opens a Session subscription and waits for the terminal session_projection of that turn. It then issues a no-op session.metadata.update as a fence before counting attention. I checked the ordering it relies on. In SessionContinuityCoordinator, the terminal publication broadcasts the projection and then awaits onCatalogChanged inside #runInSessionLane (session-continuity-coordinator.ts around lines 678–745). A later metadata write on the same Session lane therefore cannot complete until the callback has read the header/policy and published its catalog frame. That closes the race for both the positive (unlabelled → 1 attention) and the negative (labelled → 0) iteration. It also means that removing the label filter now makes the labelled iteration fail, which was the other half of our P2.

Minor note, no action needed: the fence's own metadata update also produces a catalog frame, so catalogChanges > before is now satisfied by it too. The terminal catalog publication is still asserted indirectly through the attention count in the unlabelled iteration.

CI test passes on this head.

@github-actions github-actions Bot added effort/M Under 500 readable lines and removed effort/S Under 100 readable lines labels Oct 22, 2026

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[kabi-sol]

Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.

Re-reviewed 7e19a88e6f98dfe80a04c47921a6e37043a2204e: my P2 in review 5598165007 is fixed. No new P0–P2 findings; approving at the human requester's explicit direction.

The tests now observe the terminal projection and cross the Session admission lane with a metadata update before asserting catalog attention. I traced terminal publication's awaited catalog callback and metadata's use of that same lane. This fences publication for both positive and negative assertions instead of assuming a terminal query implies notification delivery.

Rebuilt Runtime Host and reran the complete 13-test execution-host-message suite successfully using real temporary Host processes and controlled execution. Independently removing only the compiled background-label gate now fails the completed, failed, and waiting background tests; the completion cases no longer falsely pass as they did in the previous review. Restored the compiled implementation afterward; no tracked source changes.

No packaged Desktop/OS toast, live model, native Windows, or shared-principal end-to-end test. The original review's distinction between suppressed catalog attention and retained canonical state still applies. This automated approval does not replace the independent human review required by CONTRIBUTING.md.

@me2seeks
me2seeks merged commit ca4ac75 into apache:main Oct 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(desktop): silence native notifications from assistant background workers

3 participants