Skip to content

fix(chat): name what a proactive notification is about, and make structured cards real chat history - #11844

Merged
Git-on-my-level merged 8 commits into
mainfrom
fix/chat-notification-context
Aug 19, 2026
Merged

Git-on-my-level merged 8 commits into
mainfrom
fix/chat-notification-context

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Three defects reported from a real chat transcript, each traced to a distinct root cause.

1. A proactive notification that named nothing. A delivered card read Insight / PR blocked, needs review — the user cannot tell which pull request. The director prompt decides whether to speak and which decision type, and never said what the spoken text must contain; the structured-output schema declared title and message, the only two fields a user reads, as bare strings with no description. Adds a generic naming rule spanning referent kinds (pull request, email thread, document, file, meeting, person), measured against the production reasoning model.

2. A redundant, unactionable meeting notification. One .desktopMeetingConversationDidComplete signal fanned out to two unaware presenters: the durable conversationLink card, and a banner that also became a chat row reading <title>: <first item> and 2 more — no items attached, no action, and mislabeled Notification because meeting-notes was not a known presentation kind. The Context Director's own prompt already forbids this exact claim for every other lane ("the conversation-finalization lane owns that claim"). The banner is now system-banner-only, and its recommendations are folded into the card that already opens the conversation.

3. Structured chat cards were not real, synced chat history. The meeting-notes card appeared on the Mac that captured the meeting and was absent on the user's other Mac. Two carve-outs collided: the kernel deliberately projected text: "" for chat-first materialization turns (to avoid a "Done." filler), while SaveMessageRequest.text requires min_length=1 — so the row 422'd on every attempt and was permanently undeliverable. Compounding it, content_blocks lived inside an opaque metadata string with no Flutter support at all, so any card that did sync rendered as a blank bubble on mobile.

Measurement (issue 1)

Against gpt-5.6-luna at reasoning_effort=low — the model and effort desktop_proactive_reasoning routes to — on new referent-* benchmark cases, 12 replicates per case, scoring whether user-visible text carries one of the case's declared referentTokens:

condition title message silence (referent cases)
baseline 34/58 58/58 26/84
schema descriptions only 60/61 57/61 23/84
prose rule + schema 61/61 61/61 23/84
shipped (bulleted) + schema 67/67 67/67 17/84

The failure was in the title, not the body. Schema descriptions alone regressed body naming — the model moved the identifier into the title rather than carrying both — so the two halves ship together and a comment says neither should be removed alone. No silence regression: silence fell, expected polarity across the deck improved 134/228 → 162/228 runs, and the referent-visible-on-screen guard stayed silent 12/12 under every condition.

Caveat: the production prompt and schema bytes were driven through the repo's bench provider rather than the Omi backend, and that proxy drops response_format, so strict structured output was not exercised; the schema was supplied in-band, byte-identical across conditions.

Product invariants

  • INV-AGENT-*
  • INV-AUTH-1
  • INV-CHAT-1

Failure class

Failure-Class: none

Line-count exceptions

Line-Count-Exception: desktop/macos/Desktop/Sources/FloatingControlBar/FloatingControlBarWindow.swift | 5231 -> 5240 | The notification journaling owner needs a narrow title-preserving projection and moving that private persistence helper would broaden this fix.

Line-Count-Exception: desktop/macos/Desktop/Sources/MainWindow/Components/ChatBubble.swift | 2071 -> 2082 | The existing bubble decoder remains the compatibility boundary for first-class and legacy structured blocks.

Line-Count-Exception: desktop/macos/Desktop/Sources/Providers/ChatProvider.swift | 6844 -> 6858 | The existing sync/import owner must decode both wire shapes so persisted legacy rows continue rendering.

Testing

  • TypeScript: agent build + 65 focused tests (including a chat-first materialization turn now projecting Meeting notes ready - Weekly planning instead of "").
  • Backend: 130 tests across the desktop message/migration/deserialization suites; broader run 248.
  • Swift: focused suites plus the agent logic harness (545 Swift / 109 runtime / 109 extension).
  • Flutter: structured-message degradation test.
  • make preflight: all 36 checks pass.

Not covered: an authenticated two-Mac live sync run. Verification is build, unit, contract and hermetic-harness based.

Follow-ups (deliberately not in this PR)

  1. Server-side canonical materialization. _materialize_prompts still "never writes a Chat row"; the intent is retired account-wide on acknowledgement, so it reaches exactly one client, ever. Moving canonical meeting-card creation into the conversation-finalization lane is the real fix for cross-client durability and is an architecture change deserving its own PR. Noted in backend/routers/chat_first.py.
  2. Carry identifiers into the director prompt. Wording cannot name what it was never given. Across 69 spoken baseline runs the model named the referent whenever one appeared anywhere in the prompt; the residual vague messages come from contexts carrying no identifier at all. bucket_facts.identifiers already stores the handles extraction is told to copy, and ContextBucketStore.snapshot leaves that column out of the fact lines the director reads. That is a store change, not a prompt change.

🤖 Generated with Claude Code

Review in cubic

Git-on-my-level and others added 7 commits August 18, 2026 22:37
Add a named system-banner-only delivery mode, preserve notification headlines, classify meeting-note rows correctly, and carry open meeting action items in the durable conversation card.\n\nVerified with focused Swift, TypeScript, and backend regression suites.\n\nFailure-Class: none
A delivered notification read "Insight / PR blocked, needs review". The user
cannot act on that: they do not know which pull request, and "Insight" is the
decision type answered back as a title. The same hole produces "Respond to
email" and "Document needs review".

Nothing was violated to produce it. `directorStablePrompt` decides *whether* to
speak and *which* decision type to use and never says what the spoken text must
contain, and the structured-output schema declared `title` and `message` -- the
only two fields the user reads -- as bare strings with no description. So the
rule is added generically, spanning referent kinds rather than pull requests:
name the thing, take the identifier from the supplied context, write it exactly
as the context spells it, never invent one, and never answer a category word.

Measured against the production reasoning model (gpt-5.6-luna at
reasoning_effort low, the model and effort `desktop_proactive_reasoning` routes
to) on the new `referent-*` benchmark cases, 12 replicates per case, scoring
whether the user-visible text carries one of the case's declared
`referentTokens`:

                       title        message      silence
  baseline             34/58 (59%)  58/58        26/84 (31%)
  schema text only     60/61 (98%)  57/61 (93%)  23/84 (27%)
  prose wording        61/61        61/61        23/84 (27%)
  shipped wording      67/67        67/67        17/84 (20%)

The failure was in the title, not the body. Two wordings were tried; the
bulleted one shipped because it matched the prose one on naming, spoke more,
and matches the ordered-procedure shape its neighbours already use. Schema
descriptions alone regressed body naming (58/58 -> 57/61), so the two halves
ship together.

It does not buy naming with silence. Silence fell, expected polarity across the
whole deck improved 134/228 -> 162/228 runs, and no forbidden output term
appeared in any of the 912 replayed runs. `referent-visible-on-screen` -- the
same blocked pull request with its review thread on screen -- stayed silent
12/12 under every wording, so the "already visible" rule is intact. On
`referent-no-identifier`, whose context supplies no handle, no identifier was
invented in 8/8 spoken runs.

Eight fixtures are new, modelled on the live shape: the identifier lives in the
bucket narratives and the window title while the validated fact states the
situation generically, which is how extraction actually writes it. The
benchmark gate learned `referentTokens` and scores `unnamed_referent` on the
live-replay path, over title and message only -- `reasoning` never reaches the
user.

Known ceiling, recorded next to the wording: no wording can name what it was
never given. Across 69 spoken baseline runs the model named the referent
whenever one appeared anywhere in the prompt, including buried in a frozen
segment among distractor facts; the residual vague messages all come from
contexts carrying no identifier at all. `bucket_facts.identifiers` already
stores the handles extraction is told to copy, and `ContextBucketStore.snapshot`
leaves that column out of the fact lines the director reads. That is the next
lever and it is a store change, not a prompt change.

The added text is static, so it invalidates the cached director prefix exactly
once. 197 tests pass under the proactive filter.

Failure-Class: none
Co-Authored-By: Claude Opus 5 <[email protected]>
Project meaningful fallback text for every structured content block, send content_blocks as a first-class message field, preserve legacy metadata reads, and make Flutter degrade rich messages without blank bubbles.\n\nVerified with the agent build and focused TypeScript, Swift, backend, and Flutter regression suites.\n\nFailure-Class: none
The first-class content_blocks message field and the conversation-link
recommended action items both change the app-client surface, so the
committed snapshot went stale. Regenerated with
backend/scripts/export_openapi.py --surface app-client.

Co-Authored-By: Claude Opus 5 <[email protected]>
The first-class content_blocks field assigns a list into two dict
literals whose value types pyright had inferred narrowly from their
initial string/int members, so the strict typecheck gate rejected both
assignments. Annotate the dicts explicitly; no behavior change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Generated artifact for the first-class content_blocks message field.
Produced by backend/scripts/generate_dart_models.py --group messages.

Co-Authored-By: Claude Opus 5 <[email protected]>
Generated artifacts for the first-class content_blocks message field and
the conversation-link recommended action items. Produced by
backend/scripts/generate_ts_openapi_types.py.

Co-Authored-By: Claude Opus 5 <[email protected]>
@mintlify

mintlify Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Aug 19, 2026, 3:29 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Folding the meeting recommendations into the durable conversation card
added recommended_action_items to the capture-arrival intent, but three
assertions here still expected the old call signature and failed in CI.

Production is unchanged and correct: recommended_meeting_action_items
returns [] when a meeting has no open user-owned commitments, which is
what these fixtures describe. The non-empty path is already covered by
test_chat_first_blocks, test_chat_first_proactive_engine, and
test_listen_finalization_cloud_tasks.

Failure-Class: none
Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 143eeb9 into main Aug 19, 2026
38 of 39 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/chat-notification-context branch August 19, 2026 04:20
Git-on-my-level added a commit that referenced this pull request Aug 19, 2026
…ation drop rate readable (#11866)

Two small follow-ups to #11844. No behaviour changes: the desktop half
is comment-only, and the backend half adds a read-only ops script that
nothing calls.

## 1. The referent "Ceiling" note pointed at a dead end

#11844 left a note on `directorStablePrompt` telling whoever tunes it
next that carrying `bucket_facts.identifiersJson` into
`ContextBucketStore.snapshot` was the next lever, and that it was "a
store change, not a prompt change."

The premise is true and the conclusion is wrong. The snapshot does omit
the column — but the same fact line emits `evidenceText` verbatim:

```sql
SELECT 'fact:' || id || ' ' || statement ||
  ' [evidence: ' || evidenceText || '; refs: ' || evidenceRefsJson || ']'
```

and `BucketFactValidator.acceptedIdentifiers` keeps an identifier only
when the evidence contains it:

```swift
&& lowercasedEvidence.contains(identifier.lowercased())
```

`ContextBucketStore.writeExtraction` truncates evidence to 1,000
characters *first*, derives the identifiers from that truncated string,
and stores both. It is the only writer of the column. So every stored
handle is, by construction, a case-insensitive substring of a string the
director is already reading, and surfacing the column separately can add
nothing. Anyone acting on the old note would have spent the work to move
a value that was already in the prompt.

The note now says that, and points at the real lever instead —
extraction leaving `identifiers` empty while writing the same handle
into the statement (0/39 on real work screens, already measured and
recorded in the same file). A matching note sits at the snapshot SQL,
which is where someone would look first.

The 912-run measurement and every conclusion #11844 drew from it are
unaffected; only the forward-looking "next lever" sentence was wrong. No
prompt bytes change, so the cached prefix is untouched.

## 2. A way to actually read the materialization drop rate

#11844 deliberately left canonical server-side materialization as
follow-up work, to be decided by production data that only started
existing at that merge. The intended instrument was
`CHAT_FIRST_PROACTIVE_TOTAL`, which already labels `event='fetch'` and
`event='kernel_receipt'`.

That instrument is not readable in production. It is an in-process
`prometheus_client` counter behind a bearer-gated `/metrics`; the API
backend runs on Cloud Run with no scrape annotation; and no dashboard or
alert consumes it. The counters that *are* observable in this repo
(`pusher_queue_drops_total`, `backend_listen_active_ws_connections`)
belong to the GKE services, which carry `prometheus.io/scrape: "true"`.
Waiting two weeks and then querying it would have produced nothing.

`backend/scripts/chat_first_materialization_drop_rate.py` reads durable
intent state instead, which survives instance churn.

Two details that are easy to get wrong, both covered by tests:

- **"Delivered but unreceipted" is not a reachable state.**
`acknowledge_materialization` writes `delivered_at` and
`materialization_receipt_id` together, so looking for one without the
other finds nothing. A drop is an intent still sitting in `ready` or
`pending_kernel_receipt` past `--stale-after-hours`.
- **In-flight intents are excluded from the denominator.** Every intent
starts life unacknowledged, so counting young ones as drops reports
~100% on a perfectly healthy account.

It needs no Firestore index and adds no entry to
`firestore_index_registry`: age and delivery state are bucketed in
Python, so the account-wide pass is an unfiltered collection-group scan.
Read-only, no writes on any path.

```bash
python scripts/chat_first_materialization_drop_rate.py --uid <uid>
```

It also breaks drops down by block type, so `conversationLink` — the
meeting-notes card from #11844 — can be read off directly.

## Testing

- `make preflight` — 32/32 pass
- Bounded pre-push gate — pass, including the desktop Swift build,
black, the OpenAPI contract, and Flutter generated-artifact freshness
- `backend/scripts/typecheck.sh` — 0 errors; the new script is added to
`pyrightconfig.json` and is clean under `strict`
- 8 new unit tests, all passing, covering the two classification traps
above plus naive-datetime and malformed-record handling

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11866?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Aug 19, 2026
## Summary

This closes the actionable follow-ups from #11844 and #11866 without
reopening their settled conclusions:

- turn the materialization drop-rate instrument into a weekly, routed
decision review;
- improve referent supply at the extraction boundary, while leaving fact
validity and the director cache prefix alone; and
- make the preflight runner survive temporary backpressure from an
inherited non-blocking output pipe.

Failure-Class: none

## Issue 1 — materialization data gets a forcing function

### Chosen

The existing report is now a reusable production module as well as an
operator CLI. The hourly `notifications-job` calls it off the event
loop; it does no Firestore work except during the fixed Monday 14:00 UTC
slot. The classification remains the one established in #11866:
`delivered` is acknowledged, `ready`/`pending_kernel_receipt` older than
48 hours is dropped, younger rows are in flight, and malformed undated
rows are separate.

Every due run emits one content-free aggregate verdict with
`review=true`, including a healthy zero-drop verdict. A production
notifications-job deploy idempotently creates or updates a Cloud Logging
metric and a Cloud Monitoring policy routed to the repository's existing
`SYNC_BACKFILL_ALERT_NOTIFICATION_CHANNELS` contract; it fails the
deploy if the channel list is empty or the resulting policy has no
channel. This is intentionally a decision-review signal rather than only
a failure alarm: a 0% result must reach a human too, otherwise the
deferred server-materialization decision can still disappear into
silence. Durable drops and monitor failures log at error; full source
and block-type breakdowns remain in the explicit CLI rather than
becoming dynamic log labels.

This is the long-term seam I would keep: the already-scheduled
notification worker owns a related read-only operational check, the
expensive collection-group scan runs weekly rather than hourly, the
runtime log is bounded and content-free, and the deploy workflow
reconciles the human route instead of assuming somebody created it by
hand.

### Rejected

- Prometheus remains the wrong path: the in-process API counter has no
production scrape/consumer path.
- A scheduled GitHub workflow would not be autonomous. Live repository
inspection showed the `prod` environment has required reviewers and the
read-only Firestore credential, so an unattended schedule would stop at
environment approval before it could produce the number.
- Cloud Tasks supplies execution, not a human sink, and there is no
request whose lifecycle owns this weekly review. A separate Cloud Run
job would duplicate the notifications job's Firestore runtime,
deployment, schedule, and alert plumbing without creating a better
ownership boundary.
- Alerting only on non-zero drops was rejected because it preserves the
original drift failure for the healthy case.

The Cloud Monitoring resources were not applied from this branch. The
next production notifications-job deployment performs and verifies that
reconciliation; local `gcloud` production inspection was unavailable
because the workstation credential could not be refreshed
non-interactively.

## Issue 2 — referents are supplied during extraction

### Chosen

The extraction prompt and the structured-output descriptions now carry
the same cross-field contract. When the screen supplies a specific
person, PR/ticket and repository, thread subject, document, file/branch,
or meeting name/time, extraction must copy that wording into the fact
statement and evidence and mirror the same strings into `identifiers`.
When the screen supplies no identifier, `identifiers` stays empty and
the fact describes only supplied context; invention remains forbidden.

Both halves are deliberate. The prior director repair showed that schema
descriptions and prompt instructions reinforce different parts of
structured output, while the recorded 39-screen residual showed the
fields were disagreeing. The regression test inspects all three schema
fields so a later edit cannot quietly return to a single-field hint.

Fact validity is unchanged and still checks evidence resolution only.
The director prompt and `directorStablePrompt` bytes are unchanged, so
the cached director prefix is byte-identical. Extraction does not pass a
cache key, so changing its prompt/schema does not invalidate a provider
prompt-cache prefix.

### Rejected

- Carrying stored `identifiersJson` into the director remains a proven
no-op because accepted identifiers are already substrings of emitted
evidence.
- Retuning the director was rejected because the 69-run baseline already
named every supplied referent; supply, not selection, is the measured
bottleneck.
- An identifier validity gate was rejected because it previously demoted
1,083/1,085 facts on identifiers alone and would destroy evidence-backed
facts again.
- Inferring a handle absent from the capture was rejected as
fabrication; the no-identifier fallback is explicit.

The committed offline benchmark contract passes, including the two
guard-case mappings. I did not claim a new live-model measurement: the
isolated local harness had no running container runtime or provider
credentials, while the remote-dev launcher explicitly uses
production-backed Firebase identity/data. The live `--invoke` replay was
therefore not run. The focused Swift production/test build did run, and
all 29 `ContextBucketPromptAssemblerTests` passed.

## Issue 3 — checks must produce honest outcomes

### Chosen in this PR

`preflight_runner.py` now treats `BlockingIOError` from
`stdout`/`stderr.flush()` as temporary backpressure. On POSIX it waits
for the inherited descriptor to become writable and retries the same
buffered flush; the portable fallback uses the runner's bounded polling
interval, and `InterruptedError` retries immediately. The regression
test reproduces the observed Errno 35 twice before success. No gate is
skipped, downgraded, or made quieter.

### Deliberately not changed here: Desktop Swift runner governance

The evidence does not support a workflow code fix for a check that
literally never renders. On #11844, `Desktop Swift Static & Test
Contracts` started within seconds and ended after about 66.6 minutes
(failed, after merge). On #11866 it waited about 45 minutes for a
runner, then completed successfully about 39 minutes later (also after
merge). Live branch-protection inspection returned
`required_status_checks: null` for `main`.

That makes the durable defect repository governance: maintainers can
merge before the stable aggregate `Desktop Swift Build & Tests` has
published a verdict. Changing test commands, splitting the job, or
weakening parallelism would not make anyone wait for it and would risk
hiding the two suites under investigation. The long-term fix is an
external GitHub ruleset/branch-protection change requiring that
aggregate check once its current flaky failure class is repaired.
Repository settings are not versioned by this PR, so I am explicitly
leaving that operation out rather than pretending a workflow edit solves
it.

## Verification completed before the full gates

- `python3 .github/scripts/test_preflight_runner.py` — 25 tests passed,
6 skipped.
- Focused backend files through `backend/test.sh` — 12
materialization-report tests and 5 notifications-job orchestrator tests
passed.
- `./scripts/dev-feedback.py --once swift
'ContextBucketPromptAssemblerTests'` — 29 tests passed after a full
Swift production/test build.
- `desktop/macos/scripts/agent-logic-harness.sh --cross-surface-smoke` —
Swift and agent cross-surface contracts passed.
- `bash desktop/macos/tests/test-context-bucket-benchmark.sh` — 34
fixture contracts and 24 director mappings passed; this is the offline
contract, not a live model replay.
- `actionlint .github/workflows/gcp_notifications_job.yml` — passed.
- `OMI_PR_BODY_FILE=/tmp/omi-proactive-followup-pr.md make preflight` —
all 40 checks selected by the current local manifest passed.
- `OMI_PR_BODY_FILE=/tmp/omi-proactive-followup-pr.md bash
scripts/pre-push origin < /dev/null` — the real, broader pre-push gate
exited successfully.
- `cd backend && bash scripts/typecheck.sh` — the final strict run
completed with 0 errors and 3,667 pre-existing warnings.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11873?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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