Skip to content

crossSessionSearch=true still scopes to current session due to sessionKey parameter #72

Description

@yuzi001a

Bug Description

When crossSessionSearch is set to true in the Honcho plugin configuration, the memory_search tool should search across all sessions. However, it still limits results to the current session and its child sessions.

Expected Behavior

With crossSessionSearch=true, memory_search should return results from all sessions in the workspace, not just the active session scope.

Actual Behavior

Even when crossSessionSearch is explicitly set to true, search results are limited to the current session. This happens because the search logic passes the sessionKey parameter to scoped search whenever requestedSessionKey is present, bypassing the cross-session ownerPeer.search() call.

Root Cause

In dist/runtime.js, the search function handles requestedSessionKey by performing a scoped search:

if (requestedSessionKey) {
    const exactSession = await state.honcho.session(requestedSessionKey, {...});
    collect(await exactSession.search(query, { limit }));
    // ... scoped session search
}
else {
    collect(await ownerPeer.search(query, { limit }));
}

When crossSessionSearch=true and requestedSessionKey is present, the code never falls back to ownerPeer.search() for cross-session results.

Proposed Fix

Add a fallback to ownerPeer.search() when crossSessionSearch is enabled and scoped search results are insufficient:

// After scoped search, add fallback:
if (state.cfg.crossSessionSearch && filtered.length < limit) {
    collect(await ownerPeer.search(query, { limit: limit - filtered.length }));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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