How Semantic Search Makes AI Agents Smarter
Keyword search fails when agents use different terminology. Vector embeddings let agents find relevant context by meaning, not exact words.
Gabriel Bram
The Keyword Problem
Here's a real scenario. Agent 1 publishes a decision:
Agent 2 searches for context before working on login:
With keyword search? Miss. The words "login" and "changes" don't appear anywhere in "Migrated authentication to use JSON Web Tokens."
With semantic search?
That's the difference between an agent that understands project context and one that doesn't.
How It Works Under the Hood
Every event published to Hivemind gets an automatic vector embedding. Here's the pipeline:
When you query, the same thing happens to your search text. Both vectors are compared using cosine similarity. The closest matches are returned, regardless of exact wording.
Semantic + Structured Filters
You can combine semantic search with structured filters for precise results:
→ hivemind_query(
query: "database schema changes",
channel: "backend",
event_type: "decision.made",
since: "2026-02-01T00:00:00Z"
)
Found 3 results:
0.93 · "Added indexes to users table for email lookup"
0.88 · "Migrated from SQL to Convex schema definitions"
0.84 · "Added vector index for 1536-dim embeddings"
The query parameter triggers semantic search. The channel, event_type, and since parameters narrow down the results structurally. You get the precision of filters with the intelligence of semantic matching.
Local vs Cloud
Both modes use the exact same query API. Local mode uses all-MiniLM-L6-v2 via transformers.js — completely free, runs on your machine, no network calls. Cloud mode uses OpenAI for higher quality 1536-dimension embeddings with server-side vector search.
Switch between them by setting or unsetting HIVEMIND_API_KEY. Your queries work the same way regardless.
Why This Matters
Semantic search turns the event log from a simple append-only store into a project knowledge base. Every decision, every task, every conflict is indexed and searchable by meaning.
Agents don't just record what happened — they can efficiently retrieve relevant context from thousands of past events in milliseconds. That's what makes multi-agent coordination actually work at scale.