Skip to content

fix(provider): strip trailing slash from model name strings - #43492

Open
AndyS77 wants to merge 1 commit into
anomalyco:devfrom
AndyS77:model-trim-slash
Open

fix(provider): strip trailing slash from model name strings#43492
AndyS77 wants to merge 1 commit into
anomalyco:devfrom
AndyS77:model-trim-slash

Conversation

@AndyS77

@AndyS77 AndyS77 commented Aug 19, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #43473

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Model names with trailing slashes (e.g. qwen3-4b/) caused lookup failures. When parseModel("qwen3-4b/") was called, split("/") produced an empty modelID (or a slash-bearing one for provider/model/), which never matched the keys in provider.models. This resulted in a ModelNotFoundError even though the model was correctly loaded and listed.

The fix strips trailing slashes with .replace(/\/+$/, "") before .split("/") in all model-string parse functions:

  • packages/opencode/src/provider/provider.tsparseModel()
  • packages/core/src/model.tsparse()
  • packages/tui/src/util/model.tsparse()
  • packages/opencode/src/cli/cmd/run.tspick()
  • packages/opencode/src/acp/config-option.tsparseModelSelection() (trimmed once at top, used in all branches)

How did you verify your code works?

Added tests for trailing-slash handling in all affected packages:

  • packages/opencode/test/provider/provider.test.ts — 3 tests: trailing slash on model, trailing slash on provider/model, multiple trailing slashes
  • packages/core/test/model.test.ts — 2 tests: basic parse, strips trailing slash
  • packages/tui/test/util/model.test.ts — 1 test: strips trailing slash
  • packages/opencode/test/acp/config-option.test.ts — 1 test: strips trailing slash from model selection

All tests pass.

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Model names with trailing slashes (e.g. 'qwen3-4b/') caused lookup
failures because split('/') produced an empty or slash-bearing modelID
that didn't match stored keys. Strip trailing slashes before splitting
in all model-string parse functions.

Closes anomalyco#43473

Co-Authored-By: zai-glm-52 <noreply@ai.local>
Agent: @bug-fix
Scope: anomalyco#43473
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

I found a related PR:

fix(core): strip trailing slash from parsed model IDs (PR #43490)

This PR appears to be addressing the exact same issue - stripping trailing slashes from model parsing. PR #43490 likely covers similar changes in the core package related to model ID parsing. You may want to check if there's any overlap in scope or if one PR should be closed in favor of the other, or if they should be consolidated.

@AndyS77

AndyS77 commented Aug 19, 2026

Copy link
Copy Markdown
Author

Thanks for the heads up. I reviewed #43490 — it fixes the same bug but only in packages/core/src/model.ts (1 file, 1 line). This PR covers the same fix across all five model-string parse functions that had the issue: parseModel in provider.ts, parse in core/model.ts, parse in tui/util/model.ts, pick in cli/cmd/run.ts, and parseModelSelection in acp/config-option.ts. Happy to consolidate if a maintainer prefers — both fix #43473.

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.

Model name not resolved due to trailing slash

1 participant