Skip to content

Opt-in Matrix model badge: replies and sender line name the model - #155

Merged
TroyHernandez merged 4 commits into
mainfrom
feat/matrix-model-badge
Aug 4, 2026
Merged

TroyHernandez merged 4 commits into
mainfrom
feat/matrix-model-badge

Conversation

@user9208212

Copy link
Copy Markdown
Collaborator

What

New matrix_configure(model_badge =) key: "never" (default — zero behavior change unless opted in), "non_default", or "always". When a badge applies:

  • each reply gets a deterministic first line: ⚡ claude-sonnet-4-6 (anthropic_claude)
  • the bot renames itself to r2j2 ⚡ claude-sonnet-4-6 (via mx.api::mx_set_displayname), so the sender line above every message wears the model, and the rename event itself marks the switch in the timeline

Both are stamped after the turn by the poll loop, not by the LLM, so no model can forget or restyle its own badge.

Why

A /model switch to a paid provider is easy to forget from a phone; in "non_default" mode silence means the configured default and a badge means a switch is live (and probably spending money). The badge disappears exactly when the switch does: /clear and process restart both revert to the default session and reset the profile name.

Mechanics

  • Sessions stamp their creation-time model/provider (default_model/default_provider) as the comparison baseline — no cfg guessing, works when matrix_run opts override the config.
  • Display name is account-global: with sessions in several rooms the most recent switch wins; the per-reply badge line is always room-accurate (documented). Renames are best-effort and never block a reply.
  • display_name optionally sets the base name the rename builds on (default: user-id localpart).
  • Pure helpers (matrix_model_badge, matrix_badge_displayname, matrix_session_is_default) tested with 16 asserts, no network.

Bumps version to 0.7.0.5 — assumes the sibling /model menu PR (#154, 0.7.0.4) merges first; happy to renumber if the order flips.

🤖 Generated with Claude Code

New matrix_configure(model_badge =) key: "never" (default, unchanged
behavior), "non_default", or "always". When a badge applies,
deterministic post-turn code — not the model — prepends a
"<bolt> <model> (<provider>)" first line to each reply and renames the
bot to "<name> <bolt> <model>", so a room session that /model-switched
to a paid provider is visible on every message and in the sender line.
In non_default mode silence means the configured default: the badge
appears only while a switch is live and disappears on /clear or a
process restart (both reset the profile name). Sessions stamp their
creation-time model/provider as the comparison baseline. display_name
optionally sets the base name (default: user-id localpart). Bump
version to 0.7.0.5.
Per review: keep the badge policy (mode, session-vs-default comparison,
reply stamping) in corteza, but do the profile update through
mx.client's new client-level mx_set_displayname() instead of calling
mx.api directly. That routes the rename through mx_with_relogin(), so
a rotated token gets refreshed and retried instead of silently failing
the rename on a long-running bot. matrix_update_displayname no longer
needs the mx_sess argument. Requires mx.client >= 0.1.1.1
(cornball-ai/mx.client#11).
@user9208212

Copy link
Copy Markdown
Collaborator Author

Reworked per review (15c3892): badge policy and reply stamping stay here; the profile update now goes through mx.client's new client-level mx_set_displayname() (cornball-ai/mx.client#11), which routes the rename through mx_with_relogin() — a rotated token gets refreshed and retried instead of silently failing on a long-running bot. matrix_update_displayname() dropped its mx_sess argument; Suggests now floors mx.client at 0.1.1.1. Merge order: mx.client#11 → #154 → this.

CRAN has mx.client 0.1.1, so the Suggests floor added for
mx_set_displayname() is unsatisfiable there; install from GitHub like
llm.api until the next mx.client CRAN release. CI on this PR stays red
until cornball-ai/mx.client#11 lands on main.
@user9208212

Copy link
Copy Markdown
Collaborator Author

Re the red CI on the last push: two separate things. (1) The macOS leg died at the known llm.api GitHub-install problem (cannot open URL .../llm.api/contents/DESCRIPTION) during install_deps, before this PR's code is even reached — same issue cornelius flagged on #153; fail-fast then canceled the ubuntu leg mid-install, so ubuntu never actually failed. (2) A real latent problem the red run surfaced: CRAN only has mx.client 0.1.1, so the >= 0.1.1.1 Suggests floor is unsatisfiable there — added cornball-ai/mx.client to Remotes (b93411c), same pattern as llm.api. CI here stays red until mx.client#11 lands on main; a re-run after that should go green.

Rescues the badge after 12 commits of drift. 0.7.0.5 renumbers to
0.7.1.2 on top of the rewire.

Semantic resolutions, not just textual:

- matrix_apply_model_command() gained a cfg argument on main; kept
  main's call and the branch's post-switch displayname update.
- /clear was rewritten on main to record the event in the transcript
  ledger; kept main's version with the branch's displayname reset
  prepended, so a badge rename is still undone on /clear.
- The test files had diverged too far for a hunk merge (one 512-line
  conflict), so main's file is taken wholesale and the three badge
  blocks appended.
- Dropped the branch's Remotes: field; CRAN does not accept it and main
  had already removed it.
- mx.client bound moves to >= 0.2.0, the version carrying
  mx_set_displayname().

2663 tests pass, up from 2648: the badge tests run green against the
rewired chat_send() path, which was the risk a textual merge could not
settle.
@TroyHernandez
TroyHernandez merged commit afd0114 into main Aug 4, 2026
2 checks passed
@TroyHernandez
TroyHernandez deleted the feat/matrix-model-badge branch August 4, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants