Match weak-tier model-id markers as whole tokens (fixes Gemini misclassification)#352
Merged
dannon merged 1 commit intoJun 23, 2026
Conversation
…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.
Member
|
Good catch, thank you! |
dannon
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 assubstrings of the model id:
WEAK_ID_MARKERSincludes"mini", and"gemini"contains it -- so"gemini-3.1-pro-preview".includes("mini")istrueand 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-proandgemini-1.5-pro, which are listed inTRUSTED_ID_MARKERS, come out weak, andthose 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
unknowncommands(
curl ... | jq, or a script the agent just wrote) re-prompt on every call even in a trustedworkspace.
The fix
Match each weak marker as a whole, delimiter-separated token instead of a substring:
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 thegemini-2.5-pro/gemini-1.5-protrusted markers are reachable again. The trusted-marker check isleft 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.tswith two assertions in the existing "frontier modelsare trusted" block:
gemini-2.5-proandgemini-3.1-pro-previewmust betrusted. Both fail on thecurrent substring check and pass with the token match (watched them go red, then green). Full suite
green (1237 passed / 1 skipped),
npm run typecheckclean, prettier and eslint clean.