Skip to content

feat(desktop): extract environmental speaker context to detect multi-party calls and meetings - #11808

Merged
undivisible merged 3 commits into
BasedHardware:mainfrom
aryanorastar:feat/environmental-speaker-context
Aug 20, 2026
Merged

undivisible merged 3 commits into
BasedHardware:mainfrom
aryanorastar:feat/environmental-speaker-context

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Extracts environmental multi-party speaker context from live diarization segments during ambient listening. Previously, diarization tags (speaker_id, is_user) were stored in raw segments but never summarized into an environmental context signal.

With this change:

  • EnvironmentalSpeakerAnalyzer extracts active speaker count, non-user participant count, and identified participant names (e.g. Maya / Participant 1) over a bounded 180s sliding window.
  • Produces a structured EnvironmentalSpeakerSignal and renders a safe, injection-sanitized prompt section (== ENVIRONMENTAL / CALL CONTEXT ==) for the director and assistant.
  • Enables the assistant to recognize when the user is on a call or meeting with others ("I noticed another person in your call").

Product invariants affected

none

How it was verified

  1. Built and ran unit test suite covering all cases:
    swift test --filter EnvironmentalSpeakerContextTests -> 7 passed in 0.007s
    • Solo/monologue (no false multi-party trigger)
    • Two speakers (unnamed participant)
    • Two speakers (named participant from person map)
    • Multi-party group meeting (3+ speakers)
    • Active window pruning (stale turns from earlier calls excluded)
    • Label sanitization (prompt injection safe)
    • Director volatile prompt integration
  2. Added e2e flow coverage entry in context-buckets-dogfood.yaml
  3. Added changelog fragment

Tests

  • desktop/macos/Desktop/Tests/EnvironmentalSpeakerContextTests.swift (7 unit tests)

Failure class (fixes)

Failure-Class: none

Review in cubic

…party calls and meetings

- Add EnvironmentalSpeakerSignal and EnvironmentalSpeakerAnalyzer in ProactiveAssistants/Core
- Detect multi-party conversation state, unique speaker count, and identified participant names from live diarization segments
- Bounded 180s active sliding window to exclude stale turns from earlier calls
- Format safe environmental context prompt section with newline sanitization
- Wire environmental call context into ContextProactivityEngine volatile prompt assembly
- Add e2e flow coverage and changelog fragment
- Add 7 comprehensive unit tests in EnvironmentalSpeakerContextTests (all passed)
@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.

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks @aryanorastar — clean, well-scoped feature. Reviewed file by file:

EnvironmentalSpeakerContext.swift — Good design: EnvironmentalSpeakerAnalyzer.analyze is a pure function over [SpeakerSegment] with an injectable now, so the 180s active-window logic (activeWindowSeconds) is deterministically testable. sanitizeLabel (newline flattening + 40-char cap) is a sensible mitigation for speaker-name injection, and the test explicitly asserts the flattened inline result. The isUser || speaker == 0 user-detection assumption is consistent with existing conventions (backend parse fallback in AppState+Transcription.swift, and LocalTranscriptionService mic=0 / system=1).

EnvironmentalSpeakerContextTests.swift — Solid coverage of the cases that matter: solo baseline (no false multi-party trigger), unnamed and named other speakers, 3+ speaker meetings, stale-turn pruning outside the window, sanitization, and the prompt-builder integration.

ContextProactivityEngine.swift — Correct await MainActor.run hop to read LiveTranscriptMonitor.shared.segments (the monitor is @MainActor-isolated).

ContextBucketRollup.swift — The new environmentalSignal parameter defaults to nil, so existing callers (e.g. ContextBucketDirectorProbe) compile unchanged. Backward-compatible.

changelog/unreleased/20260818-environmental-speaker-context.json — Matches the documented fragment schema in desktop/macos/changelog/README.md.

e2e/flows/context-buckets-dogfood.yaml — Coverage entry added for the new source file.

Two non-blocking observations worth a maintainer decision:

  1. Named participants aren't wired in production yet. ContextProactivityEngine calls analyze(segments:) without a speakerPersonMap, so in the shipped app otherParticipantLabels will always be "Participant (Speaker N)" — names like "Maya" only appear in tests. AppState.liveSpeakerPersonMap ([Int: String], speakerId → person ID) is maintained from identification events and could be a wiring point, though it stores IDs rather than display names, so it would need name resolution. Fine as a follow-up, but worth deciding before merge since the description highlights identified participant names.

  2. The new prompt section is always on. Other proactive-context capabilities are gated behind ContextBucketsFeature flags (e.g. isRetrievalHopEnabled), while == ENVIRONMENTAL / CALL CONTEXT == is injected into the director volatile prompt whenever multi-party speech is detected. Whether ambient-social awareness ships ungated is a product call.

The direction itself fits Omi well — turning already-captured diarization metadata into situational awareness ("user is on a call with others") collects nothing new and grounds recommendations in the user's actual context. Leaving the two decisions above for human maintainer review; happy to see this land.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution needs-maintainer-review Needs a human maintainer to sign off before merge macOS labels Aug 18, 2026
@aryanorastar

aryanorastar commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @mdmohsin7 Thanks @Git-on-my-level for the thorough review and positive-signal!

Merge-readiness summary:

  • ✅ positive-signal + needs-maintainer-review labels applied
  • ✅ 17/17 checks green, 10 skipped, 0 failing
  • ✅ MERGEABLE/CLEAN — no conflicts with main
  • ✅ 7 Swift unit tests pass (solo, unnamed, named, multi-party, window pruning, sanitization, director integration)

Two product decisions flagged by David's review (non-blocking):

  1. Named participants not wired in production yet (speakerPersonMap not passed) — Participant (Speaker N) only. Fine as follow-up.
  2. Environmental context prompt section ships ungated (no feature flag) — product call on whether ambient-social awareness needs a gate.

Ready for write-access approval and merge.

@undivisible undivisible left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed current GitHub state (open, not draft, 6 files, Desktop Swift tests/compile + hygiene green) and the live diff. Scoped environmental-speaker analyzer + prompt section + unit tests match the brief; no surprise files. Non-blocking follow-ups (speakerPersonMap names, feature flag) can land later. Approving to merge.

@undivisible
undivisible merged commit 44ca862 into BasedHardware:main Aug 20, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macOS needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants