Skip to content

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

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:idle-ttl-floor
Jul 19, 2026
Merged

Studio: enforce 60s minimum on idle auto-unload TTL (0 stays off)#7185
danielhanchen merged 4 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
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Jul 17, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 5b569d2d77

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: b74355be93

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 34fa804af5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit e9ef2ac into unslothai:main Jul 19, 2026
34 of 36 checks passed
VectorCipher pushed a commit to VectorCipher/unsloth that referenced this pull request Jul 20, 2026
…slothai#7185)

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

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Drop decorative section separator from idle TTL floor tests

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
Co-authored-by: danielhanchen <unslothshared@gmail.com>
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