Skip to content

Conversation

@konard
Copy link
Contributor

@konard konard commented Jan 26, 2026

Summary

This PR fixes issue #135 where users get a confusing ProviderModelNotFoundError when using incorrect model format for OpenRouter models.

Problem

User tried to use agent --model z-ai/glm-4.7 but the correct format is agent --model openrouter/z-ai/glm-4.7. The error message didn't provide any guidance on the correct format.

Root Cause

The parseModel() function splits on /, so z-ai/glm-4.7 is parsed as:

  • providerID: z-ai
  • modelID: glm-4.7

Since there's no provider named z-ai (the provider is openrouter), a ProviderModelNotFoundError is thrown.

Solution

Improved Error Messages: When a provider is not found, the code now checks if the model exists in another provider and adds a helpful suggestion to the error output.

Before: {"type":"error","message":"ProviderModelNotFoundError"}
After:  {"type":"error","message":"ProviderModelNotFoundError","hint":"Did you mean: openrouter/z-ai/glm-4.7?"}

Files Changed

  • js/src/provider/provider.ts - Added suggestion field to error and model lookup logic
  • js/src/index.js - Pass suggestion as hint in error output
  • js/.changeset/improve-provider-error-messages.md - Changeset for this fix

Note: OpenRouter documentation was already added to the repository in the main branch.

Testing

  • Lint checks pass
  • Format checks pass
  • File size checks pass
  • Changes compile correctly
  • Changeset added

Correct Usage

# Wrong (will give helpful suggestion now)
agent --model z-ai/glm-4.7

# Correct
agent --model openrouter/z-ai/glm-4.7

Fixes #135


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #135
@konard konard self-assigned this Jan 26, 2026
…r models

When users specify a model like "z-ai/glm-4.7" instead of "openrouter/z-ai/glm-4.7",
the error message now includes a helpful suggestion if the model exists in another
provider (like OpenRouter).

Changes:
- Added suggestion field to ModelNotFoundError schema
- Modified getModel() to search for the model in other providers when provider not found
- Updated error handler in index.js to include suggestion as a hint in error output
- Added OpenRouter documentation to MODELS.md with examples and model format
- Created case study documentation for issue #135

Example:
Before: "ProviderModelNotFoundError"
After: "ProviderModelNotFoundError" with hint "Did you mean: openrouter/z-ai/glm-4.7?"

Fixes #135

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Не работает модель с Openrouter fix: improve ProviderModelNotFoundError with suggestion for OpenRouter models Jan 26, 2026
@konard konard marked this pull request as ready for review January 26, 2026 10:03
@konard
Copy link
Contributor Author

konard commented Jan 26, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $4.225092 USD
  • Calculated by Anthropic: $3.333289 USD
  • Difference: $-0.891803 (-21.11%)
    📎 Log file uploaded as Gist (741KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard marked this pull request as draft January 26, 2026 10:14
@konard
Copy link
Contributor Author

konard commented Jan 26, 2026

🤖 AI Work Session Started

Starting automated work session at 2026-01-26T10:14:02.533Z

The PR has been converted to draft mode while work is in progress.

This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback.

konard and others added 2 commits January 26, 2026 11:15
Resolved conflicts in MODELS.md by accepting the comprehensive OpenRouter
documentation from main branch.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 26, 2026 10:21
@konard
Copy link
Contributor Author

konard commented Jan 26, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $3.192392 USD
  • Calculated by Anthropic: $1.728991 USD
  • Difference: $-1.463401 (-45.84%)
    📎 Log file uploaded as Gist (467KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

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.

Не работает модель с Openrouter

2 participants