Skip to content

feat: semantic room recall — hybrid search within room context instead of sequential list #304

Closed

Description

@ajianaz

Problem

uteke room recall <room_id> currently returns all memories linked to a room sorted chronologically (by joined_at). This is a sequential dump, not a semantic search.

When a room accumulates memories over time (e.g., a Discord thread discussion spanning days), recalling all memories produces signal-to-noise degradation. An agent joining a room with 500+ linked memories gets everything in chronological order — most of which may be irrelevant to their current question.

Current behavior

uteke room recall discord:1514528701109506199
# Returns ALL memories sorted by joined_at ASC
# No semantic filtering. No relevance scoring.

Expected behavior

# Semantic recall within room context — hybrid vector + FTS5
uteke room recall discord:1514528701109506199 --query "deployment strategy for v2"
# Returns room memories ranked by semantic relevance to the query
# Uses same RRF hybrid search as `uteke recall`, but scoped to room

# Still supports full dump when no query given (backward compat)
uteke room recall discord:1514528701109506199
# Returns all memories chronologically (unchanged)

Why This Matters

1. Room is the foundation for multi-agent orchestration

Rooms (#286) are designed as collaborative memory spaces where multiple agents share context. For orchestration to work, agents need to query room context efficiently, not dump everything.

Consider this flow:

  • Agent Kai researches AI news, stores 50 memories in room news-daily
  • Agent Zeko needs only the memories about funding rounds to compile a brief
  • Without semantic room recall, Zeko gets all 50 memories and must filter client-side — wasting context window tokens

2. Context window economics

Agents have finite context windows. A room with 1000 memories × ~200 chars each = ~200K chars of noise if dumped sequentially. Semantic recall returns only the top-N relevant memories, keeping context focused and accurate.

3. Consistency with existing search capabilities

Uteke already has hybrid search (FTS5 + vector RRF, #250). Room recall is the only retrieval path that doesn't use it. This inconsistency means:

  • Global recall (uteke recall) → hybrid search ✅
  • Room recall (uteke room recall) → sequential dump ❌
  • Text search (uteke search) → FTS5 ✅

Proposed Implementation

Core change: recall_room → recall_room_semantic

In crates/uteke-core/src/memory/rooms.rs, add a new method alongside the existing recall_room:

/// Semantic recall within a room context.
/// Uses hybrid FTS5 + vector search with RRF, scoped to room-linked memories.
pub fn recall_room_semantic(
    &self,
    room_id: &str,
    query: &str,
    limit: usize,
    author: Option<&str>,
    min_score: Option<f32>,
) -> Result<Vec<Memory>, Error>

Algorithm:

  1. Embed the query using Embedder::embed(query)
  2. Hybrid search (same as Store::recall_hybrid) but scoped:
    • Vector: ANN search on memories table, filter WHERE id IN (SELECT memory_id FROM room_memories WHERE room_id = ?1)
    • FTS5: FTS match on memories table, same room filter
  3. RRF merge with configurable k (reuse existing RecallStrategy::Hybrid)
  4. Post-filter by author if provided
  5. Return top-N by RRF score

CLI change

Add --query flag to uteke room recall:

RoomCommands::Recall {
    room_id: String,
    #[arg(long)]
    author: Option<String>,
    #[arg(long, default_value = "50")]
    limit: usize,
    // NEW: semantic query
    #[arg(long)]
    query: Option<String>,
}

When --query is provided → use recall_room_semantic. When omitted → use existing recall_room (backward compatible).

MCP server update

Add query parameter to uteke_room_recall MCP tool:

{
  "name": "uteke_room_recall",
  "input_schema": {
    "room_id": {"type": "string"},
    "query": {"type": "string", "description": "Semantic search query (optional)"},
    "author": {"type": "string", "optional": true},
    "limit": {"type": "number", "default": 50}
  }
}

Dependencies

Testing

  • Unit test: create room with 10 memories, query for specific topic, verify top results are semantically relevant
  • Edge case: empty room, room with no matching memories, query with typos
  • Performance: room with 1000+ memories should return in <100ms (same as global recall)

Closes

None (new feature)

Activity

  1. added
    scope:core
    type:feature
    v0.1.0
    priority:high
    on Jun 12, 2026
  2. added 2 commits that reference this issue on Jun 13, 2026
  3. ajianaz commented on Jun 13, 2026

    @ajianaz
    CollaboratorAuthor

    Implemented in PR #314, merged to develop.

  4. added this to the milestone on Jun 13, 2026
  5. added a commit that references this issue on Jun 13, 2026
  6. added a commit that references this issue on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highscope:coretype:featurev0.1.0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions