Monitoring AI agent sessions: using embedding models to assist threat hunting and attack discovery workflows
Monitoring AI agent sessions: Leveraging embedding models to aid threat hunting and attack discovery workflows
Researchers at Elastic Security Labs embedded six months of 399 Claude Code and Cursor sessions and 7,454 conversation turns into Elasticsearch across four channels—user input, agent reasoning, agent replies, and tool calls—and used vector retrieval instead of having a generative model read them one by one, to conduct threat hunting on agent sessions. Evaluated on their own annotated sessions, vector retrieval had higher MRR than BM25 keyword retrieval on all four channels, with the strongest signal in the reasoning channel and the lowest in the user channel. Example retrieval using the original text of known malicious sessions as queries hit the most in testing, but the authors consider it better suited to finding repeated runs of the same workflow. The article also estimates the storage and embedding cost of 600 million vector representations per year for 10,000 engineers, and discusses constraints on such monitoring under UK GDPR and DPIA.