Skip to content

fix(backend): MCP search_conversations includes transcript hits + snippets (#6621) - #11198

Merged
kodjima33 merged 6 commits into
BasedHardware:mainfrom
aryanorastar:fix/6621-mcp-search-transcripts
Aug 10, 2026
Merged

kodjima33 merged 6 commits into
BasedHardware:mainfrom
aryanorastar:fix/6621-mcp-search-transcripts

Conversation

@aryanorastar

@aryanorastar aryanorastar commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes #6621: MCP search_conversations (REST + SSE) previously searched summary vectors only, so transcript-only phrases were unfindable.
  • Merges transcript-chunk Pinecone hits (search_transcript_chunks) with summary-vector hits (transcript-first), fail-open if chunk index is empty/down.
  • Returns match_snippets (grep-style context, segment_id, start/end + start_ms/end_ms) from hydrated transcript_segments.
  • Locked conversations never leak snippets (redact clears match_snippets; SSE skips snippets when locked).

Area ownership: retrieval / MCP conversation search (flagship slice; not Ratnam’s open #7421 lexical Typesense work).

Product invariants affected

none

How it was verified

  • pytest tests/unit/test_mcp_transcript_search.py tests/unit/test_mcp_search_conversations_poison.py tests/unit/test_mcp_search_date_utc.py → 19 passed
  • Honest gap: full semantic transcript recall still depends on TRANSCRIPT_CHUNK_INDEXING_ENABLED having indexed chunks; when the index is empty, summary hits still get lexical snippets when the phrase appears in hydrated segments.

Failure-Class

Failure-Class: none

Test plan

  • Unit: snippet extraction + id merge + fail-open chunk search
  • Unit: poison-page MCP search still skips malformed records
  • Unit: transcript-only chunk hit surfaces conversation with snippets
  • Unit: UTC date bounds still passed through to vector/chunk search
  • CI backend unit / Hygiene green

Review in cubic

…ppets

Summary vectors miss transcript-only phrases. Merge Pinecone transcript-chunk
hits into MCP REST/SSE search and return grep-style match_snippets (BasedHardware#6621).

Co-authored-by: Cursor <[email protected]>
@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.

Narrow Sequence[Any] typing on transcript search helpers and regenerate
app-client OpenAPI + TS clients so unit/contract CI match the new match_snippets field.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Pushed CI fix @ 24d401f202:

  • pyright: narrowed Sequence[Any] / _as_segment_dicts so isinstance checks are valid (reportUnnecessaryIsInstance / reportUnnecessaryComparison gone)
  • regenerated docs/api-reference/app-client-openapi.json + TS app-client clients for TranscriptMatchSnippet / match_snippets

Local: pytest focused MCP search suite → 19 passed; pyright on the helper → 0 errors.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread backend/routers/mcp.py Resolved
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

CI is green on the CI-fix tip (Backend unit + OpenAPI + hermetic gates). Author-side clear — ready for write-access review when you have a moment.

@Git-on-my-level — retrieval / MCP search_conversations transcript hits + match_snippets (#6621). Safe backend lane; honest gap in the PR body about optional chunk indexing.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for taking on the MCP transcript-search gap — the overall direction makes sense and the locked-row snippet handling is appreciated.

I need to request one fix before this is merge-ready:

  • search_conversations now forwards start_date / end_date bounds into transcript chunk search, but database.vector_db.search_transcript_chunks only applies created_at filtering when both bounds are present. For start-only or end-only MCP searches, transcript-chunk hits can therefore come from outside the requested date range, while summary-vector hits are still filtered correctly. This is a user-visible correctness/privacy-boundary issue for date-scoped conversation search.

Please update the transcript chunk filter to match query_vectors / _created_at_filter semantics for one-sided ranges as well, and add regression coverage that captures search_transcript_chunks kwargs for start-only, end-only, and both-bounds paths (REST and/or SSE as appropriate).

I also noticed the new path embeds the same query once for summary vectors and once for transcript chunks. That is worth tightening if the vector helper can share a query vector across namespaces, but the date-bound mismatch above is the blocking item.


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 needs-tests PR introduces logic that should be covered by tests needs-maintainer-review Needs a human maintainer to sign off before merge backend Backend Task (python) labels Aug 7, 2026
search_transcript_chunks only applied created_at when both bounds were set,
so start-only/end-only MCP searches could return out-of-range transcript hits.
Align with query_vectors via _created_at_filter, share one query embedding
across summary + chunk lookups, and add regression coverage.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

Thanks @Git-on-my-level — blocking date-bound mismatch fixed in ebcd0b2fc1.

Fix: search_transcript_chunks now uses the same _created_at_filter semantics as query_vectors (one-sided $gte / $lte, invalid range → empty, no embed).

Also tightened (your non-blocking note + cubic):

  • Shared query embedding across summary + transcript namespace lookups (query_vector / embed_query)
  • Regression tests: start-only / end-only / both-bounds kwargs capture on REST + SSE; vector_db filter shape for chunk search; non-contiguous multi-term snippet matching

Local (file-isolated): test_mcp_transcript_search 10 · test_mcp_search_date_utc 10 · test_mcp_search_conversations_poison 4 · test_action_item_dedup 17 — all pass.

Ready for re-pass when you have a moment.

Black-format action-item date-filter tests; bump mcp_sse line-count
baseline 1988→1989 for the transcript-search description; stub
resolve_mcp_conversation_search_ids in the SSE limit clamp test so the
shared-embed path does not hit live OpenAI encodings.

Failure-Class: none
Co-authored-by: Cursor <[email protected]>
@aryanorastar

aryanorastar commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator Author

CI was red on ebcd0b2fc1 after the date-bound tip — fixed on this push:

  1. Formatting — black 120 on test_action_item_dedup.py (date-filter + shared-vector coverage).
  2. Hygiene / line-count ratchet — mcp_sse.py baseline 1988→1989 (justification +21 for MCP: search_conversations should search transcripts (and return match snippets) #6621 transcript search).
  3. Backend unit — test_search_conversations_negative_limit_is_clamped now stubs resolve_mcp_conversation_search_ids (the shared-embed path was hitting live encode_ordinary). Date-UTC tests also stub vector_db.embeddings so they stay hermetic.

Per-file local: pagination 7 · date_utc 10 · transcript_search 10 · poison 4 · action_item_dedup 17 — all pass.

Ready for re-pass on the one-sided date-bound fix when CI is green.

@kodjima33 kodjima33 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.

MCP search_conversations transcript hits + snippets — reasonable fix; needs a rebase (conflicts with main).

…lict

Keep main's mcp_sse/sync cutover baselines and append the BasedHardware#6621
transcript-search justification; set mcp_sse line count to post-merge 2013.

Co-authored-by: Cursor <[email protected]>
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@Git-on-my-level @kodjima33 conflicts with main resolved on tip 10728fcb06:

Local: pytest transcript_search + poison + date_utc → 24 passed (one-sided date bounds + shared-embed coverage intact).

Prior David CR (one-sided search_transcript_chunks filters) was addressed on ebcd0b2 / 6806f30. Ready for CI re-check + dismiss stale CHANGES_REQUESTED when green. kodjima size-gate APPROVE already on file.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the follow-up fixes here — the previous date-bound blocker looks resolved on this head.

Review notes:

  • backend/database/vector_db.py now routes search_transcript_chunks through _created_at_filter, so start-only, end-only, both-bound, and invalid date ranges match the existing summary-vector behavior. The optional query_vector parameter also lets summary and transcript namespace searches share one embedding.
  • backend/utils/conversations/mcp_transcript_search.py keeps the search merge fail-open around transcript chunk lookup, dedupes transcript/summary conversation ids stably, and caps snippet output. The grep-style snippet builder is intentionally lexical evidence over already-hydrated segments, which is a good fit for explaining semantic hits without storing transcript text in Pinecone metadata.
  • backend/routers/mcp.py wires REST search_conversations through the merged resolver and attaches snippets only after list redaction, so locked rows keep match_snippets empty via backend/utils/conversations/render.py.
  • backend/routers/mcp_sse.py mirrors the resolver in the SSE tool path, updates the tool description, and explicitly skips snippet extraction for locked conversations before returning the simplified tool result.
  • The new/updated tests cover the important regression surfaces: chunk date filters in backend/tests/unit/test_action_item_dedup.py, REST/SSE UTC forwarding in backend/tests/unit/test_mcp_search_date_utc.py, transcript-only hits in backend/tests/unit/test_mcp_search_conversations_poison.py, and helper behavior in backend/tests/unit/test_mcp_transcript_search.py. The generated OpenAPI/types files (docs/api-reference/app-client-openapi.json, desktop/windows/src/renderer/src/lib/omiApi.generated.ts, and the web generated clients) consistently expose TranscriptMatchSnippet.

Validation I ran locally:

  • python -m pytest tests/unit/test_mcp_transcript_search.py tests/unit/test_mcp_search_conversations_poison.py tests/unit/test_mcp_search_date_utc.py tests/unit/test_action_item_dedup.py tests/unit/test_mcp_sse_pagination_bounds.py → 41 passed, then 7 failures in test_mcp_sse_pagination_bounds.py caused by test-harness module pollution from test_mcp_search_conversations_poison.py leaving broad sys.modules stubs behind.
  • python -m pytest tests/unit/test_mcp_sse_pagination_bounds.py -q → 7 passed.
  • python -m pytest tests/unit/test_mcp_search_date_utc.py tests/unit/test_mcp_sse_pagination_bounds.py -q → 17 passed.
  • python -m pytest tests/unit/test_action_item_dedup.py tests/unit/test_mcp_sse_pagination_bounds.py -q → 24 passed.

Given the code review, CI, and focused local validation, I do not see a remaining production-code blocker. I removed the stale needs-tests label and am leaving this for human maintainer review because it changes the conversation transcript evidence returned by the MCP/API search surface and should get maintainer sign-off before merge.


by AI on behalf of David — this PR changes a data-returning backend/API search surface, so maintainer sign-off is the right next step.

@Git-on-my-level Git-on-my-level removed the needs-tests PR introduces logic that should be covered by tests label Aug 8, 2026
@Git-on-my-level
Git-on-my-level dismissed their stale review August 8, 2026 21:19

Resolved on current head: transcript chunk search now uses the same one-sided/invalid date filtering semantics as summary vector search, with regression coverage.

@Git-on-my-level Git-on-my-level added the positive-signal Automation verified a genuine fix/quality contribution label Aug 8, 2026
@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin need human response — merge call for #11198 / #6621.

Head @10728fcb06 · APPROVED · MERGEABLE CLEAN · CI green · David dismissed the one-sided date-bound CR (positive-signal; no remaining production-code blocker).

Author-clear: MCP search_conversations merges transcript-chunk + summary hits, one-sided _created_at_filter parity, shared query embedding, locked rows never leak snippets. Honest gap unchanged — full semantic transcript recall still depends on chunk indexing being populated.

Please merge (or state hold) when ready — flagship retrieval/MCP surface.

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin need human response — merge call for #11198 / #6621.

Conflicts cleared on tip 54bb7ac6ddf0:

  • Sole conflict was backend-routers.json — set mcp_sse.py baseline to post-merge 2009 (+21 for MCP: search_conversations should search transcripts (and return match snippets) #6621 transcript search, matching the raise justification)
  • Local: test_mcp_transcript_search + poison + date_utc → 24 passed
  • David one-sided date-bound CR dismissed · positive-signal · your APPROVE stands
  • Honest gap unchanged: full semantic transcript recall still depends on chunk indexing being populated

CI re-running. Please merge when green (or state hold).

@Git-on-my-level

Copy link
Copy Markdown
Member

Thanks for resolving the conflict-only rebase on this head. I rechecked the current diff and I don’t see a new production-code blocker.

Review notes:

  • backend/database/vector_db.py now gives search_transcript_chunks the same _created_at_filter behavior as summary vector search, including start-only, end-only, both-bound, and invalid-range handling. Sharing query_vector also avoids embedding the same MCP query twice across summary and transcript namespaces.
  • backend/utils/conversations/mcp_transcript_search.py keeps transcript chunk lookup best-effort/fail-open, merges transcript and summary conversation ids stably, caps over-fetched chunk hits, and only builds snippets from hydrated transcript segments. That preserves existing summary search behavior if the transcript chunk index is unavailable.
  • backend/routers/mcp.py wires REST search_conversations through the shared resolver and validates returned conversations after snippet enrichment. Since redact_conversations_for_list only strips locked rows and backend/utils/conversations/render.py clears match_snippets for locked list rows, the added snippets should not expose locked transcript content.
  • backend/routers/mcp_sse.py mirrors the MCP tool path, including the updated tool description, shared resolver, and explicit locked-row skip before attaching snippets.
  • backend/tests/unit/test_mcp_transcript_search.py, backend/tests/unit/test_mcp_search_date_utc.py, backend/tests/unit/test_mcp_search_conversations_poison.py, backend/tests/unit/test_mcp_sse_pagination_bounds.py, and backend/tests/unit/test_action_item_dedup.py cover the main regression classes: transcript-only hits, snippet extraction, one-sided date bounds, invalid date filters, chunk-search fail-open, shared embedding reuse, and SSE limit clamping.
  • The generated API surfaces (docs/api-reference/app-client-openapi.json plus the generated TS clients under desktop/windows/..., web/admin/..., web/app/..., and web/personas-open-source/...) consistently expose the new TranscriptMatchSnippet schema and optional match_snippets field.

I’m leaving this as a positive signal rather than a formal approval because this is contributor code touching MCP conversation-search behavior and user transcript evidence. A human maintainer should make the final merge call for the MCP/user-data search behavior, but from this review the previous date-bound blocker appears resolved.

— Reviewed by Omi maintainer automation (gpt-5.5).


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

@aryanorastar

Copy link
Copy Markdown
Collaborator Author

@kodjima33 @beastoin need human response — merge call for #11198 / #6621.

Author-clear on 54bb7ac6dd:

  • APPROVED (kodjima33) + MERGEABLE CLEAN + all checks green (22 success)
  • David dismissed the one-sided date-bound CR; positive-signal; no remaining production-code blocker on latest recheck
  • MCP search_conversations merges transcript-chunk + summary hits, one-sided _created_at_filter parity, shared query embedding, locked rows never leak snippets
  • Honest gap unchanged: full semantic transcript recall still depends on chunk indexing being populated

Please merge when ready (or state an explicit hold).

@undivisible undivisible added human Human-authored pull request desktop labels Aug 10, 2026
@undivisible undivisible added web javascript JavaScript or TypeScript implementation work workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior labels Aug 10, 2026

@kodjima33 kodjima33 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.

4/5: fixes #6621 (transcript-only phrases unfindable in MCP search), fail-open merge of transcript-chunk hits, locked-conversation redaction covered, 19 unit tests, CI green.

@kodjima33
kodjima33 merged commit f51681d into BasedHardware:main Aug 10, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend Task (python) desktop human Human-authored pull request javascript JavaScript or TypeScript implementation work needs-maintainer-review Needs a human maintainer to sign off before merge positive-signal Automation verified a genuine fix/quality contribution web workflow-review Needs maintainer review for workflow, automation, hooks, or CI behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: search_conversations should search transcripts (and return match snippets)

4 participants