Skip to content

fix(channels): resolve provider from model_routes on /model, preserve context - #3198

Merged
theonlyhennygod merged 2 commits into
zeroclaw-labs:masterfrom
panviktor:fix/channel-model-switch-resolve-routes
Mar 11, 2026
Merged

theonlyhennygod merged 2 commits into
zeroclaw-labs:masterfrom
panviktor:fix/channel-model-switch-resolve-routes

Conversation

@panviktor

Copy link
Copy Markdown
Contributor

Summary

  • Base branch target: master
  • Problem: /model <name> sets model but does not resolve provider from model_routes → 404 when switching to models on different providers (e.g. /model kimi-k2.5 with anthropic default). History cleared on every switch. Matrix does not support /model at all.
  • Why it matters: users cannot switch models across providers without manual /models + /model two-step; context lost on every switch
  • What changed: /model auto-resolves provider+model from model_routes (by model name or hint); history preserved on /model and /models; Matrix added to supported channels; /model (no args) lists configured routes
  • What did not change: /new still clears history; provider init logic; agent-level RouterProvider; Telegram/Discord existing behavior for unrouted models

Label Snapshot (required)

  • Risk label: risk: medium
  • Size label: size: S
  • Scope labels: channel
  • Module labels: channel: matrix, channel: telegram, channel: discord
  • Contributor tier label: auto
  • If any auto-label is incorrect: N/A

Change Metadata

  • Change type: bug
  • Primary scope: channel

Linked Issue

  • Closes #
  • Related #
  • Depends on #
  • Supersedes #

Supersede Attribution (required when Supersedes # is used)

N/A

Validation Evidence (required)

cargo fmt --all -- --check        # ✅ pass
cargo clippy --all-targets -- -D warnings   # ✅ pass
cargo test                        # ✅ all pass

- Evidence provided: all three commands pass cleanly
- If any command is intentionally skipped: none

Security Impact (required)

- New permissions/capabilities? No
- New external network calls? No
- Secrets/tokens handling changed? No
- File system access scope changed? No

Privacy and Data Hygiene (required)

- Data-hygiene status: pass
- Redaction/anonymization notes: no user data involved
- Neutral wording confirmation: confirmed

Compatibility / Migration

- Backward compatible? Yes — /model without a matching route falls back to current behavior (set model, keep provider)
- Config/env changes? No
- Migration needed? No

i18n Follow-Through (required when docs or user-facing wording changes)

- i18n follow-through triggered? No

Human Verification (required)

- Verified scenarios: /model kimi-k2.5 resolves provider from model_routes; history preserved after switch; Matrix parses /model, /models, /new
- Edge cases checked: unknown model (no route) falls back to current provider; empty input rejected; /new still clears history
- What was not verified: live Matrix/Telegram chat (requires running daemon)

Side Effects / Blast Radius (required)

- Affected subsystems/workflows: channel runtime command handling (Telegram, Discord, Matrix)
- Potential unintended effects: users who relied on auto history-clear on /model now need /new
- Guardrails/monitoring for early detection: /new remains available; history capped at 50 messages

Agent Collaboration Notes (recommended)

- Agent tools used: Claude Code
- Workflow/plan summary: traced /model flow in src/channels/mod.rs → found three bugs (no provider resolution from routes, unconditional history clear, missing Matrix support) → minimal fix in one file
- Verification focus: clippy, fmt, full test suite
- Confirmation: naming + architecture boundaries followed

Rollback Plan (required)

- Fast rollback command/path: git revert <commit>
- Feature flags or config toggles: none
- Observable failure symptoms: /model not resolving provider → 404 (identical to pre-fix behavior)

Risks and Mitigations

- Risk: stale context when switching between models with different context window sizes
  - Mitigation: history auto-compacted at 50 messages; /new available for explicit reset

… context

- `/model <name>` now auto-resolves provider from configured model_routes
  by matching model name or hint, fixing 404 when switching to models on
  different providers (e.g. `/model kimi-k2.5` with anthropic default)
- Conversation history is no longer cleared on `/model` or `/models` —
  users can explicitly reset via `/new`
- Matrix channel now supports `/model`, `/models`, and `/new` commands
- `/model` (no args) lists configured model routes with hints

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@panviktor
panviktor force-pushed the fix/channel-model-switch-resolve-routes branch from 191f593 to 0ee3b6d Compare March 11, 2026 15:13

@theonlyhennygod theonlyhennygod left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@theonlyhennygod
theonlyhennygod merged commit 74f411b into zeroclaw-labs:master Mar 11, 2026
6 checks passed
@panviktor
panviktor deleted the fix/channel-model-switch-resolve-routes branch March 13, 2026 09:48
lantrinh1999 pushed a commit to lantrinh1999/zeroclaw-1 that referenced this pull request Mar 18, 2026
…l-switch-resolve-routes

fix(channels): resolve provider from model_routes on /model, preserve context
belumume pushed a commit to belumume/zeroclaw that referenced this pull request Oct 9, 2026
…l-switch-resolve-routes

fix(channels): resolve provider from model_routes on /model, preserve context
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