fix(rooms): resolve room ids missing or mangling the server name #152

Merged
jlxq0 merged 1 commit from fix/room-id-resolution into main 2026-10-10 04:34:23 +00:00
Owner

Agents call read_recent_messages with room ids the server cannot place: !KsFsfVrDOIylxbNokX (no server name), !iwGDzdrwuZfnQNFszT:kಂಪong.social (server name garbled by the model), and placeholders such as !current. The answer was not joined to …, which gives the model no way to recover.

Change

  • New resolve_room used by every tool that takes a room_id (29 call sites) and by message_forward for source_room_id / target_room_id.
    • An id the SDK store knows is used unchanged, so each tool's own Joined/Invited checks behave exactly as before.
    • Otherwise the one joined room with the same localpart is used. Only joined rooms are candidates, so resolution never reaches a room the user is not in. Two matches are reported as ambiguous with both ids.
    • No match: the error keeps its not joined to … / invalid room_id … prefix and adds Pass the full room id including the server name, exactly as list_joined_rooms returns it (e.g. !abc:<homeserver>); call list_joined_rooms to find the room.
  • room_id parameter descriptions state the full-id format.
  • accept/reject invite and the no such room path keep their exact-id lookups.

Tests: unit tests for localpart extraction, bare and mangled ids resolving, placeholders/prefixes/case not resolving, ambiguity, and the hint. cargo fmt --check, cargo clippy --all-targets --all-features --locked -D warnings (1.98.0) and cargo test --all-features --locked (366 + 6 passed) are green locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BbPgHm7ND8CnztzqxLEn5T

Agents call `read_recent_messages` with room ids the server cannot place: `!KsFsfVrDOIylxbNokX` (no server name), `!iwGDzdrwuZfnQNFszT:kಂಪong.social` (server name garbled by the model), and placeholders such as `!current`. The answer was `not joined to …`, which gives the model no way to recover. **Change** - New `resolve_room` used by every tool that takes a `room_id` (29 call sites) and by `message_forward` for `source_room_id` / `target_room_id`. - An id the SDK store knows is used unchanged, so each tool's own Joined/Invited checks behave exactly as before. - Otherwise the one **joined** room with the same localpart is used. Only joined rooms are candidates, so resolution never reaches a room the user is not in. Two matches are reported as ambiguous with both ids. - No match: the error keeps its `not joined to …` / `invalid room_id …` prefix and adds `Pass the full room id including the server name, exactly as list_joined_rooms returns it (e.g. !abc:<homeserver>); call list_joined_rooms to find the room.` - `room_id` parameter descriptions state the full-id format. - `accept/reject invite` and the `no such room` path keep their exact-id lookups. **Tests**: unit tests for localpart extraction, bare and mangled ids resolving, placeholders/prefixes/case not resolving, ambiguity, and the hint. `cargo fmt --check`, `cargo clippy --all-targets --all-features --locked -D warnings` (1.98.0) and `cargo test --all-features --locked` (366 + 6 passed) are green locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01BbPgHm7ND8CnztzqxLEn5T
fix(rooms): resolve room ids missing or mangling the server name
All checks were successful
CI / cargo (pull_request) Successful in 1m51s
CI / docker (pull_request) Has been skipped
8601adbf97
Agents called read_recent_messages with `!KsFsfVrDOIylxbNokX` (no server
name) and `!iwGDzdrwuZfnQNFszT:kಂಪong.social` (server name garbled), and
got `not joined to …` with no hint how to recover.

Every room tool now goes through resolve_room: an id the SDK store knows
is used unchanged (so per-tool membership checks are untouched); otherwise
the one joined room with the same localpart is used, two matches are
reported as ambiguous, and no match yields an error naming the expected
`!abc:<homeserver>` form and list_joined_rooms. Only joined rooms are
candidates. The room_id parameter descriptions state the full-id format.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BbPgHm7ND8CnztzqxLEn5T
jlxq0 merged commit de8f7a5e51 into main 2026-10-10 04:34:23 +00:00
jlxq0 deleted branch fix/room-id-resolution 2026-10-10 04:34:23 +00:00
jlxq0 referenced this pull request from a commit 2026-10-10 04:41:52 +00:00
Sign in to join this conversation.
No description provided.