Skip to content

Bug: /model directive fails to parse Auth Profiles containing @ (e.g. OAuth email IDs) #30912

@bingfoon

Description

@bingfoon

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

  1. Login using a provider that generates email-based profile IDs:
openclaw models auth login --provider google-gemini-cli
  1. This creates a profile ID such as google-gemini-cli:[email protected].
  2. 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:

  1. Use indexOf("@") instead of lastIndexOf("@") (assuming model IDs do not contain @), OR
  2. Modify the regex in extractModelDirective to more intelligently capture the separator, perhaps allowing a dedicated delimiter format for explicit overrides.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions