It says “let me search this session” — and comes back with nothing


Last week you worked something out with the agent in a long session — which config key to flip, what the test output meant. Today you come back: “what did we decide about that?” The reply is perfectly reasonable: the conversation got compacted, let me search it. Then it calls session_search and returns the first few messages you already remember, or worse, “nothing found” — even though you both know the detail was there.

The model isn’t being lazy. Compaction has a cost: the middle of the conversation is replaced by a summary, and the footer tells the model where to look for the dropped detail — an in-session search. The problem was that the search itself, for a long time, either ignored the query or came back empty because the asking session matched every word. PR #160576, merged on November 27, fixes that whole cluster, and it was validated by replaying real calls rather than reasoning about the code.

The worst kind of failure: a search that reports success

After compaction the model is told to search that session, so it passes query together with session_id. On the old code that combination took the READ path: it returned the head and tail of the session and never used query at all. The compacted rows had left the live context, so they could not appear — that is issue #99568.

The second shape is sneakier. You ask “what did we conclude about billing last week?” and discovery returns zero results. Not because nothing matched, but because the asking session itself held every query word: your prompt and the session_search call it just produced. The strict search “succeeded”, those rows were dropped as live context, and the any-term retry that should have rescued the search never ran.

The tool only has five shapes

Worth spelling out, because the fix only makes sense once you see what the tool is: session_search never calls an LLM to summarise. It queries the local state.db and infers the mode from its arguments.

What you pass What it does
query Discovery: matching messages across every past session
session_id Read: the whole session, or its head and tail
query + session_id Search inside one session’s compression lineage
session_id + around_message_id Scroll: a window around one anchor message
nothing Browse: which sessions exist

“Compression lineage” is the concept that matters. Compaction does not overwrite a session; it creates a continuation and makes the old one its predecessor. A search has to walk that chain upwards, or everything that was compacted away stays invisible forever.

Four changes, each aimed at a real failure

In-session search honours the query. query plus session_id now returns the matching messages themselves instead of the first and last few. A demoted tool result — whose only full copy lives in the superseded original — is searchable from any caller, not just from the session that owned it.

An empty result gets a second pass. Only when the asking session’s own rows matched does the search retry with any-term matching, and earlier agents’ search calls stop counting as history — they are not conversation content and should not compete with it.

Results are capped. The worst real case was an 8-result discovery at 152K characters, 118K of it stored tool-call arguments: entire files and heredocs. Now discovery cuts tool arguments to 200 characters (2,000 on the hit itself), scroll cuts neighbouring tool rows at 1,500 and neighbouring text at 8,000, and the message you asked for stays whole — scroll is still the way to read a long message to its end, and an oversized one spills to a readable file.

A guessed position lands somewhere real. When the model has an approximate id or offset, the old code failed outright. Now the scroll snaps to the nearest real message, and the answer adds the line you actually need: to continue, hermes --resume <session_id> opens the latest continuation, and any id from the lineage works.

The numbers come from a replay, not a feeling

The author re-ran the last 30 days of real session_search calls from one heavy install against its own database: 135 calls across 42 sessions, with the original session as the caller and relative bounds rebased on the call time.

Metric Before After
In-session hits (returned message holds at least half the query words) 10 / 26 21 / 26
Discoveries returning 0 results 14 / 92 3 / 92
Discoveries where the session later used was the top hit 22 / 37 23 / 37
Discovery payload, p90 42,423 chars 31,758 chars
Largest discovery 171,114 chars 60,413 chars
Discoveries over 100K chars (spilled to a preview) 3 0
Scrolls that landed on a real message 14 / 17 17 / 17
Scroll payload, p50 24,701 chars 12,243 chars

Two calls score slightly below a version with no argument cap at all, because their query words lived only inside tool arguments now cut at 200 characters — the snippet still shows the match. That is the trade: a little recall for a lot less context.

One more rule explains a lot of “why can’t it find my own conversation”: sessions with the source kanban, subagent and tool are hidden entirely — they are machine work logs, not your history. cron sessions stay searchable but are demoted, because scheduled jobs generate enormous amounts of repetitive vocabulary that would otherwise crowd your own chats out of a pure relevance ranking (that was the earlier “recall blindness” fix, #19434).

What you can do today

This is on main and not in the v0.23.4 stable package — its release page does not list it — so a stable install still shows the old behaviour. Three practical habits:

Update (2026-11-28): these changes shipped in v0.23.5 (November 28) — hermes update brings them in. The “not in v0.23.4 / on main only” wording above is a snapshot from publication time.

Say “search inside this session” when you want a specific detail after compaction. Discovery across everything is where scheduled-job vocabulary gets in the way.

Once it has the id, continue rather than re-read: hermes --resume <session_id> opens the newest continuation. If you are unsure which session owns a chat, the session boundaries guide covers the ownership rules.

Keep the payload small. A discovery result is context you pay for; the same discipline as compacting in one call applies — narrow the range first, then read the one message you need.

The takeaway

“Search found nothing” and “search found it and didn’t show you” feel identical from the outside, and the second is much harder to diagnose. Nothing new was added here. A tool that already existed was made to do what it promises: match on words, widen the net when nothing matches, keep the result from swallowing the context window, and hand you a way to pick the conversation back up.