feat: env vars to control model inactivity timeout (QMD_MODEL_KEEP_ALIVE, QMD_MODEL_TTL)#436
Open
DmitryPogodaev wants to merge 1 commit intotobi:mainfrom
Open
feat: env vars to control model inactivity timeout (QMD_MODEL_KEEP_ALIVE, QMD_MODEL_TTL)#436DmitryPogodaev wants to merge 1 commit intotobi:mainfrom
DmitryPogodaev wants to merge 1 commit intotobi:mainfrom
Conversation
Add two environment variables to control LLM model lifecycle: - QMD_MODEL_KEEP_ALIVE=1 — disable inactivity timer entirely, keeping models and contexts in RAM indefinitely. Useful for MCP daemon mode on servers where cold-start latency (30-60s on CPU) is unacceptable. - QMD_MODEL_TTL=<seconds> — override the default 5-minute inactivity timeout. Set higher to reduce cold starts, lower to save memory. Default behavior is unchanged (5 min timeout, models disposed on idle).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In MCP daemon mode on CPU-only servers, the 5-minute inactivity timer disposes model contexts. Recreating contexts takes 500-750ms, which can exceed tight RAG timeouts (1-2s) when combined with session init overhead.
There is currently no way to control this behavior without patching
dist/index.js.Solution
Two environment variables:
QMD_MODEL_KEEP_ALIVE=1— disables the inactivity timer entirely. Models and contexts stay in RAM for the lifetime of the process. Ideal for always-on MCP servers.QMD_MODEL_TTL=<seconds>— overrides the default 300s (5 min) inactivity timeout. Allows tuning without disabling entirely.Default behavior is unchanged.
Usage
Impact
Tested on AMD EPYC 8-core (no GPU), QMD 2.0.1.