Skip to content

fix(honcho): honcho_search returns empty in directional observation mode#48602

Open
keislij wants to merge 3 commits into
NousResearch:mainfrom
keislij:fix/honcho-search-directional-fallback
Open

fix(honcho): honcho_search returns empty in directional observation mode#48602
keislij wants to merge 3 commits into
NousResearch:mainfrom
keislij:fix/honcho-search-directional-fallback

Conversation

@keislij

@keislij keislij commented Jun 18, 2026

Copy link
Copy Markdown

Summary

honcho_search returns empty for every query in directional observation mode (the default), even when Honcho has rich data about the user. honcho_profile, honcho_context, and honcho_reasoning all work — only honcho_search comes back empty.

Root cause

In directional mode, _resolve_observer_target("user") resolves to observer=assistant, target=user, so search_context() queries the assistant→user directional slot via peer.context(target=user, search_query=...).

That slot is only populated when conclusions are written through the directional path (create_conclusion in directional mode). But the user's substantive data — the auto-derived representation and peer card — lives on the user peer's own self-representation, which Honcho builds from the message stream. So the directional fetch returns empty and search_context() returns "".

get_peer_card() already anticipates exactly this split and has a target-peer fallback (added in a118b94):

# Some backends store cards directly on the target peer, not the
# observer-target slot. Fall back so honcho_profile still works.
if target_peer_id:
    return self._fetch_peer_card(target_peer_id)

search_context() was missing the equivalent fallback, which is why honcho_profile works but honcho_search doesn't.

Fix

Mirror the get_peer_card() fallback in search_context(): when the directional fetch yields no representation and no card, refetch the target peer's own self-context.

if not ctx["representation"] and not ctx["card"] and target and target != observer_peer_id:
    ctx = self._fetch_peer_context(target, search_query=query)
  • Preserves directional precedence — the observer→target slot is still tried first, so if it's populated it wins.
  • No-op for the ai peer path, where observer == target (the condition short-circuits).
  • 6 lines, no new mechanism — reuses the existing _fetch_peer_context helper and matches the pattern already shipping in get_peer_card.

Validation

Reproduced against a live Honcho cloud workspace in directional mode. Before the fix, peer.context(target=user, search_query=q) returns representation len: 0 for every query. The user's own peer.context(search_query=q) returns 1840–2949 chars for the same queries. After the fix, honcho_search returns those results.

New regression test test_search_context_falls_back_to_target_self_context_when_directional_empty covers the directional-empty → user-self-context fallback (parallel to the existing test_get_peer_card_falls_back_to_target_peer_own_card).

pytest tests/honcho_plugin/test_session.py -k "search_context or peer_card" -q
9 passed

Full tests/honcho_plugin/test_session.py passes. (3 unrelated failures in test_pin_peer_name.py::TestPinTransition are pre-existing on main — confirmed by stashing this change and re-running; they concern cache-busting signatures, not retrieval.)

Prior art

This is a recurrence of the symptom from #5667 / PR #5658 ("align honcho_search retrieval with observation direction"), which was closed unmerged and superseded by the tool-surface overhaul in #10619. That overhaul absorbed the target= plumbing but dropped the fallback, reintroducing empty results for users whose data is Honcho-derived rather than written via honcho_conclude. This fix restores read/write alignment while also covering the auto-derived-representation case that #5658 would not have (it read the directional slot only).

keislij added 2 commits June 18, 2026 18:58
search_context() resolved observer->target as hermes-about-Jesse, whose
representation slot is empty in directional mode; the peer's own
self-representation holds the data. Unlike get_peer_card(), search_context()
had no fallback, so honcho_search returned '' for every query while
honcho_profile/context/reasoning worked.

Mirror the get_peer_card() target-peer fallback: when the directional fetch
yields no representation and no card, refetch directly against the target
peer. Preserves directional precedence (only falls back when empty) and is
a no-op for the ai-peer path where observer == target.

Verified against the live backend: queries that returned 0 chars now return
1840-2949 char representations.
Regression test for the honcho_search empty-result fix: in directional
observation mode the assistant->user slot is empty (representation and card),
so search_context must fall back to the user peer's own self-context.
Mirrors test_get_peer_card_falls_back_to_target_peer_own_card.
Copilot AI review requested due to automatic review settings June 18, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes honcho_search returning empty results in Honcho “directional observation mode” by adding a fallback: when the observer→target slot yields neither representation nor card, refetch the target peer’s own self-context (mirroring the existing get_peer_card() fallback behavior). This aligns honcho_search with how Honcho-derived (auto-built) user representations are actually stored.

Changes:

  • Add a fallback in HonchoSessionManager.search_context() to query the target peer’s self-context when the directional observer→target context is empty.
  • Add a regression test covering the “directional empty → target self-context” fallback behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
plugins/memory/honcho/session.py Adds a guarded fallback in search_context() to retrieve target peer self-context when directional context is empty.
tests/honcho_plugin/test_session.py Adds a regression test validating the fallback behavior and call ordering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have labels Jun 18, 2026
…al slot populated

Complements the fallback test by locking in the happy path: when the
observer->target directional fetch returns data, no second fetch against
the target peer is made. Prevents regression and redundant network calls.
(Addresses independent code-review suggestion.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants