A coding agent can read a customer export and push it to a repository while each individual tool call looks permitted. Elastic Security Labs researcher Marcus Jeffes tested a way to find that kind of session: turn-level vector searches across six months of his own Claude Code and Cursor activity. His evaluation covered 399 sessions and 7,454 turns. A labeling model marked 56 of the 368 real sessions for review, roughly one in seven. Those are review decisions in one researcher’s environment, not confirmed breaches.

For a team running coding agents against company files and repositories, the problem is the sequence. An allowed file read followed by an allowed repository push can still move data to the wrong place. Jeffes uses the customer-export example to show why a rule on either action alone can miss the work the agent carried out. The researcher is evaluating Elastic’s own search stack. Use locally labeled sessions to establish a baseline for your environment.

A short turn gets buried

Jeffes split each agent turn into up to four searchable channels: user prompt, agent reasoning, agent response and tool call. He embedded each channel separately, searched each with language appropriate to that channel, and fused the four ranked lists with reciprocal rank fusion. A session takes the score of its highest-ranked turn. As he puts it, “Each session then scores as its best turn.” This keeps a brief risky action visible amid hours of ordinary build work.

A vector search ranks similarity; it does not decide whether a matched session violated policy. Write the hunt in the language of the turn you want to retrieve. Searching for an instruction to find exfiltration tends to retrieve talk about exfiltration. Describe an action that might appear in an actual turn instead, or search with the text of a confirmed case to find repeat runs of that workflow. Keep exact-match queries for literal commands, paths and remote URLs.

The strongest channel may be missing

On Jeffes’s real-session test, vector search beat keyword search in mean reciprocal rank for each channel: user prompt 0.212 versus 0.136; reasoning 0.339 versus 0.190; agent response 0.266 versus 0.195; tool calls 0.318 versus 0.195. Mean reciprocal rank rewards placing a review-worthy case high in the results. These results measure this labeled corpus and query set. Test retrieval with your own sessions before setting a review threshold.

Reasoning carried the strongest signal in this experiment, but Anthropic’s Claude Code telemetry settings expose prompts, assistant responses and tool details through separate content controls. OTEL_LOG_USER_PROMPTS, OTEL_LOG_ASSISTANT_RESPONSES and OTEL_LOG_TOOL_DETAILS are disabled by default or require explicit enablement for content, and tool output has its own tracing control, OTEL_LOG_TOOL_CONTENT. Jeffes notes that Claude Code’s telemetry does not export its reasoning channel. Plan a hunt around the channels actually collected, rather than using his four-channel result as the expected baseline for a Claude Code-only deployment.

His first exemplar test also overcounted recurring mailbox jobs and duplicate Cursor recordings. After keeping those related sessions on the same side of a held-out split, exemplar retrieval and written descriptions found the same number of sessions in each side’s top 25: 13 and 6. Jeffes notes that approximate vector search shifted those counts by one on repeat runs. Use known-bad turns to catch repeat workflows; written descriptions still matter when the behavior takes a different form.

Collect the right evidence carefully

Start with a small, authorized sample of agent sessions and keep the turn, channel, user and session identifiers together. If you use Elasticsearch semantic_text, its mapped fields generate embeddings during indexing through an inference endpoint. Check endpoint and license availability before enabling the mapping: an inappropriate license can make indexing or reindexing fail. Keep original event timestamps and tool-result context available for review so a similarity hit can be checked against actual activity.

Session content may include secrets and employee personal data. Decide the lawful basis, retention and human-review threshold with the people who own that decision before turning on content export. Treat vectors as sensitive too. Elastic’s access-control documentation describes read-only document- and field-level restrictions; it also warns that access granted by multiple roles is additive. A broad second role can restore fields or documents you meant to hide. Separate sensitive data by index where that role combination would defeat the intended restriction, and constrain who may run arbitrary similarity questions, including queries that reveal patterns through scores without returning raw text.

Test matches against real actions

Run a descriptive hunt over the available prompt, response and tool channels, then read high-ranking turns in their session context. For a suspected data movement, compare the agent’s tool-event timestamp and destination with repository push records and file-access logs; a read of ~/.aws/credentials or a push to an unfamiliar remote deserves specific review when it belongs to the same turn sequence. Escalate a confirmed finding into a case and use its turns to search for repeats. Review matched sessions before treating them as incidents.

Seed the exercise with locally reviewed risky and benign sessions, including look-alike demo work, and measure where each lands in the ranked results. Verify that the collector actually emits the content channels you chose, that the case reviewer sees the original actions, and that a restricted role cannot read a held-back document or field through another assigned role. The decision to escalate belongs to the reviewer who checks the original actions against the local case criteria.