-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
Bug: /model directive fails to parse Auth Profiles containing @ (e.g. OAuth email IDs) #30912
Description
Description
When using the /model directive to override the auth profile for a session, the parser incorrectly splits the input if the Auth Profile ID itself contains an @ symbol (which is standard for OAuth profiles like google-gemini-cli:[email protected]).
Steps to reproduce
- Login using a provider that generates email-based profile IDs:
openclaw models auth login --provider google-gemini-cli- This creates a profile ID such as
google-gemini-cli:[email protected]. - Attempt to use this profile in a chat session:
/model flash@google-gemini-cli:[email protected]
Expected Behavior
The system should recognize the model as flash and the Auth Profile ID as google-gemini-cli:[email protected].
Actual Behavior
The system reports:
Auth profile "gmail.com" not found.
Technical Details
The issue stems from splitTrailingAuthProfile in src/agents/model-ref-profile.ts (or equivalent built output like model-selection-J6oFwo9y.js), which uses lastIndexOf("@") to split the string:
function splitTrailingAuthProfile(raw) {
// ...
const profileDelimiter = trimmed.lastIndexOf("@");
// ...
const model = trimmed.slice(0, profileDelimiter).trim();
const profile = trimmed.slice(profileDelimiter + 1).trim();
// ...
}Because it searches from the back, it splits [email protected] instead of the directive's intended @ separator.
Suggested Fix
Given that profile IDs commonly contain @ (for emails), the parser should either:
- Use
indexOf("@")instead oflastIndexOf("@")(assuming model IDs do not contain@), OR - Modify the regex in
extractModelDirectiveto more intelligently capture the separator, perhaps allowing a dedicated delimiter format for explicit overrides.