Skip to main content

Context Search

The Context view lets you search across all your sessions using either exact text matching or semantic (meaning-based) search. Results can be copied and injected into new coding prompts, used in RAG pipelines, or exported for analysis.

Search types

Matches exact terms against sessions.searchableText, which concatenates the session title with all message text content. Uses Convex’s built-in search indexes for fast, ranked results.
authentication middleware express
Returns sessions containing all three terms, ranked by relevance. Converts your query into a 1536-dimension vector using OpenAI’s text-embedding-3-small model and searches against the sessionEmbeddings table using cosine similarity.
how to handle OAuth callback errors
Returns sessions about authentication and error handling, even if they use different terminology.
Semantic search uses OpenAI embeddings. On self-hosted deployments, you need to set the OPENAI_API_KEY environment variable. On the hosted version, this is already configured.

How embeddings work

When a session is synced, OpenSync generates an embedding vector from the session’s searchable text. This vector is stored in the sessionEmbeddings table with:
FieldDescription
sessionIdReference to the session
embedding1536-dimension float array
textHashHash of the source text, used to skip re-embedding unchanged sessions
createdAtWhen the embedding was generated
Message-level embeddings are also generated for finer-grained search, stored in the messageEmbeddings table. Embeddings are generated asynchronously after session sync. There may be a brief delay before a newly synced session appears in semantic search results.

Using context search in the dashboard

1

Open the Context tab

Click Context in the sidebar navigation.
2

Choose search type

Toggle between Full-text and Semantic at the top of the search box.
3

Enter your query

Type keywords (for full-text) or a natural language question (for semantic).
4

Review results

Results show matched sessions ranked by relevance score. Each result includes a title, snippet, score, and link to the full session.
5

Copy context

Click Copy on any result to copy the relevant session content to your clipboard. Paste it into your next coding prompt for better context.

Using context search via API

Full-text

curl -X POST "https://polished-penguin-622.convex.site/search" \
  -H "Authorization: Bearer osk_your_key" \
  -H "Content-Type: application/json" \
  -d '{"query": "authentication middleware", "type": "fulltext", "limit": 10}'

Semantic

curl -X POST "https://polished-penguin-622.convex.site/search" \
  -H "Authorization: Bearer osk_your_key" \
  -H "Content-Type: application/json" \
  -d '{"query": "how to handle login errors", "type": "semantic", "limit": 10}'

Context endpoint (for RAG)

The dedicated /api/context endpoint returns results formatted for injection into LLM prompts:
curl "https://polished-penguin-622.convex.site/api/context?q=handle+auth+errors&limit=5" \
  -H "Authorization: Bearer osk_your_key"
Response:
{
  "context": [
    {
      "sessionId": "j57a...",
      "title": "Fix OAuth callback loop",
      "content": "The relevant conversation excerpt...",
      "score": 0.91
    }
  ]
}

Use cases

RAG pipelines

Inject past session knowledge into new prompts. When starting a new coding task, query the context API for relevant past sessions and include the results in your system prompt.

Knowledge retrieval

Find how you solved a specific problem before. Semantic search is especially useful here because you can describe the problem in your own words.

Team documentation

If your team shares an OpenSync instance (via self-hosting), search becomes a shared knowledge base of all coding sessions across the team.

Eval dataset curation

Use search to find sessions about specific topics, then mark them as eval-ready for export.

Tips

  • Be specific with full-text search. Use function names, library names, and error messages.
  • Be descriptive with semantic search. Ask questions as if you were talking to a colleague.
  • Combine search types. Start with semantic to find the general area, then use full-text to find exact matches.
  • Use source filters alongside search to narrow results to a specific tool.

Next steps