Skip to content

Comments

fix(models): strip @profile suffix from model selection#11198

Open
mcaxtr wants to merge 1 commit intoopenclaw:mainfrom
mcaxtr:fix/10882-model-profile-allowlist
Open

fix(models): strip @profile suffix from model selection#11198
mcaxtr wants to merge 1 commit intoopenclaw:mainfrom
mcaxtr:fix/10882-model-profile-allowlist

Conversation

@mcaxtr
Copy link
Contributor

@mcaxtr mcaxtr commented Feb 7, 2026

Fixes #10882

Summary

When using /model provider/model@profile:name syntax, the @profile suffix was included in the model name during allowlist lookup, causing a "model not allowed" error even when the model is properly configured.

Repro Steps

  1. Configure an allowlist with nvidia/moonshotai/kimi-k2.5
  2. Send /model nvidia/moonshotai/kimi-k2.5@nvidia:default
  3. Result: "model not allowed" error because the key becomes nvidia/moonshotai/kimi-k2.5@nvidia:default instead of nvidia/moonshotai/kimi-k2.5

Root Cause

resolveModelRefFromString() in src/agents/model-selection.ts passed the full input (including @profile suffix) to parseModelRef(). The inline directive path (extractModelDirective() in src/auto-reply/model.ts) already strips @profile before calling resolution, but the session reset path (applyResetModelOverride()buildSelectionFromExplicit()) does not — it calls resolveModelRefFromString() with the raw token.

Fixing at the resolveModelRefFromString() level ensures all code paths that resolve model refs correctly strip the @profile suffix, regardless of whether the caller pre-strips it.

Behavior Changes

  • resolveModelRefFromString() now strips @profile suffix before alias lookup and parseModelRef() call
  • No change to parseModelRef() itself (profile stripping is an application-level concern, not a model-ref concern)
  • Existing callers that already strip @profile (inline directive path) are unaffected — double-stripping is safe

Codebase and GitHub Search

Tests

4 new tests in src/agents/model-selection.test.ts — all 4 fail before fix, pass after:

  • Strip @profile suffix from provider/model input (nvidia/moonshotai/kimi-k2.5@nvidia:default)
  • Strip @profile suffix from single-segment model input (gpt-5@myprofile)
  • Strip @profile suffix with colon in profile name (google/gemini-flash-latest@google:bevfresh)
  • Resolve alias with @profile suffix (kimi@nvidia:default)

Full test suite: 220 tests pass across 36 files. Build and lint clean.

lobster-biscuit

Sign-Off

  • Models used: Claude Opus 4.6
  • Submitter effort: autonomous (TDD)
  • Agent notes: Fix applied at deepest shared layer (resolveModelRefFromString) to benefit all code paths. The inline directive path already handled this correctly; the session reset path did not.

Greptile Overview

Greptile Summary

This PR updates resolveModelRefFromString() to strip a trailing @profile suffix from model tokens before alias lookup and parseModelRef() parsing, fixing allowlist key mismatches when users specify /model provider/model@profile:name. It also adds unit tests covering provider/model inputs, single-segment inputs, aliases, and profile names containing colons to ensure all resolution paths behave consistently.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Change is narrowly scoped to stripping @profile suffixes before alias lookup/parsing, with added unit tests covering the affected cases. No other resolution logic is altered, and the new behavior is consistent across callers.
  • No files require special attention

@openclaw-barnacle openclaw-barnacle bot added the agents Agent runtime and tooling label Feb 7, 2026
SutanuNandigrami pushed a commit to SutanuNandigrami/openclaw that referenced this pull request Feb 8, 2026
@mcaxtr mcaxtr force-pushed the fix/10882-model-profile-allowlist branch 3 times, most recently from 65421d4 to c16ca4c Compare February 12, 2026 04:18
@mcaxtr mcaxtr force-pushed the fix/10882-model-profile-allowlist branch from c16ca4c to 53a38c9 Compare February 13, 2026 02:14
@openclaw-barnacle openclaw-barnacle bot added the trusted-contributor Contributor with 4+ merged PRs label Feb 13, 2026
@mcaxtr mcaxtr force-pushed the fix/10882-model-profile-allowlist branch from 53a38c9 to 6ee4ab0 Compare February 13, 2026 14:33
@openclaw-barnacle openclaw-barnacle bot added the experienced-contributor Contributor with 10+ merged PRs label Feb 13, 2026
@mcaxtr mcaxtr force-pushed the fix/10882-model-profile-allowlist branch 9 times, most recently from fc1a11d to 0f0c297 Compare February 15, 2026 14:21
@mcaxtr mcaxtr force-pushed the fix/10882-model-profile-allowlist branch 2 times, most recently from f2ee3f4 to cf4f0ac Compare February 17, 2026 01:27
@mcaxtr mcaxtr force-pushed the fix/10882-model-profile-allowlist branch from cf4f0ac to 105213d Compare February 19, 2026 02:13
@ivalsaraj
Copy link

Feature: support multiple aliases per model (for per-profile routing)
Currently agents.defaults.models uses model ID as the key, so only one alias is possible per model. Users with multiple OAuth profiles for the same model (e.g. two Codex accounts) can't have codex-one/codex-two as usable aliases — they're forced into auth.order with no ergonomic per-profile alias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling experienced-contributor Contributor with 10+ merged PRs size: S trusted-contributor Contributor with 4+ merged PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /model command with explicit @profile suffix fails with "model not allowed"

2 participants