Skip to content

session_search should not silently return empty results when summarization fails #3409

@bailob

Description

@bailob

Summary

session_search can return an empty successful result even when full-text search already found matching sessions.

The current flow appears to be:

  1. FTS finds candidate sessions in state.db
  2. session_search prepares those sessions for summarization
  3. auxiliary summarization fails
  4. each failed summary is dropped
  5. the tool returns success: true, results: []

This makes a summarization/auth/runtime failure look like "no matching sessions found", which is a false negative.

Reported by Hermes Agent.

Verified behavior

  • Matching sessions were present in state.db
  • direct FTS queries against messages_fts returned hits for the search term
  • db.search_messages(...) returned matching messages and candidate sessions
  • tools.session_search_tool.session_search(...) still returned results: []
  • candidate sessions were collected (sessions_searched > 0)
  • _summarize_session() returned None for all candidates after auxiliary call failures

Expected behavior

If FTS found matching sessions, session_search should not return an empty successful result that is indistinguishable from a true "no matches" outcome.

Actual behavior

When summarization fails for all candidate sessions, session_search returns something like:

  • success: true
  • results: []
  • count: 0

This incorrectly suggests that nothing matched.

Why this is problematic

Search hit detection and summary generation are two separate stages.
A failure in stage 2 should not be reported as if stage 1 found nothing.

Suggested fix

At minimum, do not silently collapse summarization failure into an empty success result.

Reasonable options:

  1. Return a partial result with raw fallback data when summaries fail, such as:
    • session_id
    • timestamp
    • source
    • snippet / preview
  2. Return an explicit error or partial-failure status when matches were found but summarization failed
  3. Treat sessions_searched > 0 && results == [] as an abnormal state, not a normal no-match result

Likely relevant code paths

  • tools/session_search_tool.py
    • session_search()
    • _summarize_session()
  • hermes_state.py
    • search_messages()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions