fix(lmstudio): respect applied runtime context - #52188
Conversation
|
Additional verification / process notes:
Maintainers can modify the branch if you'd prefer small wording/code adjustments before merge. |
d0f8092 to
6b4cf87
Compare
|
Update: the PR branch has now been rebased onto current Post-rebase local verification: python -m pytest tests/agent/test_lmstudio_runtime_load.py tests/agent/test_model_metadata_local_ctx.py -q -o 'addopts='
# 26 passed
python -m py_compile run_agent.py agent/model_metadata.py tests/agent/test_lmstudio_runtime_load.py tests/agent/test_model_metadata_local_ctx.py
# passed |
|
Quick maintainer check: should this be reviewed independently from #36852, or folded somehow? This PR covers the runtime preload + loaded-instance fallback path, not just config lookup: Focused verification is already in the PR body ( |
|
Thanks for consolidating the two LM Studio paths. The 64K preload behavior is still present on current main ( Problems
Suggested changes
Automated hermes-sweeper review. |
6b4cf87 to
38598ba
Compare
38598ba to
89bc5f0
Compare
|
Correction: I narrowed this branch after the replacement grew beyond the reviewer request. This revision removes the fallback lifecycle, cache invalidation, and broad transaction-snapshot work from the PR. Those are useful follow-ups, but not needed for the core LM Studio context bug. Current scope is limited to:
The earlier broad rework comment is obsolete and should be ignored in favor of this narrower revision. |
… Studio loads Salvage of PR NousResearch#52188. The original PR raised RuntimeError when LM Studio load was rejected or unverifiable, which would abort agent startup on transient network failures. Replace with logger.warning + fallback to configured context length, preserving the old graceful-degradation behavior.
… Studio loads Salvage of PR #52188. The original PR raised RuntimeError when LM Studio load was rejected or unverifiable, which would abort agent startup on transient network failures. Replace with logger.warning + fallback to configured context length, preserving the old graceful-degradation behavior.
… Studio loads Salvage of PR NousResearch#52188. The original PR raised RuntimeError when LM Studio load was rejected or unverifiable, which would abort agent startup on transient network failures. Replace with logger.warning + fallback to configured context length, preserving the old graceful-degradation behavior.
What does this PR do?
Fixes LM Studio context handling so Hermes stops treating
64_000as both a preload default and a runtime-state sentinel.The replacement keeps LM Studio runtime state and allocation intent separate:
loaded_instances[].config.context_length, including 64K;context_lengthwhen Hermes has no explicit override;echo_load_configand only adopts a context length verified by LM Studio's response or a refreshed loaded-instance query;lmstudio_load_mode: jitstill skips the management preload endpoint.Related Issue
Fixes #30178
Related to #25989
#25989 asks for JIT lifecycle behavior. This PR preserves existing JIT no-preload behavior but does not redesign post-JIT reconciliation, fallback lifecycle, or multiple-instance routing.
Type of Change
Changes Made
hermes_cli/models.pycontext_lengthfor unloaded/no-override explicit loads.max_context_lengthbefore POST.echo_load_configor one refreshed catalog query before adopting runtime context.run_agent.pymax(config_context_length or 0, 64_000)LM Studio preload target.agent/agent_init.pyagent/agent_runtime_helpers.pytests/...website/docs/integrations/providers.mdcontributors/emails/git@lunarnexus.comHow to Test
Targeted local verification:
Result:
Additional checks run:
Results:
Manual smoke validation performed earlier on Linux with LM Studio: unloaded explicit-mode cold load no longer forced 64K when no Hermes context override was configured.
Checklist
Security impact
No new credential sources or auth behavior. Existing credential-safe urllib redirect handling remains covered by
tests/hermes_cli/test_urllib_security.py.Scope intentionally deferred