Skip to content

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Dec 22, 2025

Summary

Fixes an issue where the Chutes API returns an empty object {} at the end of their models array, which caused the entire Zod parse to fail and prevented all dynamic models from loading.

image

This change aligns the Chutes provider with the OpenRouter fallback pattern for more robust API response handling.

Changes

  • Made schema fields optional to allow graceful parsing
  • Added graceful fallback: if schema validation fails, falls back to raw response.data.data (mirrors OpenRouter pattern)
  • Added per-item validation to skip invalid entries (empty objects, missing id, missing context_length)
  • Added maxTokens fallback calculation (contextWindow * 0.2) when max_model_len is missing
  • Added 4 new test cases covering edge cases for invalid/malformed API responses

Testing

  • All 26 related tests pass (12 fetcher tests + 14 handler tests)
  • Manually verified that previously missing dynamic-only models (e.g., MiniMaxAI/MiniMax-M2) now appear in the UI

Important

Fixes Chutes API model parsing by making schema fields optional and adding fallbacks for invalid data, with new test cases for edge cases.

  • Behavior:
    • Makes all fields in ChutesModelSchema optional in chutes.ts for robust parsing of incomplete API responses.
    • Adds fallback to raw response.data.data if schema validation fails, mirroring OpenRouter pattern.
    • Skips invalid entries (empty objects, missing id, missing context_length) in getChutesModels().
    • Calculates maxTokens as contextWindow * 0.2 if max_model_len is missing.
  • Testing:
    • Adds 4 new test cases in chutes.spec.ts for edge cases: empty objects, missing id, missing context_length, and mixed valid/invalid items.
    • Confirms all 26 related tests pass, including fetcher and handler tests.
    • Manually verified dynamic-only models now appear in the UI.

This description was created by Ellipsis for 3daea7f. You can customize this summary. It will automatically update as commits are pushed.

The Chutes API returns an empty object {} at the end of their models
array, which caused the entire Zod parse to fail. This prevented all
dynamic models from loading.

This change aligns with the OpenRouter fallback pattern:
- Falls back to raw response data when schema validation fails
- Validates each model individually, skipping invalid entries
- Calculates maxTokens fallback when max_model_len is missing

Also adds comprehensive test coverage for edge cases.
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Dec 22, 2025
@roomote
Copy link
Contributor

roomote bot commented Dec 22, 2025

Oroocle Clock   See task on Roo Cloud

Re-review completed. Previously flagged item is resolved.

  • Guard context_length/max_model_len types when falling back to raw data, to avoid propagating non-number values into ModelInfo.
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 22, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 22, 2025
Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
@hannesrudolph hannesrudolph merged commit f462eeb into main Dec 22, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Dec 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Dec 22, 2025
@hannesrudolph hannesrudolph deleted the fix/chutes-model-parsing-fallback branch December 22, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants