Skip to content

Add model versioning to storage and cache invalidation#229

Open
kevinjosethomas wants to merge 2 commits intomainfrom
claude/preserve-cached-maia-model-75F8I
Open

Add model versioning to storage and cache invalidation#229
kevinjosethomas wants to merge 2 commits intomainfrom
claude/preserve-cached-maia-model-75F8I

Conversation

@kevinjosethomas
Copy link
Collaborator

Summary

This PR introduces model versioning to the MAIA engine's storage layer, enabling intelligent cache invalidation based on model versions rather than just URLs. This allows the model to be moved to different hosts without losing the cache, while still invalidating the cache when a new version is released.

Key Changes

  • Added version field to ModelStorage interface to track model versions alongside URLs
  • Updated storeModel() method to accept and store a modelVersion parameter
  • Updated getModel() method to accept a modelVersion parameter and implement version-aware cache validation:
    • Clears cache if version has changed (genuinely new model)
    • Updates stored URL/version if they differ but version matches (model moved to new host)
  • Extended MaiaOptions interface to include modelVersion configuration
  • Updated Maia class to track and pass modelVersion to storage operations
  • Added environment variable NEXT_PUBLIC_MAIA_MODEL_VERSION with default value of '1'

Implementation Details

  • Version mismatch triggers full cache invalidation and re-download
  • URL changes with matching version only update the stored metadata without re-downloading
  • Graceful error handling for metadata update failures with warning logs
  • Maintains backward compatibility with existing cache entries that may lack version information

https://claude.ai/code/session_01Tv2Uaz64haxYkoJWu2jrPG

Instead of deleting the cached model and forcing a ~93MB re-download
when the source URL changes, update the stored URL in-place and return
the existing cached data. The model binary is identical regardless of
which URL served it.

https://claude.ai/code/session_01T73Yphu4y2U3c3ctCcHVPf
- Version mismatch → delete cache, force re-download (new model)
- URL-only change with same version → keep cache, update stored URL
- Existing users without a version field get the cache preserved
  (the `modelData.version &&` guard handles this gracefully)

To force all clients to re-download, bump NEXT_PUBLIC_MAIA_MODEL_VERSION
(or the hardcoded default in MaiaEngineContext.tsx).

https://claude.ai/code/session_01T73Yphu4y2U3c3ctCcHVPf
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
maia-platform-frontend Building Building Preview, Comment Feb 24, 2026 11:15pm

Request Review

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.

2 participants