Skip to content

BUG: POST /room/recall has no chronological fallback — add GET /room/memories for full room timeline listing #569

Closed

Description

@ajianaz

BUG: POST /room/recall has no chronological fallback — add GET /room/memories for full room timeline listing

Description

POST /room/recall always runs semantic search via recall_room_semantic(), even when no query (or an empty query) is provided. There is no chronological fallback path in the HTTP handler — unlike the CLI, which dispatches to recall_room() (chronological, returns all room members) when --query is absent.

This makes it impossible to enumerate a room's full memory timeline over HTTP. An empty query produces a zero-vector embedding, recall_hybrid() returns nothing, and the post-filter against room IDs yields [] — even when the room has many memories (confirmed via /room/stats).

This was partially addressed for the CLI in #546, but the HTTP handler was not given the same fallback. The asymmetry breaks HTTP-only clients (e.g. CorIn desktop, MCP consumers, any non-CLI integrations) that need to list room memories chronologically.

Environment

  • Uteke version: 0.6.6 (server + CLI)
  • Endpoint: POST /room/recall
  • Reproducibility: Consistent

Steps to Reproduce

Pick any room with linked memories. Here api-platform-strategy has 10 memories (per /room/stats):

# 1. Confirm the room has memories
curl -s -X POST $URL/room/stats \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"room_id":"api-platform-strategy"}'
# → {"memory_count":10,"participant_count":3,"participants":["cfo","cto","sosmed"],...}

# 2. HTTP /room/recall with empty query → empty
curl -s -X POST $URL/room/recall \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"room_id":"api-platform-strategy","query":"","limit":50}'
# → []

# 3. HTTP /room/recall with min_score=0 → still empty
curl -s -X POST $URL/room/recall \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"room_id":"api-platform-strategy","query":"","limit":50,"min_score":0.0}'
# → []

# 4. CLI chronological recall (no --query) → returns all 10 ✓
uteke room recall api-platform-strategy --json | jq 'length'
# → 10

# 5. CLI semantic recall (--query) → ranked subset ✓ (fixed in #546)
uteke room recall api-platform-strategy --query "API Platform Strategy" --json | jq 'length'
# → small ranked subset

Expected Behaviour

POST /room/recall should mirror CLI dispatch semantics:

Request shape Behaviour
{room_id} or {room_id, query:""} Chronological — return all room members ordered by joined_at ASC (calls recall_room())
{room_id, query:"..."} Semantic — rank by relevance, apply min_score (calls recall_room_semantic())

This matches crates/uteke-cli/src/commands/room.rs RoomCommands::Recall exactly, where the presence of query chooses the path.

Actual Behaviour

HTTP always calls recall_room_semantic(). Empty/missing query → empty result, regardless of min_score.

Root Cause

crates/uteke-server/src/handlers.rs, /room/recall arm:

(Method::Post, "/room/recall") => match read_body::<RoomRecallRequest>(req.as_reader()) {
    Ok(req_data) => {
        let min_score = req_data.min_score.unwrap_or(...);
        match uteke.recall_room_semantic(                       // ← always semantic
            &req_data.room_id,
            &req_data.query,
            req_data.limit,
            req_data.author.as_deref(),
            min_score,
        ) { ... }
    }
    ...
}

recall_room_semantic() (in crates/uteke-core/src/rooms.rs) over-fetches via recall_hybrid(query, ...). With query="", the embedding step yields nothing matchable, so the post-filter against room_ids produces an empty set. The core recall_room() function (chronological, direct SQL JOIN on room_memories) already exists and works correctly — it's just not wired through HTTP.

Suggested Fix

Preferred: Option B — new explicit chronological endpoint.

Separating "list room members" from "semantic search within a room" gives clients clear, predictable semantics: GET = list, POST = search. Mirrors how the rest of the API already splits listing (GET /recent, GET /list via POST, GET /namespaces) from semantic ranking (POST /recall, POST /search).

Option B (preferred) — New GET /room/memories endpoint

Add a chronological listing endpoint that wraps the existing recall_room() core function:

// crates/uteke-server/src/handlers.rs
(Method::Get, p) if p == "/room/memories" || p.starts_with("/room/memories?") => {
    let query = p.split('?').nth(1).unwrap_or("");
    let room_id = match parse_query_param(query, "room_id") {
        Some(id) => id,
        None => return ctx.error_response_for(req, 400, "Missing 'room_id' query parameter"),
    };
    let author = parse_query_param(query, "author");
    let limit = parse_query_param(query, "limit")
        .and_then(|v| v.parse::<usize>().ok())
        .unwrap_or(50);
    match uteke.recall_room(&room_id, author.as_deref(), limit) {
        Ok(memories) => ctx.ok_response_for(req, &memories),
        Err(e) => {
            error!("room memories error: {e}");
            ctx.error_response_for(req, 500, "Internal server error")
        }
    }
}

Endpoint contract:

GET /room/memories?room_id=<id>&limit=<n>&author=<ns>
  → Vec<Memory>            (chronological, joined_at ASC)

Then tighten POST /room/recall to require a non-empty query:

(Method::Post, "/room/recall") => match read_body::<RoomRecallRequest>(req.as_reader()) {
    Ok(req_data) => {
        if req_data.query.trim().is_empty() {
            return ctx.error_response_for(req, 400,
                "'query' is required for /room/recall. Use GET /room/memories for chronological listing.");
        }
        let min_score = req_data.min_score.unwrap_or(default);
        uteke.recall_room_semantic(&req_data.room_id, &req_data.query, req_data.limit, req_data.author.as_deref(), min_score)
    }
    ...
}

Pros:

  • Fully explicit — GET always chronological, POST always semantic. No behaviour switch on input.
  • Consistent with existing API split (list vs recall/search).
  • The empty-query footgun disappears entirely (400 with a helpful message).
  • Existing recall_room() core function already exists and works — pure HTTP wiring.
  • RoomRecallRequest becomes simpler: query mandatory.

Cons:

  • Two endpoints instead of one (small docs surface increase).
  • Breaking change for any caller that today relies on empty-query /room/recall (today those callers silently get [], so effectively not breaking real functionality — just turning silent failure into an explicit error).

Option A (alternative) — Behaviour parity with CLI on single endpoint

For completeness: keep a single /room/recall endpoint that dispatches on query.trim().is_empty() → recall_room() chronological, else → recall_room_semantic(). Lower surface area but mixes listing and ranking semantics under one URL. Less preferred because it makes the API less self-describing.

Suggested Version Target

v0.7.0 (semver minor: new endpoint + 400 on previously-silent empty query) or v0.6.7 if treated as a bug fix.

Use Case

CorIn desktop's Rooms view has three tabs: Summary, Memories (timeline), Participants. The Memories tab needs a complete chronological list of room memories — like a chat thread. Semantic ranking belongs on the per-memory detail view ("similar memories", graph neighbors via /edges, /neighbors), not as the only way to list room members.

Without a chronological HTTP path, HTTP clients can't render a room's memory timeline at all. Currently CorIn works around this by seeding /room/recall with the room title + min_score=0, but this still only returns memories that happen to be semantically close to the title — not the full membership. A GET /room/memories endpoint would let CorIn drop the workaround entirely.

The same applies to any MCP consumer or non-CLI integration that wants to display a room's history.

Additional Context

  • Related: BUG: room recall --query (semantic search within room) returns empty results #546 (CLI --query empty results — fixed for CLI semantic only)
  • The core function recall_room() already exists and is correct — this issue is purely about wiring it through the HTTP handler.
  • RoomRecallRequest already has query as optional in spirit; making empty-query mean "chronological" is a one-branch change in the handler.

Activity

  1. added
    bug
    scope:server
    on Jul 5, 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

    bugpriority:mediumscope:server

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions