Skip to content

Honcho memory tools ignore focused query and token budget controls #29402

@dso2ng

Description

@dso2ng

Bug description

The Honcho memory tool schemas advertise focused retrieval controls that are not fully honored by the current implementation:

  • honcho_context exposes an optional query parameter described as focusing/filtering context, but the handler currently calls get_session_context(..., peer=peer) without passing the query through.
  • honcho_search accepts max_tokens, but HonchoSessionManager.search_context() returns the assembled representation/card blob without deterministic budget trimming.

This makes the Hermes tool surface noisier than the underlying focused Honcho/pgvector retrieval path: broad peer representation/card content can dominate even when a caller asks for a focused search or smaller token budget.

Expected behavior

  • honcho_context(query=...) should pass the focused query into Honcho peer-context retrieval rather than silently returning broad session context.
  • honcho_search(max_tokens=N) should bound its returned raw context to the requested approximate token budget.
  • The existing JSON shape ({"result": ...}) should remain backward-compatible for a narrow bugfix.

Proposed first slice

Keep the first PR intentionally narrow:

  1. Pass query from the honcho_context tool handler into HonchoSessionManager.get_session_context().
  2. When a query is present, fetch focused peer context via peer.context(search_query=..., target=...) instead of broad session context.
  3. Apply deterministic post-fetch trimming in search_context() based on max_tokens.
  4. Add regression tests for the drift above.

Out of scope for the first PR

  • Switching honcho_search to a new conclusions/query API.
  • Adding top_k, min_score, MMR, or structured ranked result arrays.
  • Changing peer routing semantics.

Those would be good follow-up work after the schema/implementation drift is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/pluginsPlugin system and bundled pluginstool/memoryMemory tool and memory providerstype/bugSomething isn't working

    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