Repository navigation
Episodes v1: live episodes over conversations (backend + mobile) - #22877
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Episodes v1: the day's conversations grouped into occasions (a lunch, a meeting, a work session), live while they happen and wrapped up when you move on. Backend plus the Flutter app, one themed PR, built to the approved boards D–I.
Architecture
An overlay, not a rewrite. An episode is a separate document (
users/{uid}/episodes/{id}, speech-derived fields sealed throughutils.encryption) that points at conversations. No conversation is changed by it. Per-conversation processing, smart merge, tasks and memories are untouched. Lookups are doc gets only (episode_links/current,episode_links/{conversation_id}), with no new queries or indexes. Writes are compare-and-set onstate_versioninside Firestore transactions.utils/app_integrations.py) cuts a moment on a ≥45s pause, at 600 words, or on a conversation change (utils/episodes/live.py, in-memory and bounded). Each moment runs on the postprocess executor, never on the socket path.episode_incremental(gpt-5-nano through the gateway, minimal reasoning) gets the previous state plus the new text only and returns a bounded delta: title, bullets, people, open questions, provisional items, and the moment heading. The prompt is a fixed prefix with the clock, state and new text last, so it is cache-friendly. The call is rate-limited per user (one per 60s; shorter moments merge), and a failed call keeps the previous state.episode_boundarylane, moved-on threshold 0.2, 2.5s timeout, fail-open to a 15 min fallback). There is a 3h hard cap. ThePOST /v1/episodes/{id}/wrap-upAPI closes the episode once that conversation's finalization lands.process_conversationwith its normal trigger), followed by the episode close. There is no second notes pass, and nothing inconversation_processing.py, the notes mount, the prompts or theconv-structurelane is touched.mentor_episode_state(uid)returns the live state, with a TODO inproactivity_producers.mentor_context. There are no extra reads on the mentor path.utils/conversations/episode_*andutils/llm/episode_*are the notes pipeline's "episodes". The new package isutils/episodes/, andutils/episodes/ARCHITECTURE.mdspells out the difference.App.
EpisodeProvideris capability-gated: it starts off and stays off on a 404 orenabled: false, so an older or switched-off server keeps today's UI exactly.Home (D/E). The live episode is the first row of Today: green pulsing tile, title, "Now · 24m · topics". It scrolls away with the list. A row being filled by offline sync shows a spinner and "adding 12m from your Omi" in place of the separate catching-up row. The quiet sync indicator is a thin ring around the header's device glyph; the filled row uses the same ring inline (a faint track with a turning arc), so both read as one indicator.
Device page (F). Status line, a stats row (battery, heard today, on device to sync), Right now (live episode link and catching-up progress), Recently (real disconnects from the native history), Controls (Pause/Resume) and a Transcription Language row.
Live episode (G/I).
LiveEpisodePagereplacesconversation_capturing/page.dart, and every entry point is repointed. It has two tabs:EpisodePresentation.participants): the owner plus speakers resolved to the user's people, named exactly as the transcript names them. An unresolved "Speaker N" is never named in the header, and the model's mention list does not feed it.The page ends with "Wrap Up Now" and "Omi wraps this up when you move on". Pause moves to the ⋯ menu and the device page. With episodes off, the page is today's capture page unchanged (same keys, same Finish).
Finished conversation (H). Today's page with nothing removed, plus a collapsed Moments section when the episode had two or more moments. A one-moment episode looks exactly like today. Nested bullets render as before (see render 007).
There are no Live Activity or Dynamic Island changes. The new primitives
OmiLiveDotandOmiActivityRingare added toapp/docs/ux-contract.md.Kill switch and ramp
EPISODES_ENABLEDis a kill switch, on unless set off, and it is read on every request and every moment. Off means the routes answerenabled: false, no moments are recorded, the finalizer hook no-ops, and the app falls back to today's UI.EPISODES_PERCENT(default 100) andEPISODES_UID_ALLOWLISTdefine the cohort (stable uid bucket, saltepisodes-v1). The cohort is registered inconfig/feature-flags.yaml.Ramp plan (cost risk: one nano call per moment, about 1–4 per active hour):
EPISODES_PERCENT=0.Whoever runs the deploy expands it, in one config change per step. Watch:
omi_episode_moment_updates_total,omi_episode_moment_tokens_total,omi_episode_moment_cost_usd_totalomi_episode_closed_total{reason}omi_episode_provisional_items_total{outcome}omi_episode_wrapup_latency_secondsHold if the 5% cost per active user projects above budget, if the close mix is dominated by
hard_caporfallback, or if crash-free sessions drop.Deferred (follow-ups)
open_tasks. That is the notes lane, owned by another agent.mentor_episode_state(Episodes: mentor prompt reads the live episode state instead of the buffered transcript #22870).Tests
BACKEND_UNIT_TEST_FILE_LIST+./test.sh):test_episodes_policy_state(21)test_episodes_service(StrictFirestore, CAS and conflict retry, idle/hard-cap/wrap-up close, dedupe, reconcile kept/dropped, smart-merge repoint)test_episodes_incremental_live(11)test_episodes_router(3)test_episodes_finalizer_hook(5)episode_provider_test(9)episodes_ui_test(11): page with episodes on and off, the transcript tab, the Home row, Moments, device sections and the filled rowLiveEpisodePage.Renders (synthetic data, widget-test renders at 393pt @3x)
Renders use a fixed clock (13:30) and precached asset images. In G and I the transcript has one speaker resolved to Maya and one unresolved ("Speaker 2"); the header names only You and Maya.
Product invariants affected
/v1/episodescalls use the existing app API client and base URL.scheduleTimeoutseam inrecording_transfer_coordinator.dart. With no scheduler injected, pendant frame delivery, retention and resume behavior are unchanged; thecapture_live_recovery_testguards pass 20/20.Failure-Class: none
Line-Count-Exception: app/lib/providers/device_provider.dart | 1615 -> 1624 | disconnectHistory() reuses the provider's injected BLE diagnostics seam for the device page's Recently section; moving it out would duplicate that seam
🤖 Generated with Claude Code