Skip to content

feat(mcp): conversation deletion feed for agents that keep copies - #25524

Merged
Git-on-my-level merged 8 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/mcp-deletions
Nov 16, 2026
Merged

Git-on-my-level merged 8 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/mcp-deletions

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Why

Agents that keep a copy of the user's Omi conversations (assistants that sync Omi into their own knowledge repositories) cannot learn what the user deleted. Conversations have no truthful updated_since feed: their updated_at is document metadata, and generic writes do not store it. That gate stays, and so does its 400.

Deletions, though, are already recorded durably. Every user deletion writes a content-free tombstone to users/{uid}/deleted_conversations with a real deleted_at. Nothing read those tombstones by time, so deleted conversations lived on in agents' copies.

What changes

  • backend/database/conversation_deletion_feed.py pages the tombstones in (deleted_at ASC, __name__ ASC) order. It uses the action-item sync feed's keyset contract: limit + 1 lookahead, resuming at the last emitted row. It selects deleted_at only. Tombstones without deleted_at cannot be ordered and are not listed.
  • New MCP tool get_deleted_conversations (conversations.read, read-only) takes deleted_since, limit (1-500, default 100) and cursor, and returns {deleted: [{id, deleted_at}], has_more, next_cursor}.
  • New REST route GET /v1/mcp/conversations/deleted?deleted_since=&limit=&cursor= returns an array body, with paging in X-Next-Cursor, like the other REST sync surfaces. It is declared before /v1/mcp/conversations/{conversation_id}, so deleted is never read as an id.
  • deleted_since must carry a timezone offset and is inclusive. Removal is idempotent, so repeating rows at the boundary is harmless. Cursors are bound to deleted_since.
  • The conversations updated_since 400 now points at the deletion feed, and backend/docs/mcp-rest-sync.md documents the contract.
  • The route is declared in backend/route_policy_manifest.yaml (mcp_api_key, conversations.read, the mcp:read rate limit). The app-client OpenAPI and the generated desktop Swift DTOs are regenerated for it.
  • The Firestore query driver registry declares the new query. Ordering on one field plus __name__ is served by Firestore's automatic single-field index, as with the action-item feed. test_firestore_query_shapes.py passes, 600 tests.

Tests

New backend/tests/unit/test_mcp_conversation_deletions.py, 9 cases, over an in-memory Firestore that applies the feed's where, order, start-after and limit:

  • every deletion is walked once, in order, across equal timestamps and pages;
  • deleted_since is inclusive, and tombstones without a time never appear;
  • rows carry only the id and the watermark;
  • a cursor is bound to its deleted_since;
  • naive or malformed watermarks are rejected;
  • the REST route returns an array with the cursor in X-Next-Cursor;
  • the updated_since gate points at the feed.

Wire output is validated against the advertised output schema. 61 related backend unit files pass through test.sh, including every test_mcp_*.py, the Firestore query-shape guards and the delete-accept tests.

Release

Default-on. The change is additive: a read-only tool and a route over data that already exists. Rollback is reverting this PR.

Not verified: production latency. The route reads at most limit + 1 tombstone documents, deleted_at only.

UI-Evidence: none -- the only desktop change is the regenerated OpenAPI DTO file; no screen changes

Failure-Class: none

🤖 Generated with Claude Code

View guided diff

Git-on-my-level and others added 6 commits November 17, 2026 01:03
Agents syncing Omi into their own store could not learn what the user
deleted: conversations have no truthful updated_since, and nothing read the
durable tombstones by time.

- database/conversation_deletion_feed.py pages users/{uid}/deleted_conversations
  in (deleted_at ASC, __name__ ASC) order with the action-item feed's keyset
  contract (limit+1 lookahead, resume at the last emitted row), selecting
  deleted_at only.
- MCP tool get_deleted_conversations (conversations.read) and REST
  GET /v1/mcp/conversations/deleted?deleted_since= (array body, X-Next-Cursor),
  declared before the {conversation_id} route. deleted_since is inclusive and
  must carry an offset; cursors are bound to it.
- The conversations updated_since 400 now points at the deletion feed;
  mcp-rest-sync.md documents the contract.

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

mintlify Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 4a30149.

Approve preview

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T19:41:43.390516Z 4a30149 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b647daca71

ℹ️ 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".

Comment thread backend/utils/mcp_server/registry.py Resolved
Git-on-my-level and others added 2 commits November 17, 2026 02:18
Always range-filter deleted_at so explicit-null tombstones never surface;
REST limit is Query(ge=1, le=500); item schema requires id and deleted_at.
Docs and tool description state the watermark-minus-60s overlap and that
merge-absorbed sources are not listed, with the not_found reconcile path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	backend/utils/mcp_server/registry.py
#	docs/doc/developer/mcp/tools.mdx
@Git-on-my-level
Git-on-my-level merged commit 46cabc1 into BasedHardware:main Nov 16, 2026
57 checks passed
Git-on-my-level added a commit to Git-on-my-level/omi that referenced this pull request Nov 16, 2026
Git-on-my-level added a commit that referenced this pull request Nov 16, 2026
…e on open, keep location (#25529)

# Conversations v3 follow-up: stub-proof playback check, custom-STT
allowance on open, keep location

Failure-Class: none

Three small fixes, plus a regenerated-client catch-up, that came after
#25500 was approved. #25500 merged at its approved head, and this PR
lands them on top.

- **Backend unit shard 5 is green again.** #25500 imported a shared
`has_recording_pieces` helper from
`utils/conversations/layer.py` into the playback, sync and
plugin-backup-audio paths. Shard 5 replaces
`utils.conversations` with a stub in `sys.modules`, so that import
failed with
`ModuleNotFoundError: utils.conversations.layer`. Each caller now checks
`conversation.get('recording_pieces') is not None` itself, and the
shared helper is removed.
- **On-open summaries respect the custom-STT allowance.** A derived
conversation whose recordings used
custom STT now goes through the same
`should_skip_omi_paid_postprocessing` check as the background
path before `/summary/stream` writes notes. Before this fix, opening the
conversation could bill a
  summary that the background path had refused.
- **Derived conversations keep their location.** `planner.build()`
copies `geolocation` from the
existing row, or else from the first contributing recording, so a v3 row
keeps the place shown on its
  recordings.
- **Generated API clients are current again.** #25500 and #25524 landed
together, and main's TypeScript and
Swift clients still counted 553 methods instead of 554, which failed the
OpenAPI check on every push.
They are regenerated in a separate commit; only the total lines change.

## Verification

- `tests/unit/test_conversations_v3_engine.py` and
`tests/unit/test_conversations_v3_stream.py` have new
  cases for the location and the custom-STT refusal.
- The shard-5 file set and the full pre-push backend unit suite ran on
push.

UI-Evidence: none -- backend only

🤖 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/25529?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>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25529?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25529&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit to Git-on-my-level/omi that referenced this pull request Nov 16, 2026
…5500 and BasedHardware#25524 landed together

Main's generated TypeScript and Swift clients counted 553 methods; the merged routes make 554.
Regenerated with backend/scripts/generate_ts_openapi_types.py and generate_swift_openapi_types.py;
only the total lines change.

Failure-Class: none

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit to Git-on-my-level/omi that referenced this pull request Nov 16, 2026
…snippet window

Matching gets 2s after the 4s scan (chat's 6s overall) and resumes after the
last finished record; unreadable records record a degraded fallback; a long
segment is clipped around the shortest stretch holding every query word.
Developer changelog entries for BasedHardware#25497, BasedHardware#25524 and this PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 16, 2026
…25527)

* feat(mcp): outline-first, offset and lines reads, and conversation state on cards

Builds on transcript paging (#25491) so an agent can read a long conversation
the way a person skims one, without loading the whole transcript first.

- view=outline returns the card plus the stored note sections, each anchored
  to the segment range it cites (first_segment, segment_count, start, end),
  and no transcript.
- offset starts a transcript read at a segment index, such as a section's
  first_segment; the cursor then continues it (a resent offset is ignored).
- format=lines renders a page as one "[h:mm:ss] Speaker: text" line per speaker
  turn with transcript_range, about a third of the size of the per-segment JSON;
  the cursor is bound to the format. Also on get_conversations_by_ids.
- Cards carry status and duration_seconds, plus kind, shown_on_home and
  summary_covers_through where stored, so agents can tell live conversations,
  media and other people's background talk from the user's own.
- Tool descriptions and server instructions say to start long conversations
  with the outline, prefer lines, and treat transcript text as quoted content,
  never instructions.
- omi_mcp_transcript_pages_total counts detail pages by tool, view, format,
  position and whether more remain, so paging can be measured.

Defaults are unchanged: transcript view, JSON segments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): bound outlines, honest card duration, and one card per detail read

Review follow-ups on the progressive-reads commit:

- view=outline returns at most 100 sections, reports sections_truncated, and
  checks the 120k serialized budget like transcript pages.
- duration_seconds is the transcript's speech span: null on list and search
  cards, which load no transcript, instead of the wall window, which can start
  long before speech.
- summary_covers_through is localized like the other card timestamps.
- The default format adds nothing to the detail cursor fingerprint, so cursors
  minted before format existed still decode during a rolling deploy.
- offset is ignored, not parsed, when a cursor is given; negative, malformed or
  oversized offsets are argument errors rather than clamped.
- The page counter's position=first means "no cursor sent", so an offset read
  from the outline counts as a first page.
- The detail card is built once per request rather than on every
  budget-fitting retry. The 1,200-segment walk test uses about 0.27s of CPU
  instead of 0.43s, well inside the 1.0s per-test limit that CI shard 5 hit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): lines page what they render, split same-label speakers, full outline windows

Codex review follow-ups on #25497:

- format=lines pages over text only. original_text is not rendered, so a page
  boundary inside it produced continuation pages with no speech.
- Lines join turns on speaker_key, not the display label, so two people who
  share a name (or two unresolved speakers) stay on separate lines.
- An outline section's start/end span every cited segment (min start, max end),
  since cited segments can overlap or be stored out of time order.
- transcript_range is always present on lines pages and null when the page is
  empty, so fields=[transcript, transcript_range] works at the end of a read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(mcp): hybrid conversation search with match_basis, and literal search_transcripts

Agents asking about something said in passing found nothing: MCP search read
summary vectors only, and the keyword index ran only when vectors returned
zero rows, so one semantic hit hid every exact title or overview match.
Two-hour v3 conversations make summaries leave out more detail.

search_conversations:
- asks summary vectors and the keyword index (titles, overviews) on every
  call; shared hits rank first, then the two indexes alternate, so neither
  crowds the other out. Stale ids get one bounded second hydration.
- each card carries match_basis (summary, keyword, transcript); only
  match_snippets quote the transcript, and each snippet carries segment_index,
  the get_conversation_by_id offset to read around it.
- search_coverage names what actually ran (summary_vectors_and_keyword,
  summary_vectors_only, keyword_only) plus unavailable_indexes; one index
  down still answers. No hits with the keyword index down stays a 503.

search_transcripts (new, conversations.read):
- literal words or a short phrase in saved transcripts, newest first, over
  the bounded owner/query-bound scan chat transcript recall already uses (no
  derived index, 50 records and 4s per call, signed cursor resuming after the
  last record examined).
- optional conversation_id finds where something was said in one long
  conversation; hits carry segment_index, speaker and time.
- locked, discarded, deferred and unreadable records are never quoted;
  misses are never presented as absence.

The developer search route reports the same truthful coverage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): lines join turns only when speaker key and label both match

A segment-only speaker correction leaves adjacent rows with one diarization
key but different resolved labels; joining on the key alone attributed an
unassigned speaker's words to the user.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): transcript-free detail records keep their wall-window duration

A loaded detail with no transcript (a photo-only capture) reported a null
duration; use the shared conversation_duration_seconds wherever the
transcript is loaded, and keep list cards null.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(mcp): task-shaped agent journeys across the read tools

Four journeys chain real tool calls the way an agent would (search ->
outline -> section in lines; literal transcript hit -> read around it; a
whole long conversation by cursor; a day listing that tells media from
conversation, then a batch read) and validate every response against its
output schema and the serialized budget, so a tool that stops leading to the
next one breaks a journey.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): type the transcript hit card's structured dict for pyright

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): search fallbacks and literal matching per panel review

A summary-vector index still building is one index down: keyword search
still answers, and the index error returns only when both are down.
search_transcripts rejects dates with conversation_id (it searches the whole
conversation). A one-letter query word must appear as a word in the segment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): bound search_transcripts by serialized size; count keyword-down fallbacks

A page of large (or escaped CJK) hits stops before the 120000-character
serialized budget and resumes at the first conversation it left out.
Keyword or vector index loss now records the degraded fallback even when
other hits survive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(openapi): regenerate client method totals after #25524 and #25500

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): full stale-id backfill, deferred check on scoped reads, legacy segment index

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): transcript search deadline, unreadable fallback, all-words snippet window

Matching gets 2s after the 4s scan (chat's 6s overall) and resumes after the
last finished record; unreadable records record a degraded fallback; a long
segment is clipped around the shortest stretch holding every query word.
Developer changelog entries for #25497, #25524 and this PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(mcp): report an unconfigured vector index and unreadable records as partial coverage

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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