{"record":{"id":"c24da64a114a92ef","repo":"plandex-ai/plandex","slug":"stream-timed-out-due-to-inactivity-the-model-is-n","errorCode":null,"errorMessage":"stream timed out due to inactivity. The model is not responding.","messagePattern":"stream timed out due to inactivity\\. The model is not responding\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/client_stream.go","lineNumber":134,"sourceCode":"\tdefer timer.Stop()\n\tstreamFinished := false\n\n\treceivedFirstChunk := false\n\n\t// Process stream until EOF or error\n\tfor {\n\t\tselect {\n\t\tcase <-streamCtx.Done():\n\t\t\tlog.Println(\"Stream canceled\")\n\t\t\treturn accumulator.Result(true, streamCtx.Err()), streamCtx.Err()\n\t\tcase <-timer.C:\n\t\t\tlog.Println(\"Stream timed out due to inactivity\")\n\t\t\tif streamFinished {\n\t\t\t\tlog.Println(\"Stream finished—timed out waiting for usage chunk\")\n\t\t\t\treturn accumulator.Result(false, nil), nil\n\t\t\t} else {\n\t\t\t\tlog.Println(\"Stream timed out due to inactivity\")\n\t\t\t\treturn accumulator.Result(true, fmt.Errorf(\"stream timed out due to inactivity. The model is not responding.\")), nil\n\t\t\t}\n\t\tdefault:\n\t\t\tresponse, err := stream.Recv()\n\t\t\tif err == io.EOF {\n\t\t\t\tif streamFinished {\n\t\t\t\t\treturn accumulator.Result(false, nil), nil\n\t\t\t\t}\n\n\t\t\t\terr = fmt.Errorf(\"model stream ended unexpectedly: %w\", err)\n\t\t\t\treturn accumulator.Result(true, err), err\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\terr = fmt.Errorf(\"error receiving stream chunk: %w\", err)\n\t\t\t\treturn accumulator.Result(true, err), err\n\t\t\t}\n\n\t\t\tif response.ID != \"\" {\n\t\t\t\taccumulator.SetGenerationId(response.ID)","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/client_stream.go#L116-L152","documentation":"The stream's inactivity watchdog timer fired while the stream was still open: no chunk arrived before the timeout. The library returns the accumulated partial result with this error attached (Result(true, err)) instead of propagating a hard failure. It means the model/provider accepted the request but stopped sending data.","triggerScenarios":"stream.Recv() has not returned a chunk before the inactivity timer deadline and streamFinished is false; the select's timer case fires before a Recv result or EOF.","commonSituations":"Provider outage or brownout mid-request; extremely long model 'thinking' time exceeding the inactivity timeout; hung proxy (e.g., LiteLLM) between client and provider; connection silently dropped without TCP close.","solutions":["Retry the request, possibly with a shorter prompt or lower max_tokens","Increase the inactivity timeout if the model legitimately takes long before first/next token","Check provider status page or proxy health (isLiteLLMHealthy) for outages","Verify the chosen model is actually producing output (test with a trivial prompt)","Treat the returned partial accumulator.Result(true, err) content as usable-or-discard depending on product needs"],"exampleFix":"// before: single attempt dies on idle timeout\nresult, err := processChatCompletionStream(...)\n// after: retry once on inactivity timeout\nresult, err := processChatCompletionStream(...)\nif err != nil && strings.Contains(err.Error(), \"timed out due to inactivity\") {\n    result, err = processChatCompletionStream(...) // retry\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"func isInactivityTimeout(err error) bool { return err != nil && strings.Contains(err.Error(), \"timed out due to inactivity\") }","tryCatchPattern":"result, err := call()\nif isInactivityTimeout(err) && attempt < maxAttempts {\n    time.Sleep(backoff)\n    return call()\n}","preventionTips":["Set an inactivity timeout appropriate to the model's worst-case latency","Monitor provider status and configure fallback models","Avoid routing long streams through proxies with short idle timeouts","Alert on recurring inactivity timeouts per model to catch degradations"],"tags":["streaming","timeout","llm","inactivity"],"backgroundTag":"stream-inactivity-timeout","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}