Skip to content

Studio: enforce 60s minimum on idle auto-unload TTL (0 stays off)#7185

Open
NilayYadav wants to merge 2 commits into
unslothai:mainfrom
NilayYadav:idle-ttl-floor
Open

Studio: enforce 60s minimum on idle auto-unload TTL (0 stays off)#7185
NilayYadav wants to merge 2 commits into
unslothai:mainfrom
NilayYadav:idle-ttl-floor

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Problem

The opt-in idle auto-unload (#6392) accepts any TTL >= 0. A tiny value like 5s silently tears the model down between turns of an active chat, so every next turn pays a full weight reload plus re-prefill of the whole conversation (seconds of re-work per turn, growing with chat length).

Change

  • MIN_AUTO_UNLOAD_IDLE_SECONDS = 60; 0 keeps meaning "off".
  • set_openai_auto_switch rejects 1-59 with a clear ValueError (PUT route already maps it to 400).
  • Readers floor legacy stored values and UNSLOTH_MODEL_IDLE_TTL (one-time warning for the env var, since headless deploys have no UI to surface an error), so pre-floor persisted values are covered too.
  • Settings UI validates 0-or->=60 and the idle strings mention the minimum (all 11 locales).

Tests

  • Setter rejects below-floor values without persisting; 0/60/3600 pass through.
  • PUT route returns 400 for 30.
  • Stored legacy 5 reads back as 60 (effective + UI view); env 5 -> 60, 0 -> off, 600 unchanged.
  • python -m pytest studio/backend/tests/test_openai_auto_switch.py: 154 passed. Frontend tsc -b clean.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a minimum floor of 60 seconds for the model idle auto-unload setting (with 0 remaining as 'off') to prevent frequent model reloading during active chats. The changes include backend validation, clamping of legacy persisted values and environment variables (with a warning), frontend validation mirroring, updated localization strings across multiple languages, and comprehensive unit tests. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@NilayYadav NilayYadav marked this pull request as draft July 16, 2026 14:17
@NilayYadav NilayYadav marked this pull request as ready for review July 16, 2026 14:53
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