Embedding-based vector search flags suspicious AI agent sessions at a rate of one in seven
Semantic vector search of stored agent session embeddings can identify malicious or risky AI agent behavior more effectively than keyword search and at lower operational cost.
Security & privacy Elastic Security Labs 4 Nov 2026 Measurement Prototype evidence
Published as “Monitoring AI agent sessions: Leveraging embedding models to aid threat hunting and attack discovery workflows”
Why it matters
Embedding-based monitoring can reduce the volume of agent sessions analysts must read while improving detection of risky AI-driven actions.
Summary
The author embedded every turn of 399 Claude Code/Cursor sessions (7,454 turns) into Elasticsearch using a jina-embeddings-v5-text-small model, separating user, reasoning, agent and tool channels. He then ran three query styles-descriptive, instructive and exemplar retrieval-against the vectors and compared recall (MRR) to traditional BM25 keyword search. Vector search consistently outperformed keyword search across all channels, and one in seven sessions were flagged as needing human review, with the reasoning channel providing the strongest signal. The evidence is based on a self-labeled dataset and a limited, single-user workload, so generalizability is uncertain.
What they found 3
- One in seven agent sessions required triage after vector search.
“One in seven sessions came back requiring triage of suspicious actions.”
- Vector search outperforms keyword (BM25) search on all four channels.
“Vector wins outright against our normalized dataset.”
- Credential-access techniques were perfectly recovered (MRR = 1.0) while discovery techniques were not found.
“Credential access is the one place where the question and the ground truth line up.”
Caveats 6
- Vector and keyword (BM25) scores are close, indicating only a modest advantage.
- Embedding models are generic; jina-embeddings-v5-text-small has never seen agent transcripts, which may limit recall.
- Evaluation uses only the author’s own Claude Code and Cursor sessions, not a multi-tenant dataset.
- Ground-truth labels were generated by an LLM rather than manual review, which may introduce labeling bias.
- Results depend on the specific embedding model (jina-embeddings-v5-text-small) and may differ with other models.
- The MITRE ATLAS question set was built by the author and may not cover all real-world techniques.
What’s new here 4
- Demonstrates end-to-end ingestion of AI agent turns as per-channel vectors in Elastic.
- Compares three semantic query styles and shows exemplar retrieval yields the highest recall.
- Provides a quantitative cost model for storing and querying hundreds of millions of vectors.
- Shows that the agent reasoning channel carries more detection signal than the user channel.