Back to Blog
Technical

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.

GB

Gabriel Bram

February 18, 20267 min read

The Keyword Problem

Here's a real scenario. Agent 1 publishes a decision:

decision.made · backend
"Migrated authentication to use JSON Web Tokens"

Agent 2 searches for context before working on login:

hivemind_query(query: "login changes")

With keyword search? Miss. The words "login" and "changes" don't appear anywhere in "Migrated authentication to use JSON Web Tokens."

With semantic search?

Match found 0.91 similarity
"Migrated authentication to use JSON Web Tokens"
The model understands that "login" relates to "authentication" by meaning

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:

Agent publishes event
"Switched to JWT auth"
OpenAI text-embedding-3-small
[0.023, -0.041, 0.087, ... ] (1536 dims)
Stored in vector index
Searchable by cosine similarity

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:

Combined query
 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

💻
Local Mode
Model: all-MiniLM-L6-v2
Dimensions: 384
Runs on: your machine
Cost: free
Setup: none (default)
Cloud Mode
Model: text-embedding-3-small
Dimensions: 1536
Runs on: OpenAI + Convex
Cost: included in plan
Setup: set HIVEMIND_API_KEY

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.

semantic-searchembeddingsvector-search