Skip to content

fix: await models.dev cache refresh when stale or missing#176

Merged
konard merged 4 commits intomainfrom
issue-175-6f5f5eeae855
Feb 14, 2026
Merged

fix: await models.dev cache refresh when stale or missing#176
konard merged 4 commits intomainfrom
issue-175-6f5f5eeae855

Conversation

@konard
Copy link
Contributor

@konard konard commented Feb 14, 2026

Summary

This PR fixes the ProviderModelNotFoundError when using short model names like kimi-k2.5-free on macOS (and other platforms).

Root Cause: Race condition in ModelsDev.get() where the refresh() call was not awaited, causing the agent to use stale or empty cache data before the network refresh completed.

Fix: Properly handle cache staleness:

  • Await refresh() when cache file doesn't exist (first run)
  • Await refresh() when cache is stale (> 1 hour old)
  • Only trigger background refresh when cache is fresh (< 1 hour old)

Changes

  • js/src/provider/models.ts: Fixed race condition by awaiting refresh for stale/missing cache
  • js/tests/models-cache.test.js: Added unit tests for ModelsDev module
  • docs/case-studies/issue-175/: Added case study documentation with root cause analysis

Test Plan

  • Unit tests for ModelsDev.get() verifying provider data is loaded
  • Unit tests verifying kimi-k2.5-free model exists in opencode provider
  • Manual testing with echo 'hi' | agent --model kimi-k2.5-free

Related Issues

References


🤖 Generated with Claude Code

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

Issue: #175
@konard konard self-assigned this Feb 14, 2026
This fixes ProviderModelNotFoundError when using short model names like
`kimi-k2.5-free` on fresh installations or after new models are added.

The root cause was a race condition in ModelsDev.get() where the
refresh() call was not awaited, causing the agent to use stale or
empty cache data before the refresh completed.

Changes:
- Await refresh() when cache file doesn't exist (first run)
- Await refresh() when cache is stale (> 1 hour old)
- Only trigger background refresh when cache is fresh
- Add detailed logging for cache state debugging
- Add unit tests for ModelsDev module
- Add case study documentation

Fixes #175

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] echo 'hi' | agent --model kimi-k2.5-free is not working on macOS fix: await models.dev cache refresh when stale or missing Feb 14, 2026
@konard konard marked this pull request as ready for review February 14, 2026 20:48
konard and others added 2 commits February 14, 2026 21:49
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard
Copy link
Contributor Author

konard commented Feb 14, 2026

🤖 Solution Draft Log

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

💰 Cost estimation:

  • Public pricing estimate: $10.881545
  • Calculated by Anthropic: $7.523605 USD
  • Difference: $-3.357940 (-30.86%)
    📎 Log file uploaded as Gist (1389KB)
    🔗 View complete solution draft log

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

@konard konard merged commit 1b995b2 into main Feb 14, 2026
8 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.

echo 'hi' | agent --model kimi-k2.5-free is not working on macOS

1 participant