DEV Community

Reducing AI Context Waste in Obsidian with Local Retrieval

When working with AI assistants and a large knowledge base, one recurring problem is context waste.

You have a set of notes, some of them relevant, many of them only loosely related, and the easiest thing to do is often to paste too much context into the model.

That creates a few problems:

  • token usage grows quickly
  • prompts become harder to inspect
  • the assistant receives irrelevant information
  • important notes can still be missed
  • the workflow depends too much on manual searching

I wanted to explore a local-first approach to this problem inside Obsidian.

The result is Context Prism, an open-source Obsidian plugin that creates token-aware context packs from related notes.

Community Directory: https://community.obsidian.md/plugins/context-prism

GitHub: https://github.com/stefanimp/context-prism

The idea

Instead of asking an AI assistant to inspect a large vault, Context Prism does the first retrieval step locally.

The active note becomes the query. The plugin ranks related notes in the vault and creates a compact Markdown context pack containing:

  • note paths
  • focused snippets
  • ranking reasons
  • rough token estimates
  • estimated avoided context

That context pack can then be pasted into ChatGPT, Claude, Codex, Cursor, or any other assistant before asking for analysis, writing help, planning, or implementation work.

The goal is not to replace the assistant. The goal is to give it a smaller and more relevant starting point.

Why local-first matters

For this kind of tool, privacy and predictability are important.

Context Prism does not call external APIs, does not send note content anywhere, and does not require an embedding service. It reads Markdown files through the Obsidian plugin API and builds the ranking locally.

That design has tradeoffs. Local lexical retrieval is not as semantically powerful as embedding-based search, but it is fast, explainable, cheap to run, and easier to trust.

For a note-taking workflow, those properties matter.

Ranking approach

The current ranking system combines several lightweight signals:

  • TF-IDF cosine similarity
  • BM25-style lexical scoring
  • title and alias matches
  • heading matches
  • configurable metadata weighting
  • folder include/exclude filters
  • multilingual stopword profiles

Each candidate includes a short explanation of why it was selected. This is important because retrieval tools should not behave like a black box. If a note appears in the pack, the user should be able to understand why.

Multilingual vaults

Many real vaults are not purely English. Mine are not either.

Context Prism supports multiple language profiles, including:

  • English
  • Spanish
  • French
  • German
  • Italian
  • Portuguese
  • multilingual mode

The multilingual layer is still lexical. It does not translate notes and it does not use semantic embeddings. The goal is to reduce obvious noise from common words and make mixed-language vaults more usable.

Token-aware context packs

The context pack includes rough token estimates.

This is not meant to be a perfect tokenizer for every model. It is a practical approximation that helps answer a simple question:

Am I about to paste a small focused pack, or a huge amount of unnecessary context?

In AI workflows, that distinction matters.

Manual linking is still useful

Although the main use case is AI context routing, Context Prism also includes a manual link review workflow.

You can review suggested related notes and insert selected wiki-links into the current note. This keeps the plugin useful even when you are not working with an AI assistant.

What I learned

Building this made me think more carefully about retrieval quality.

The hard part is not just finding notes with shared words. The hard part is ranking notes that are actually useful for the user's next action.

Some notes are short index notes. Some have generic templates. Some share metadata but not meaning. Some relevant notes mention the active topic without using the exact same wording.

This makes retrieval a product problem as much as an algorithmic one.

What I want feedback on

I am especially interested in feedback from people who use Obsidian together with AI assistants.

Useful feedback would be:

  • Does it surface the notes you would have copied manually?
  • Does it miss important context?
  • Are irrelevant notes ranked too high?
  • Are the snippets useful enough for the assistant?
  • Are the token estimates understandable?
  • What settings would make retrieval easier to tune?

Synthetic or redacted examples are ideal, especially for ranking problems.

Links

Community Directory: https://community.obsidian.md/plugins/context-prism

GitHub: https://github.com/stefanimp/context-prism

If you try it, I would really appreciate feedback through GitHub Issues or comments.

Top comments (1)

Collapse
 
stefanimp profile image
Stefan Giovanni Imperato Lozano

I’m especially interested in retrieval-quality feedback: cases where the plugin misses an important note, ranks irrelevant notes too high, or produces snippets that are not useful enough for an AI assistant.