Let me fetch that article and check how embeddings are used in the codebase.
Assistant
The article didn't render well and the codebase searches hit a path issue. Let me fix both.
Assistant
User
but if we use time based changes instead of vector search, how would an agent know of a relevant decision that was made 2 weeks ago by another agent?
Assistant
User
so maybe the observer should be extended to also check workspace decisions and link cross project
Assistant
Exactly. That's the architecturally correct solution for Brain — turn a runtime search problem into a background graph enrichment problem.
Right now the Observer scans for contradictions. Extending it to also link related decisions across projects means:
Observer finds "use PostgreSQL for billing" (Project A) and "choosing storage for analytics" (Project B)
Creates a relates_to edge (or observation linking both) with reasoning: "Both decisions concern data storage technology selection"
Next time an agent loads context for Project B, the link is there via graph traversal
Great question. Having read the article and mapped it against your actual embedding usage — you're already 80% of the way to not needing embeddings, and the remaining 20% is questionable.
The irony
The article's top recommended alternative to embeddings is GraphRAG — structured knowledge graph retrieval. Brain is a knowledge graph. Your entities have typed relationships (task→belongs_to→feature→belongs_to→project), structured metadata, and graph traversal queries. You're not searching unstructured document chunks — you're searching a schema-full graph with 18+ entity types.
Where embeddings are used today
Use case
How it works
Do you need embeddings?
UI entity search
BM25 fulltext
Already embedding-free
Chat agent search_entities
Loads 120-200 candidates, cosine similarity in app code
No — BM25 + graph traversal. The agent already has get_entity_detail, get_project_status for structured lookup
Proxy context injection
KNN for recent changes relevant to coding intent
Maybe — but the intent already has workspace + project scope. BM25 on recent changes within scope would likely suffice
Learning loader precedent
KNN with 0.70 threshold
Questionable — learnings have learning_type, target_agents, priority. Structured filters + BM25 on text
Objective alignment
KNN to match intent→objective
Questionable — objectives are few per workspace. LLM reranking or even BM25 on title/description
The costs you're paying
18 HNSW indexes on every entity type — storage and write overhead on every mutation
Embedding API calls on every message — persistEmbeddings() embeds every extracted entity. You literally just had to increase the timeout to 60s because it was failing in CI
Embedding dimension coupling — EMBEDDING_DIMENSION=1536 baked into schema, migration required to change models
search_entities doesn't even use KNN — it loads all candidates into memory and scores in JS (queries.ts:713-945)
What I'd recommend
Phase 1: Stop generating embeddings for entities. The chat agent's search_entities tool could use BM25 (you already have fulltext indexes on every entity type). For multi-hop questions ("what's blocking the auth feature?"), graph traversal is strictly superior to cosine similarity.
Phase 2: Replace proxy context injection KNN with scoped BM25 + recency. The context injector already filters by workspace and updated_at > last_request_at. BM25 within that scope, ranked by recency * relevance, would be equivalent.
Phase 3: Replace learning/objective matching with BM25 + structured filters. These are small result sets where structured metadata (status, type, agents) does most of the filtering. BM25 on the text field handles the rest.
Phase 4: Drop HNSW indexes and embedding fields from schema. One migration.
The article's strongest point applies directly: "achieving 85% recall might require 7 results from embeddings vs 8 from BM25 — this is insignificant considering the cost of maintaining a vector database and embedding service." And that's for unstructured documents. Your data is structured — the gap is even smaller.
The one place I'd keep an eye on is if you eventually need cross-workspace or cross-project semantic discovery where no graph path exists. But that's a future problem, and you could add embeddings back surgically for that single use case.
Want me to scope out what a migration plan would look like?
That's the right challenge. Let me break down the actual retrieval paths for that scenario.
How a 2-week-old decision reaches an agent today
There are three distinct retrieval paths, only one of which relies on embeddings:
1. Graph traversal (already works, no embeddings)
If the decision is linked to the same project/feature the agent is working on, it's reachable via edges:
This is how get_project_status and buildChatContext() already work — they load decisions for the current project regardless of age. This covers the majority of cases because decisions are linked to the project where they were made.
2. BM25 keyword match (already works, no embeddings)
If an agent searches for "API protocol" and the decision says "standardize on tRPC", BM25 with stemming catches "API" overlap. Won't catch pure semantic matches with zero keyword overlap, but those are rarer than you'd think in a domain-specific workspace.
3. Cross-project semantic discovery (the actual gap)
A decision in Project A ("use PostgreSQL for billing") is relevant to an agent in Project B designing analytics storage. No graph edge connects them. No keyword overlap. Only semantic similarity would find it.
How big is that gap really?
In practice, small — for two reasons specific to Brain's architecture:
Workspaces are bounded. A workspace typically has dozens to low hundreds of confirmed decisions, not millions of documents. You could load all active decisions into a context budget scan without any search at all:
sql
SELECT id, summary, status, rationale
FROM decision
WHERE workspace = $ws AND status IN ['confirmed', 'proposed']
ORDER BY updated_at DESC;
At ~100 tokens per decision, 200 decisions = 20K tokens. That fits in a context budget window. No search needed — just load and let the LLM reason over them.
The Observer already does cross-cutting scans. Its entire job is detecting contradictions and patterns across the graph. When it finds that Project B's storage approach conflicts with Project A's PostgreSQL decision, it creates an observation linking them. That observation is the graph edge that makes it traversable for future agents.
What I'd actually propose
Instead of embeddings for cross-project discovery, lean into what Brain already does:
Need
Current (embeddings)
Alternative
Same-project decisions
KNN (overkill)
Graph traversal — already works
Keyword-matchable
KNN (overkill)
BM25 — already have indexes
Cross-project semantic
KNN (legitimate)
Load all workspace decisions into context budget. LLM reasons over them directly
Cross-cutting contradictions
KNN (weak — only finds similar, not contradictory)
Observer scans — already purpose-built for this
The "load all decisions" approach is actually better than KNN for this case — embeddings find the most similar decision, but the relevant one might be contradictory (low cosine similarity) rather than similar. The Observer + LLM reasoning catches both.
The one scenario where this breaks down is if a workspace scales to thousands of active decisions where you can't fit them all in context. At that point you'd want search — but BM25 with LLM-generated query expansion (agent generates 3-4 keyword variants) would still get you most of the way there before reaching for embeddings.
So the honest answer: embeddings solve a real problem, but it's a problem Brain's graph structure and Observer pattern already address through different (arguably better) mechanisms. The gap is narrow enough that you'd be removing significant complexity for a marginal loss in one edge case.
Why this is better than embeddings:
Auditable — the edge carries the Observer's reasoning for why they're related, not just a similarity score
Catches contradictions AND alignments — embeddings only find similarity. The Observer can distinguish "these agree" from "these conflict"
Proactive — the link exists before any agent needs it, not computed at query time
Graph gets smarter over time — every Observer scan enriches the connectivity. Embeddings are stateless
What the scan would look like:
The Observer already loads workspace decisions. The new scan type would be something like "cross-project decision coherence" — for each unlinked decision, check if decisions in other projects within the same workspace share domain overlap. When found, create an edge with metadata (relationship type: aligns_with, conflicts_with, supersedes, relates_to).
This also plays into the existing observation→suggestion→learning pipeline. A cross-project link that reveals a contradiction becomes an observation, which can become a suggestion ("consolidate these into a workspace-wide policy"), which can become a learning.
That closes the semantic discovery gap while actually making the graph more valuable — which embeddings never did. They were a parallel retrieval path that bypassed the graph rather than enriching it.