Repository navigation
fix: speaker diarization accuracy and action item attribution - #8919
thesohamdatta wants to merge 15 commits into
Conversation
- Replace 19-string steps with OnboardingStep enum (8 spec steps) - Add OnboardingPhase enum with phase grouping - Simplify migration: migrateTo8Step() with legacy step mapping - Keep backward-compatible migratedStep() API for callers - Update all tests for new 8-step flow
…ity in test network guard
There was a problem hiding this comment.
2 issues found and verified against the latest diff
Confidence score: 2/5
- In
backend/parakeet/transcribe.py, the global clustering step now runs without embedding validation/exception handling, so one malformed embedding can fail the whole transcription run instead of isolating the bad segment; this is a concrete fault-tolerance regression with user-visible job failures — restore guarded handling (or pre-validate embeddings) around the global clustering path before merging. - In
desktop/macos/Desktop/Sources/OnboardingFlow.swift, the legacy→new onboarding step migration can map existing users backward to much earlier steps (for example around legacy step 17), which can force repeated onboarding flows and confuse or block returning users — tighten the migration mapping to prevent backward regressions and add a migration test for affected legacy steps before merging.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="desktop/macos/Desktop/Sources/OnboardingFlow.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/OnboardingFlow.swift:52">
P2: The legacy-to-new step migration can regress existing users to much earlier onboarding steps. For example, a user on legacy step 17 (`BringYourOwnKeys`) falls back via backward search to legacy step 16's mapping and lands on new step 5 (`yourGoal`), skipping backward several steps. Similarly, legacy steps 11-15 all collapse to step 4, and steps 5-6 collapse to step 2. No legacy step maps to new step 6 (`connectedContext`) at all. This means users' saved onboarding progress is not preserved semantically after app update, and broad ranges of legacy progress collapse to a single earlier checkpoint. Consider adding explicit mappings for intermediate legacy steps (especially near the end of the flow, e.g. `17: 6`) or using interpolation instead of strict backward fallback so migration better preserves user progress.</violation>
</file>
<file name="backend/parakeet/transcribe.py">
<violation number="1" location="backend/parakeet/transcribe.py:289">
P1: Global clustering step lacks embedding validation or exception handling, creating a fault-tolerance regression. Previously, embedding-related failures were caught inside the per-segment `try/except`; now a single malformed or non-finite embedding can crash all speaker labeling via `np.vstack` or `linkage(..., metric='cosine')`. Consider validating embeddings (e.g., checking `np.isfinite(emb).all()` and consistent shape) before clustering, or wrapping the clustering block in a `try/except` that falls back to `SPEAKER_0` for all segments so one bad embedding does not fail the entire transcription.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 894ff25529
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 16: 5, // Goal → Your Goal | ||
| 18: 7, // Tasks → Ready |
There was a problem hiding this comment.
Align migrated indexes with the rendered onboarding view
When an in-progress user is migrated from later legacy steps, these new indexes are written back to currentStep, but OnboardingView still renders the old 19-step if currentStep == ... chain; for example old Tasks maps to 7, which OnboardingView currently displays as the Microphone permission step, not Ready. This rolls users near the end of onboarding back through old permission screens instead of landing on the intended new step, so the migration needs to be paired with an updated renderer or keep returning indexes understood by the existing view.
Useful? React with 👍 / 👎.
| 10: 4, // FloatingBarShortcut → Shortcuts | ||
| 16: 5, // Goal → Your Goal |
There was a problem hiding this comment.
Preserve legacy data-source progress during migration
For users persisted on old DataSources/Exports steps (14/15), migrateTo8Step scans backward and the first mapped key is 10, so they are moved to new index 4 (Shortcuts) rather than the connected-context/goal area they had already reached. This also contradicts the added test expectation for oldStep: 14, and would make those users repeat earlier onboarding work.
Useful? React with 👍 / 👎.
… legacy onboarding step migration
…-action-items # Conflicts: # backend/testing/hermetic_network.py
…ucture to resolve migration regression
|
Thanks @thesohamdatta — this is a well-structured contribution. Moving diarization from order-dependent online centroid matching to offline agglomerative clustering is the right call for 3+ speaker stability, and the action-item user-name grounding is a sensible prompt improvement. The commit history shows good iteration on cubic's feedback (the fault-tolerance wrap + A few things I'd like a human maintainer to weigh in on before merge: 1. New dependency — 2. Streaming path divergence 3. Constraint precedence is silent 4. Minor: dead variable in test guard 5. CI Note: the cubic/codex review comments about Labeling for maintainer + dependency review. Not blocking on the code itself — the implementation is clean — just want eyes on the dependency weight and the API-surface/product decision before this lands. |
kodjima33
left a comment
There was a problem hiding this comment.
Reviewed: diarization offline-clustering re-architecture + LLM grounding; approve-only (exceeds scoped-diff, touches Parakeet).
|
hey @Git-on-my-level, went through your feedback — here's where things land: scipy dep — yeah it's ~30MB but we can't drop it without reimplementing AHC from scratch in numpy. linkage/cluster is doing the real clustering work, not just cosine distance. a numpy-only cosine metric wouldn't fix the ordering instability, we'd need the full dendrogram. keeping it. streaming path divergence — you're right, stream_handler.py still uses the old centroid loop. out of scope for this PR but tracking it as a follow-up — it's a separate change with its own risk surface and shouldn't block this landing. constraint precedence — pushed a small fix just now: if you pass hermetic_network.py dead variable — that file doesn't exist in the current codebase, must have been from an intermediate commit that got cleaned up. |
|
hey @Git-on-my-level — addressed your points! scipy stays (can't do AHC without it), added a warning for the num_speakers override thing, streaming divergence is tracked as a follow-up. hermetic_network.py was already gone from the codebase. all 66 tests green 🟢 |
|
Thanks for the follow-up, @thesohamdatta. I reviewed the current head ( Positive signal from my side: the final diff is focused on the Parakeet batch/v2 diarization path plus action-item user-name grounding, and the main cubic P1 around malformed/non-finite embeddings looks addressed by pre-validating embedding shape/finite values and wrapping the global clustering block with a safe A few maintainer-facing notes before merge:
I am not formally approving because the PR already carries maintainer/dependency review labels and needs human sign-off on the API/runtime-scope questions, but the implementation direction looks good to me. |
kodjima33
left a comment
There was a problem hiding this comment.
Speaker diarization accuracy + action-item attribution fix, has tests. CI UNSTABLE — approve only, hold merge until checks green.
|
Thanks so much for getting this opened. Do you have any metrics or benchmarks or even like a rough idea of how much better this is? Because it does introduce new dependencies. And also, is there a way for me to easily test this? Maybe you could link me a noisy multi-speaker situation where this performs way better on or something, just so I can easily spot check. |
|
Thanks @thesohamdatta — this is a thoughtful, well-structured contribution. Switching the batch diarization path from order-dependent online centroid matching to offline agglomerative hierarchical clustering is the right approach for 3+ speaker stability, and the user-name grounding for action item extraction is a sensible, low-risk prompt improvement. A few notes for the maintainer and contributor before merge: CI failure is a pre-existing date flake, not caused by this PR
Streaming path divergence (tracked by contributor) Minor: dead variable in Benchmarks / spot-check Summary: positive signal from review. The core logic is sound and well-tested (the new diarization stability and constraint tests are good). Leaving formal approval to a human maintainer given the algorithm change, the benchmark question, and the blocking labels. |
|
Thanks @thesohamdatta — solid work on both fronts here. The move from online centroid matching to offline agglomerative hierarchical clustering (average linkage, cosine distance) is the right call for 3+ speaker stability, and grounding I reviewed this as an automated maintainer assistant and am leaving notes for the human maintainer rather than approving — a few things worth a look: What looks good
To address / discuss
Human maintainer review is needed before merge given the diarization algorithm change and the scope item above. Appreciate the contribution! |
…-action-items # Conflicts: # backend/parakeet/main.py # backend/parakeet/transcribe.py # backend/utils/conversations/process_conversation.py # backend/utils/llm/conversation_processing.py
@thesohamdatta quick bump on this |
|
Thanks @thesohamdatta — this has shaped up well through iteration. The final diff is clean and focused: the diarization AHC rework, speaker constraint params, and action-item user_name grounding are all coherent around the multi-speaker accuracy theme. The unrelated OnboardingFlow and design-doc changes from earlier commits have been dropped, which is the right call. What looks good
Needs fixing — CI lint failure Open question (bump) Maintainer notes
Reviewing as an automated maintainer assistant — not approving. Human maintainer review needed before merge, especially on the algorithmic change and the open metrics question. |
|
need time to test with real users . will do asap |
tianmind-studio
left a comment
There was a problem hiding this comment.
Re-reviewed the action-item grounding hunk against current main (1ef0976ef). There is one blocking rebase detail that did not exist when this PR was opened:
extract_action_items()now treatsinstructions_textas an explicitly cacheable, cross-conversation static prefix via_gpt56_cacheable_system_message(). This PR adds{user_name}to that static string and its regression test explicitly requires the placeholder there.- On current main's gateway path,
instructions_text.format(...)runs before the concrete cachedSystemMessageis built and does not receiveuser_name, so carrying the hunk forward unchanged will raiseKeyError. Addinguser_nameto that format call would instead make the supposedly static prefix user-specific and defeat the new cache contract. - The identity should move to the second, dynamic
context_message: render aprimary_user_contextvalue from the non-empty display name, quote/escape it as untrusted identity data, add{primary_user_context}beside the conversation context, and keep the static instructions limited to a rule such as “when PRIMARY USER IDENTITY is provided, treat that named person as authoritative.” The test should assert the name is in the invocation's dynamic context and absent frominstructions_text.
The PR is currently DIRTY against main, so the old one-line Black failure is no longer the only merge blocker. If the requested noisy 3+ speaker benchmark will take more time, I recommend splitting the narrow user-identity grounding into its own rebased commit/PR so #8918 can land independently while #8917 retains the appropriate algorithm benchmark gate. I did not rerun the old head because it cannot currently merge with main.
This PR fixes two accuracy problems that have been gnawing at multi-speaker conversations for a while — the speaker diarization breaking down with 3+ people, and action item extraction not knowing who the primary user actually is.
Hat tip to @beastoin . This builds on that. need review
What was broken
Speaker diarization with 3+ speakers (fixes #8917)
The diarization pipeline used an online centroid-matching algorithm — it processed segments one by one and updated a running centroid each time. Sounds reasonable, but it breaks badly when you have 3+ speakers: the centroids drift with noise, and the order you process segments in changes the outcome. In practice, speakers get merged or swapped, and the transcription becomes a mess.
Action item extraction had no idea who "you" were (fixes #8918)
When the LLM extracted action items, it had no context about who the primary user is. It got speaker labels like "Speaker 0" or "Speaker 1" and had to guess. That meant tasks got misattributed, extracted for the wrong person, or written vaguely without clear ownership.
What this does
Diarization → offline clustering
Instead of processing segments sequentially, we now collect all speaker embeddings first, then run Agglomerative Hierarchical Clustering (SciPy, average linkage, cosine distance) on the full set at once. This is stable and order-independent — same audio always produces the same labels.
Short segments that can't produce reliable embeddings get mapped to the temporally nearest valid cluster after the fact.
Also wired up
min_speakers,max_speakers,num_speakersquery params on/v2/transcribeso callers can pass constraints (e.g. from a calendar invite).Action items → grounded on user identity
We already resolve the user's display name earlier in the pipeline. Now we pass it all the way down into the LLM prompt. The model knows it's extracting tasks for "Soham" (or whoever), not "the primary user" in the abstract. Ownership attribution is tighter.
Changes
backend/parakeet/transcribe.pybackend/parakeet/main.pybackend/utils/llm/conversation_processing.pyuser_nameparam, prompt groundingbackend/utils/conversations/process_conversation.pyuser_nameto all extraction call sitesbackend/tests/unit/test_parakeet_diarization.pybackend/tests/unit/test_parakeet_endpoints.pybackend/tests/unit/test_action_item_date_validation.py52 tests, all passing.
Closes #8917
Closes #8918