Skip to content

fix(ai-gateway): anchor model-slug regex to prevent false positives#56

Merged
Melkeydev merged 1 commit intovercel:mainfrom
dorelljames:fix/ai-gateway-model-slug-regex
Apr 14, 2026
Merged

fix(ai-gateway): anchor model-slug regex to prevent false positives#56
Melkeydev merged 1 commit intovercel:mainfrom
dorelljames:fix/ai-gateway-model-slug-regex

Conversation

@dorelljames
Copy link
Copy Markdown
Contributor

Problem

The Model slug uses hyphens validator rule in skills/ai-gateway/SKILL.md (line 22) uses \d+-\d+[)'"] — any digit-hyphen-digit followed by ), ', or ". This is much broader than the intended error class (hyphenated model version slugs like "claude-sonnet-4-5"), producing false-positive errors in agent tooling whenever those characters coincide.

Examples triggered in real usage against unrelated docs/code:

Content Erroneous match
(line 13-21): (markdown line-range) 13-21)
"00000000-0000-0000-..." (UUID string literal) 0-0"
"192.168.1.1-2" (IP range) 1-2"
"1-2" (semver pair) 1-2"

Fix

Anchor the pattern on known model-family keywords with \b word boundaries, matching the convention already used by other patterns in the same file (e.g., bashPatterns on line 15: \bvercel\s+env\s+pull\b).

\b(claude|gpt|gemini|llama|mistral|qwen|deepseek)[a-z0-9-]*-\d+-\d+[a-z0-9-]*\b

Verification

Tested against both intended targets and known false-positive cases:

Input Matches? Note
claude-sonnet-4-5 intended target
"claude-sonnet-4-5-20250514" full model ID
"anthropic/claude-sonnet-4-5" provider-prefixed slug
"openai/gpt-5-4" gpt variant
(line 13-21): line range (was FP)
"00000000-0000-0000-..." UUID (was FP)
claude-sonnet-4.6 correct dot form, no warning
1-2 (semver pair) no keyword, skipped
192.168.1.1-2 (IP) no keyword, skipped

Files

  • skills/ai-gateway/SKILL.md — regex change
  • generated/skill-manifest.json — regenerated via bun run build:manifest

The validator rule in skills/ai-gateway/SKILL.md used `\d+-\d+[)'"]`,
which matched any digit-hyphen-digit followed by a closing bracket,
quote, or apostrophe — much broader than the intended error class
(hyphenated model version slugs like "claude-sonnet-4-5").

False positives seen in real usage:
  - `(line 13-21):` — matches `13-21)` in markdown line-range references
  - `"00000000-0000-0000-0000-000000000000"` — matches `0-0"` in UUIDs
  - `"192.168.1.1-2"` — matches `1-2"` in IP ranges
  - `"1-2"` — matches `1-2"` in semver pairs

Fix: anchor the pattern on known model-family keywords with `\b` word
boundaries, matching the convention used by other patterns in the same
file (e.g., line 15: `\bvercel\s+env\s+pull\b`).

    \b(claude|gpt|gemini|llama|mistral|qwen|deepseek)[a-z0-9-]*-\d+-\d+[a-z0-9-]*\b

Still catches the intended case ("claude-sonnet-4-5",
"openai/gpt-5-4", "anthropic/claude-sonnet-4-5-20250514") while
leaving line ranges, UUIDs, IP ranges, and other incidental
digit-hyphen-digit patterns alone.

generated/skill-manifest.json regenerated via `bun run build:manifest`.
@Melkeydev Melkeydev merged commit 8db97f0 into vercel:main Apr 14, 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