Skip to content

feat(episodes): default account context for episode summaries (people, calendar, prior discussions, open actions) - #25368

Merged
Git-on-my-level merged 12 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/q12-ctx-default
Nov 15, 2026
Merged

Git-on-my-level merged 12 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/q12-ctx-default

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Episode notes gain a deterministic background block with the stored people in the recording, an overlapping stored calendar entry, the two most recent matching conversations in a bounded recent window, and related open actions or loops. The composer gets this account context without an additional model turn or external calendar API request; the transcript remains the authority for this episode.

Failure-Class: none

Product invariants affected

  • INV-MEM-1: no new memory tier, collection or write; the owner explicitly authorizes in-account background in the governing brief.
  • INV-MEM-3: related facts reuse the existing hydrated memory result, preserving its canonical deletion, suppression and generation checks. The block adds no direct memory reader.
  • INV-MEM-4: no memory intake or promotion changes.

Behavior and limits

Default on in code behind EPISODE_COMPOSER_DEFAULT_CONTEXT_ENABLED; bound to the same dev/prod Cloud Run services and backend-listen/pusher charts as EPISODE_COMPOSER_CONTEXT_ENABLED. Switching it off delegates directly to the previous context gather. The Q12-M hook does not change eligibility or transcript-receipt code; those behaviors come from the merged summaries branch. No composer version/fingerprint bump or deploy-triggered regeneration.

One worker and the existing eight-second absolute deadline cover both gathers. Existing memory/profile retrieval runs first and retains all 640 charged data reads; the separate 48-read allowance does not charge that budget. Default sections use only the time remaining. Successful memory results survive a later default-section timeout. Combined charged data-read ceiling: 688; memory-provider routing/control/readiness reads and SDK retries remain additional as documented by the sibling. Combined rendered context: 4,500 existing tokenizer tokens + at most 4,800 added UTF-8 bytes/characters (at most 4,800 byte-BPE tokens), or 9,300 context tokens per prompt. The tokenizer vocabulary has at most 128 bytes per token, yielding a conservative combined text ceiling of 580,800 UTF-8 bytes/characters (4,500 × 128 + 4,800); the original token limits are the useful prompt bound. All gathers stay within the same 8-second caller deadline. People, calendar and prior sections have at most 1.25 seconds of the remaining deadline. Prior reserves up to1.25 seconds for actions, which may use up to2 seconds; errors drop that section, no retries. Previously completed sections survive later memory failure/timeout, and late results cannot change the returned block. Reservations before RPCs cap the block at 48 document reads, including empty queries and conservative reservations for failed RPCs. Rendering is capped at 4,800 UTF-8 bytes and characters including labels and provenance, with stable people first. Queries use only existing single-field indexes, with runtime query drivers registered; no new index deployment is required.

Candidate bounds after review: six resolved people with stored person fields and up to three name/alias-matched facts reused from the existing authoritative memory result; eight stored meetings starting between one day before episode start and episode end, ranked by actual overlap; twelve previous conversations using only manual identity receipts and title/overview, returning up to two sharing an exact resolved person; thirteen relation-prioritized task candidates and eight open loops, filtered to people/prior discussion links. These bounded windows do not guarantee exhaustive historical retrieval. No transcript text or pointer payload is read for prior matching. Automatic-only identities without a receipt do not match history. Current-member and surfaced-prior conversation IDs drive linked task queries first (up to three batches of30, eight candidates total), followed by three exact-person candidates and two recent name-only candidates; all use explicit single-field ordering. Open loops use the store OPEN_STATUSES. The prior section reserves up to1.25 seconds for actions, whose own ceiling is2seconds of the remaining deadline. Rendering appends complete JSON rows and marks omissions. Task generation checks exclude rows retained after a task reset. Categories, privacy/visibility labels and subject attribution do not deny in-account context; attribution is rendered.

Cost model

At the sibling lane's supplied 27,000 composes/day baseline (composer-round3-final.md), the hard maximum is 1,296,000 added document reads/day, or $0.7776/day using the nam5 $0.06/100,000 reads rate in Google's official nam5 example. The live read-only database descriptor confirmed nam5 on 2026-11-15. Queries have at most one range field; no query offsets, vector requests or added writes.

The 4,800-byte cap is also a conservative maximum of 4,800 added input tokens with the composer's byte-BPE tokenizer; typical English text is smaller. At the sibling's repository Luna input rate of $0.10/million input tokens, worst-case added prompt cost is $12.96/day, for $13.7376/day with one charged provider prompt per compose, before bandwidth/infrastructure. Existing composer retries permit up to two logical turns with two provider attempts each; at four charged prompts, the conservative incremental input-plus-read ceiling is $52.6176/day ($51.84 input +$0.7776 reads), without adding calls or changing retry policy. Zero additional LLM calls, embeddings, vector queries or external calendar calls. No claim of measured fleet latency, token growth or vendor bills. The corrected review census at 2026-11-15T06:00:05Z averaged 13.4 added reads/episode (maximum 27), yielding a sample-based read projection of $0.21708/day at the supplied volume and rate. This owner sample is not a fleet estimate; fleet-typical reads/tokens remain unmeasured.

Verification

  • Owner-only shape/coverage census: owner-default-context-review-counts.json, measured 2026-11-15T06:00:05Z, ro-prod, prescribed owner guard, counts only. Same 20 healthy episodes / 190 retained transcribed members, 2026-11-09 06:27:53Z–2026-11-14 06:58:58Z. Coverage: stored resolved people 11/20, calendar 0/20, prior shared-person discussion 0/20, related open actions 8/20, related open loops 0/20. Zero section failures or timeouts. Reads 268 total, mean13.4, max27; rendered blocks at most1286bytes in this sample. Account totals: 53 people, 50 meetings, 1035 actions, one live open loop. A separate projection-only census of all50 stored meetings found zero entries overlapping any of the20 episode intervals: calendar is correct but not useful for these recordings. Transcript-free prior matching uses manual identity receipts; it cannot recover automatic-only assignments from encrypted transcript text, and its owner coverage is now zero. This recall limitation is explicit; no new producer projection or index is introduced. Setup/member/calendar-validation reads455 plus five count aggregation queries are separate. The census does not run paid memory/vector retrieval, so combined live latency/recall remains unverified.
  • Production SDK query builders and autospec RPC mocks cover all four sections, independent errors/timeouts, full candidate-window and 48-read cap coverage, byte/character bounds, off parity, real nanosecond timestamps, canonical deletions, task resets and account scoping.
  • Final source head 0d8ccef0c87893d1fc4ee5f676b43c1f7add4203 includes summaries b417032dfa1a8 and main 65f46cce8306. 81 affected/importing files: 3508 passed, 3 skipped, 1 deselected. This includes42 default-context tests, cross-service deployment contracts33passed/3skipped, Firestore guards and receipt import closure. No new test CPU warning above0.1s. The exact installed pre-push hook passed end to end 2026-11-15T06:18:24Z: 55 manifest checks, canonical typecheck 0errors/84070warnings, and2160passing cases across overlapping hook phases. Explicit flag-budget count 295 equals len(names); feature registry/runtime outputs regenerated and runtime reproduction check passes. Provider type fixes match the merged sibling; local receipt conversion satisfies the production assignment signature. No guard changes, skip hatches, push, PR or deploy by this lane.

Rollback: set EPISODE_COMPOSER_DEFAULT_CONTEXT_ENABLED=false on composing hosts and roll the same image. This restores the previous context gather exactly and removes all added default-block reads/prompt text.

Review and measurement

One independent review round (GPT-6 Luna); its four findings (open-loop statuses from the store constant, action items linked to current members, whole-row truncation, prior-episode projection and time reservation) are fixed in this head. Measured read-only on the owner's last 20 healthy episodes: resolved people 11/20, open actions 8/20, calendar 0/20 (no stored meeting overlaps), prior discussion 0/20, open loops 0/20; 13.4 mean and 27 maximum reads; no section timeouts. Summaries base #25340 is merged (b101f96), so this diff is the default-context block only.

Author model: GPT-6.1 Sol; integrated by Claude Fable 5.2.

🤖 Generated with Claude Code

View guided diff

Git-on-my-level and others added 12 commits November 15, 2026 11:00
Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ction-time reservation

The People scope inventory lists the new read-only people lookup (no write, no generation
bump needed). The reservation test now starts with 2 s left, so it fails when the prior
section does not leave time for actions.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 473fffc into BasedHardware:main Nov 15, 2026
63 of 65 checks passed
Git-on-my-level added a commit that referenced this pull request Nov 15, 2026
…budgets on an injected clock

Two slow-suite guards went red on main with #25340 and #25368, which the pull requests'
own path-selected CI did not run:

- the direct-provider inventory did not list utils/llm/summary_embeddings.py (AsyncOpenAI,
  the non-gateway branch of the composer's single bounded embedding request);
- two context-budget tests handed production code a real-clock budget under 0.5 s.

The inventory entry states its gateway policy. Both tests now let the caller's whole budget
elapse on an injected clock while the provider call is still running, and assert the caller
returned before the provider finished. No production code changes.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 15, 2026
…es (#25372)

Two slow-suite guards are red on main since #25340 and #25368 merged.
This repairs both with test and inventory changes only; no production
code changes.

Failure-Class: none

## What was wrong

-
`test_llm_gateway_coverage_guardrails.py::test_direct_provider_usage_stays_inside_approved_boundaries`
reports `DirectUse(utils/llm/summary_embeddings.py, AsyncOpenAI)`: the
file added by #25340 was not in the direct-provider inventory.
-
`test_real_clock_budget_ratchet.py::test_no_new_tiny_real_clock_budgets`
rejects two tests that set `COMPOSER_CONTEXT_TIMEOUT_SECONDS` to 0.1 s
(#25340) and 0.04 s (#25368), real-clock budgets under the 0.5 s limit.

Both guards are marked slow and are selected by path, so the two pull
requests' own CI did not run them; other pull requests (#25314, #25131)
inherited the failures.

## The repair

- Inventory: `utils/llm/summary_embeddings.py` is registered with its
policy stated beside the entry. It is the composer's single bounded
embedding request for owner-memory retrieval. It enforces the
generated-compute budget and resolves the BYOK key before any IO, and
routes through the LLM gateway whenever gateway feature mode is on,
which is the production setting on backend, backend-sync and
backend-sync-backfill (`OMI_LLM_GATEWAY_FEATURE_MODE=gateway`, read from
the serving specs). The direct client is the non-gateway branch only:
same provider, key custody and model as `clients.py` `OpenAIEmbeddings`,
with SDK retries off and the caller's absolute deadline. It lives
outside `clients.py` so the notes routing digest and paid checkpoints
stay unchanged. Both branches are exercised with the real SDK in
`test_episode_summary_provider_bounds.py`. No gateway, BYOK or quota
path is bypassed.
- Tests: both context-budget tests now inject the clock and the
completion event of `composer_context_budget`, so the caller's whole
budget elapses deterministically while the provider call is still
running. They still assert the properties the originals covered: the
caller returns at the deadline and not when the non-cooperative provider
finishes, partial context is discarded, completed sections survive, late
results are never published, and the timeout fallback is recorded once.
The ratchet and its allowlist are unchanged.

## Verification

Both guards, the ratchet's stale-entry checks, the provider-bounds tests
and the two edited test files: 89 passed locally with slow tests
selected (`-m "slow or not slow"`). No tuning value, flag, state or
schema changes.

Rollback: revert this commit; main returns to the two red guards.

Author: Claude Fable 5.2.

🤖 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/25372?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="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Nov 15, 2026
…ch; admit each search and record why context falls back (#25379)

## Problem and behavior

Episode summaries discard all profile and memory context when the second
search starts after one second or the third search starts at all.
Independent single-attempt searches incorrectly share the list reader's
one-second/two-attempt retry-admission state. Production class-only logs
and a real-SDK regression reproduce `MemoryReadAdmissionDenied`.

Give each single-attempt logical search independent admission under the
original overall context deadline. Preserve the shared process
allowance, circuit, no-retry policy, and eight-second context bound. Add
one class-only fallback log with stage `budget`, `embedding`, `vector`,
or `hydrate`; never log provider messages or account/content
identifiers.

Failure-Class: new

New class: `FC-independent-searches-share-retry-admission`; reusable
regression drives real MemoryService, HTTPX and Pinecone 7.3.0 objects,
including name-based host discovery and isolated async transport. Only
HTTP responses, owner routing storage, and BYOK lookup are synthetic.

Tuning disclosure: single-attempt admission now uses the caller's
remaining context budget instead of the list retry window. No overall
budget, process allowance, retry count, model, or production setting
changes. Existing `EPISODE_COMPOSER_CONTEXT_ENABLED=false` is the
rollback lever; no new flags. All touched product Python files remain
below the 1500-line ratchet; no Line-Count-Exception is required.

Validation measured 2026-11-15T08:14:36Z: affected 15-file backend suite
green; required real-clock and gateway scans 38 passed; cross-service
deploy contract 33 passed, 3 skipped; canonical `bash
backend/scripts/typecheck.sh` zero errors. Additional owner-summary
retrieval coverage passed 16 tests. The installed pre-push hook passed
all 40 shared checks, canonical typecheck and 10 tests in its bounded
backend unit phase.

Runtime evidence: carrier `51b449ec` serves 100% of backend traffic and
predates default-context merge #25368, so zero default-context logs is
absence of deployed code, not successful collection. No production
account content was read. Tier `ro-prod` only.

Delivery: local lane commit only. No push, PR, merge, deploy, or
production mutation. The integration lead owns publication and serving
verification.

## Product invariants affected

- INV-MEM-1: retain MemoryService's canonical-first authority, hydration
and account scoping; the fix changes operation admission only.
- INV-MEM-4: preserve canonical lineage collapse, quality rejection and
projection authority; no intake, promotion, mutation or external write
is added.

Additional owner-summary retrieval suite: 16 passed. Product invariant
citations were validated by the installed hook, with no skip flags or
guard changes.

Final validation 2026-11-15T08:21:51Z: full installed pre-push hook
passed (40 shared checks, canonical typecheck, 10 bounded unit tests).
Local head `3e9c6a434ec3a0e0ae1a8fb8d2a9be248ee1be0c`. Detailed evidence
is in q12-u-retrieval-fix.md; no public CI or deployment is claimed.


Author model: GPT-6.1 Sol; integrated by Claude Fable 5.2.

🤖 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/25379?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="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.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