Skip to content

fix: cache GET /api/models for five minutes - #104

Merged
caigee-cmd merged 1 commit into
mainfrom
fix/api-models-catalog-cache
Sep 6, 2026
Merged

caigee-cmd merged 1 commit into
mainfrom
fix/api-models-catalog-cache

Conversation

@caigee-cmd

Copy link
Copy Markdown
Owner

Summary

  • Cache GET /api/models for 5 minutes so the console catalog page, Access picker, and account model modal do not re-hit WorkBuddy/Trae on every load.
  • ?refresh=1 still fetches live. Overview and /v1/models stay uncached.
  • Failed catalog fetches are not stored, so a 503 is not remembered for the TTL.

Test plan

  • go test ./internal/api -count=1 -timeout 60s -run 'TestModelsAPI'
  • Open console Models twice within 5 minutes and confirm the second load does not wait on upstream.
  • Click Models refresh (?refresh=1) and confirm it still hits live catalogs.
  • Confirm Overview still fetches catalogs independently of the /api/models snapshot.

Keep Overview and /v1/models live. refresh=1 still bypasses the snapshot so operators can force a catalog reload without waiting out the TTL.
@caigee-cmd
caigee-cmd merged commit e4c18a8 into main Sep 6, 2026
6 checks passed
@caigee-cmd
caigee-cmd deleted the fix/api-models-catalog-cache branch September 19, 2026 15:02
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.

1 participant