Hi all,
I'm trying to use Posit Assistant in RStudio with a local model served through LM Studio (Qwen3, endpoint at http://127.0.0.1:1234/v1), but I can't get Posit Assistant to recognize the model's actual context window.
Symptom: Even with a simple "hello" message, Posit Assistant explores the workspace and then fails with:
There is not enough context remaining for Posit Assistant to reply. Please start a new conversation, or delete some previous messages and manually compact the conversation with `/compact`.
The session panel shows something like 14000/4096 tokens (100%) โ the token count already exceeds the reported limit, and "conversation size: very large".
What I've verified:
- LM Studio itself is correctly configured:
curl http://localhost:1234/api/v0/models returns "max_context_length": 262144 and "loaded_context_length": 32768 (I explicitly set and reloaded the model with this context length).
- LM Studio's developer logs confirm the model is actually handling conversations well beyond 4096 tokens without any truncation (
n_tokens = 14498, truncated = 0), and each request completes successfully (Finished streaming response).
- So the real LLM backend has no problem at all โ the "not enough context" limit appears to come entirely from Posit Assistant's own internal accounting for this model, not from LM Studio.
- Requests sent to LM Studio also show
"max_tokens": 2048 for the output, suggesting Posit Assistant is falling back to hardcoded/default values (2048 output / 4096 context) because it doesn't recognize this custom local model.
What I've tried:
- Setting
positron.assistant.models.overrides.lmstudio in ~/.posit/assistant/settings.json (this key is documented for Positron/VS Code settings, but doesn't seem to apply here or wasn't picked up).
- Adding a
models array with maxInputTokens/maxOutputTokens directly under the lmstudio provider entry in ~/.posit/ai/providers.json โ no effect either.
Question: Is there a supported way, for RStudio specifically, to override the context window (maxInputTokens/maxOutputTokens) for a model served via LM Studio (or any local/custom provider)? I found GitHub issue #18217 which suggests this configuration path isn't documented yet for RStudio โ is there a workaround in the meantime, or is this a known limitation?
Posit Assistant
- Version: 1.1.0
- Build: release
- Platform: RStudio
- RStudio: 2026.07.1+147
- RStudio Protocol: 11.0
- OS: Darwin 25.6.0
- Architecture: arm64
- Runtime: Node.js v22.22.2
- Git Commit: b2a4d8b
- Build Date: 16 aoรปt 2026, 06:18
Happy to share more logs/config if useful.
Thanks!
Follow-up for anyone hitting the same issue: I got it working. Posting the solution here since this configuration path isn't in the official docs yet.
Root cause: Posit Assistant doesn't auto-detect the actual context window for custom/local providers like LM Studio โ it falls back to hardcoded defaults (4096 context / 2048 output tokens) unless you explicitly declare the model's capabilities yourself, with models.discovery disabled so it doesn't override your settings.
The fix: edit ~/.posit/ai/providers.json and declare LM Studio as a custom provider (not the built-in lmstudio provider type at the top level), with an explicit model list:
{
"providers": {
"custom": {
"my-gateway": {
"type": "lmstudio",
"baseUrl": "http://localhost:1234/v1",
"models": {
"discovery": "off",
"custom": [
{
"id": "<identifier>",
"name": "<name>",
"maxContextLength": <contextlength>,
"supportsTools": true,
"supportsImages": false,
"supportsToolResultImages": false,
"supportsWebSearch": false
}
]
},
"endpoint": "http://localhost:1234/v1"
}
}
}
}
<identifier> = the exact "id" field returned by curl http://localhost:1234/api/v0/models
<name> = whatever display name you want
<contextlength> = the context length you set for the model in LM Studio (check with the same curl command, field loaded_context_length)
Steps:
- Edit
~/.posit/ai/providers.json as above.
- Restart Posit Assistant: close the Posit Assistant pane, then Session โ Restart R, and reopen the pane.
- Go to Configure LLM Providers, select
my-gateway, and click Configure.
A few things worth noting for anyone debugging this themselves:
- The
positron.assistant.models.overrides.<provider> setting documented for Positron/VS Code does not apply here โ it's a different settings mechanism.
- The field names differ too: it's
maxContextLength here, not maxInputTokens/maxOutputTokens.
curl http://localhost:1234/api/v0/models (LM Studio's own API) and LM Studio's Developer Logs were very useful for confirming that the actual LLM backend had no problem handling large contexts โ the limit really was coming from Posit Assistant's model metadata, not from LM Studio itself.
Credit to GaryR for the syntax, found in the posit-ai.pdf doc draft shared here.
If anyone finds a simpler or more elegant way to do this, I'd love to hear it!
1 Like
This looks like a RStudio/Posit Assistant limitation, not an LM Studio problem. LM Studio supports the larger context, but Posit Assistant appears to fall back to its default 4096-token limit for custom LM Studio models.
The providers.json and Positron override settings do not seem to be supported by RStudio yet. So currently, there may be no documented workaround to manually override maxInputTokens/maxOutputTokens in RStudio. GitHub issue #18217 is likely the best place to track the fix.