Skip to content

Match weak-tier model-id markers as whole tokens (fixes Gemini misclassification)#352

Merged
dannon merged 1 commit into
galaxyproject:mainfrom
ishinder:fix/gemini-mini-tier-misclassification
Jun 23, 2026
Merged

Match weak-tier model-id markers as whole tokens (fixes Gemini misclassification)#352
dannon merged 1 commit into
galaxyproject:mainfrom
ishinder:fix/gemini-mini-tier-misclassification

Conversation

@ishinder

Copy link
Copy Markdown
Contributor

The problem

The brain exec-guard classifies a model as weak- or trusted-tier in
extensions/loom/exec-guard/model-tier.ts, and the weak-tier check matched its markers as
substrings of the model id:

if (WEAK_ID_MARKERS.some((m) => id.includes(m))) return "weak";

WEAK_ID_MARKERS includes "mini", and "gemini" contains it -- so
"gemini-3.1-pro-preview".includes("mini") is true and every Gemini model classifies as weak.
That check runs before the trusted-marker list and the price fallback, so it short-circuits: even
gemini-2.5-pro and gemini-1.5-pro, which are listed in TRUSTED_ID_MARKERS, come out weak, and
those two entries are unreachable dead code.

The user-visible effect: a weak-tier model never gets the trusted-workspace auto-allow (policy.ts),
so on any Gemini model "Trust this workspace" does nothing -- routine unknown commands
(curl ... | jq, or a script the agent just wrote) re-prompt on every call even in a trusted
workspace.

The fix

Match each weak marker as a whole, delimiter-separated token instead of a substring:

const idTokens = id.split(/[^a-z0-9]+/);
if (idTokens.some((tok) => WEAK_ID_MARKERS.includes(tok))) return "weak";

Every weak marker is a single token, so genuinely weak ids still match (gpt-4o-mini,
claude-3-5-haiku, gemini-2.0-flash, llama-3.1-8b), while "mini" no longer matches inside
"gemini". Gemini ids fall through to the trusted list and price fallback as intended, and the
gemini-2.5-pro / gemini-1.5-pro trusted markers are reachable again. The trusted-marker check is
left as a substring match -- those markers are longer, version-specific strings -- so there's no
behavior change for non-Gemini ids.

Tests

Extends tests/exec-guard-model-tier.test.ts with two assertions in the existing "frontier models
are trusted" block: gemini-2.5-pro and gemini-3.1-pro-preview must be trusted. Both fail on the
current substring check and pass with the token match (watched them go red, then green). Full suite
green (1237 passed / 1 skipped), npm run typecheck clean, prettier and eslint clean.

…ssification)

classifyModelTier matched WEAK_ID_MARKERS as substrings, so "mini" matched inside
"gemini" and every Gemini model was classified weak. That check runs before the
trusted-marker list and the price fallback, so it short-circuited. Even
gemini-2.5-pro / gemini-1.5-pro (which are in TRUSTED_ID_MARKERS) came out weak.

For a Gemini user this makes "Trust this workspace" inert: a weak-tier model in a
trusted workspace still prompts on every "unknown" command, since trust only
auto-allows for trusted-tier models.

Match each weak marker as a whole dash/dot-delimited token instead. Every weak
marker is a single token, so real weak ids (gpt-4o-mini, claude-3-5-haiku,
gemini-2.0-flash, llama-3.1-8b) still match, while "mini" no longer matches inside
"gemini". Gemini ids reach the trusted list / price fallback as intended, and the
gemini-2.5-pro / gemini-1.5-pro trusted markers are reachable again.

Extend the existing model-tier test with a gemini-pro regression case.
@dannon

dannon commented Jun 23, 2026

Copy link
Copy Markdown
Member

Good catch, thank you!

@dannon dannon merged commit 1b0ae44 into galaxyproject:main Jun 23, 2026
3 checks passed
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