Skip to content

fix: accept slashes, tildes, and colons in fallback model IDs - #28

Closed
Oren-Schmerling wants to merge 1 commit into
Smart-Coders-HQ:mainfrom
Oren-Schmerling:fix/model-key-allowed-chars
Closed

Oren-Schmerling wants to merge 1 commit into
Smart-Coders-HQ:mainfrom
Oren-Schmerling:fix/model-key-allowed-chars

Conversation

@Oren-Schmerling

Copy link
Copy Markdown

Problem

MODEL_KEY_RE only accepts a providerID/modelID key whose model ID matches [a-zA-Z0-9._-]. Real OpenCode model keys often contain more:

  • multi-segment IDs: openrouter/openrouter/free
  • tilde-prefixed IDs: openrouter/~deepseek/deepseek-flash-latest
  • variant suffixes: openrouter/anthropic/claude-3.5-sonnet:beta

Because one invalid entry rejects the agent's entire fallbackModels array, affected agents end up with an empty chain (fallback.no-chain) and the session stops instead of falling back.

Change

  • Relax the model-ID portion to [a-zA-Z0-9._~\/:-]{1,200} in both validators (src/config/agent-loader.ts, src/config/schema.ts).
  • No other runtime changes: the code already splits on the first / and rejoins the remainder, and health tracking keys on the full string.
  • Add regression tests for accepted and rejected keys, and document the accepted characters.

Notes

Related to #27, which relaxes the same regex for / and : but rejects ~ and adds no tests. Happy to rebase, fold into #27, or close this if #27 is preferred.

@Oren-Schmerling

Copy link
Copy Markdown
Author

Superseded by #29, which now includes the relaxed model-key regex.

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.

1 participant