Android studio - how to disable timeout with self-hosted models if they need more than 10 minutes for a task. Error: Stream failed
Android studio connects to a locally hosted (same machine) LM studio server with various models (Gemma, Qwen) etc. There is no problem with relatively short tasks - as long as they take less than 10 minutes. However if I ask the agent for a more complicated…
Android studio connects to a locally hosted (same machine) LM studio server with various models (Gemma, Qwen) etc. There is no problem with relatively short tasks - as long as they take less than 10 minutes. However if I ask the agent for a more complicated task, that requires a lot of tokens and consequently takes more than 10 minutes, Android Studio disconnects from LM studio and provides the following message: Error: Stream failed Please note, when I switch to LM studio I can see that often it is still working on a complex task - the server is still running - and then it gets a message that the client (Android Studio) has disconnected. This shouldnt be a networking issue, since both applications are hosted on the same machine. It feels like there is some sort of an internal, 10 minute timeout somewhere in Android Studio. How to change it? It wouldnt be a problem to leave the computer on for whole night, so the agent / model can finish the requested work, but Android studio disconnects after 10 minutes each time - what feels like some sort of a hidden flag somewhere. Perhaps the timeout can be set somewhere in MCP.json? Please help, so far I tried: extensive googling, going through documentation posting on reddit (android studio, lm studio) opening a stack overflow question (no answers) I assume that others also use a local model to run Android studio, so you somehow had to get rid of the 10 minute time limit.
已收录讨论
I disabled timeout for my Windows client, though still think that's rather risky and crude. On the Android side, my Kotlin app uses local hosting so I don't have experience with client/server connections. So I asked my friendly Gemma 4 31B and it said: //Kotlin val client = OkHttpClient.Builder() .connectTimeout(0, TimeUnit.SECONDS) // Disable connection timeout .writeTimeout(0, TimeUnit.SECONDS) // Disable write timeout .readTimeout(0, TimeUnit.SECONDS) // Disable read timeout (waiting for LLM) .build() IMHO, a better option than disabling timeouts might be to enable server streaming via LM Studio's API with the "stream": true flag. That outputs tokens as they are being generated by the server and functions as a 'heartbeat' for this purpose. It can do more, like providing inference stats for pre-fill and t/s that your app can measure and display (optionally).
Could you please clarify: You wrote: I disabled timeout for my Windows client, though still think that's rather risky and crude. How did you do that? 2) where to put the code you wrote? Please note: my app does not connect to LM studio in any way. Android studio connects to LM studio, so the model can help me code the app. Im simply building the app with a local model and it times out. 3) "stream": true - where to put it? In fact probably I should set it to false, but I dont know where / how to do it. When I look at your post, it feels as if it was generated by some AI - 3 incomplete, very random "answers" that dont answer anything.
>When I look at your post, it feels as if it was generated by some AI - 3 incomplete, very random "answers" that dont answer anything. So my "AI answers" weren't to your liking, I see. Maybe I ran out of tokens during my comment.. Oy... lol I thought you were coding a chat/agent app in Android Studio, that's where the whole thing stemmed from. If not, then my reply doesn't apply. I believe the Android Studio client doesn't support timeout settings. An Android Studio plugin like Continue.dev might be worth looking into as it defaults to stream=on. Check the Settings->Plugins, search and install Continue, and configure the plugin to point it to LM Studio. Note: Continue.dev was recently acquired so I'm not sure about their project state, or future. I'd install the plugin now to get you out of the timeout jam but keep an eye on it as it might not be getting updates. It should work until someone wakes up and updates the Android Studio client to something proper.
I had the same issue using Xcode. I found a workaround by simply use Claude Code harness directly with my model (Qwen 3.6 27B), instead of my IDE. I don't know about Android Studio, but Xcode let access console and error messages from a terminal command, so there's no difference from using the built in harness. https://lmstudio.ai/docs/integrations/claude-code
the assertion that making it stream output might function as a heartbeat DOES sound reasonable to me, actually, but I'd expect it to have streaming enabled by default... the other statements were pretty questionable
I would definitely try using llama.cpp instead for the endpoint.
The AI agent stuff in Android Studio is super jank and minimal, especially with non Gemini models. As a paying Jetbrains customer I'm not pleased.