{"record":{"id":"fb185d55fe043050","repo":"floci-io/floci","slug":"modeltimeoutexception","errorCode":"ModelTimeoutException","errorMessage":"Proxy backend timed out: {}","messagePattern":"Proxy backend timed out: (.+?)","errorType":"error_code","errorClass":"AwsException","httpStatus":408,"severity":"error","filePath":"src/main/java/io/github/hectorvent/floci/services/bedrockruntime/backend/ProxyBackend.java","lineNumber":91,"sourceCode":"        proxyConfig.apiKey()\n                .filter(key -> !key.isBlank())\n                .ifPresent(key -> builder.header(\"Authorization\", \"Bearer \" + key));\n\n        String requestBody;\n        try {\n            requestBody = objectMapper.writeValueAsString(openAiRequest);\n        } catch (Exception e) {\n            throw new AwsException(\"InternalServerException\", \"Failed to serialize proxy request: \" + e.getMessage(), 500);\n        }\n        builder.POST(HttpRequest.BodyPublishers.ofString(requestBody));\n\n        long start = System.nanoTime();\n        HttpResponse<String> response;\n        try {\n            response = httpClient.send(builder.build(), HttpResponse.BodyHandlers.ofString());\n        } catch (HttpTimeoutException e) {\n            LOG.warnv(\"Bedrock proxy backend timed out: modelId={0}, url={1}, error={2}\", modelId, uri, e.getMessage());\n            throw new AwsException(\"ModelTimeoutException\", \"Proxy backend timed out: \" + e.getMessage(), 408);\n        } catch (Exception e) {\n            LOG.warnv(\"Bedrock proxy backend call failed: modelId={0}, url={1}, error={2}\", modelId, uri, e.getMessage());\n            throw new AwsException(\"ModelErrorException\", \"Failed to reach proxy backend: \" + e.getMessage(), 424);\n        }\n        long latencyMs = (System.nanoTime() - start) / 1_000_000;\n\n        if (response.statusCode() >= 300) {\n            LOG.warnv(\"Bedrock proxy backend returned HTTP {0}: {1}\", response.statusCode(), response.body());\n            throw new AwsException(\"ModelErrorException\",\n                    \"Proxy backend returned HTTP \" + response.statusCode() + \": \" + truncate(response.body(), 512),\n                    424);\n        }\n\n        JsonNode openAiResponse;\n        try {\n            openAiResponse = objectMapper.readTree(response.body());\n        } catch (Exception e) {\n            throw new AwsException(\"ModelErrorException\", \"Proxy backend returned malformed JSON: \" + e.getMessage(), 424);","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/floci-io/floci/blob/62ff490619e7bd3554597c28c704081b4c15add5/src/main/java/io/github/hectorvent/floci/services/bedrockruntime/backend/ProxyBackend.java#L73-L109","documentation":"The upstream proxy backend (OpenAI-compatible /chat/completions endpoint) did not answer within floci.services.bedrock-runtime.proxy.request-timeout-seconds. Java's HttpClient raised HttpTimeoutException; Floci maps it to ModelTimeoutException with HTTP 408.","triggerScenarios":"A slow local model (Ollama/vLLM cold start, long generation) exceeding the configured timeout; an overloaded proxy; a timeout set too low (default seconds).","commonSituations":"First request after starting a local LLM runtime (model load takes minutes); generating long completions; running the emulator on a constrained machine.","solutions":["Raise floci.services.bedrock-runtime.proxy.request-timeout-seconds (FLOCI_SERVICES_BEDROCK_RUNTIME_PROXY_REQUEST_TIMEOUT_SECONDS)","Warm the local model before the first request (a trivial completion)","Shorten maxTokens in the Converse request so generation finishes in time"],"exampleFix":"# before\nFLOCI_SERVICES_BEDROCK_RUNTIME_PROXY_REQUEST_TIMEOUT_SECONDS=30\n# after\nFLOCI_SERVICES_BEDROCK_RUNTIME_PROXY_REQUEST_TIMEOUT_SECONDS=300","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"RetryPolicy<Object> p = RetryPolicy.builder()\n    .handle(ModelTimeoutException.class)\n    .withDelay(Duration.ofSeconds(5))\n    .withMaxRetries(2).build();\nFailsafe.with(p).get(() -> client.converse(req));","preventionTips":["Set request-timeout-seconds generously for local LLM backends","Warm the model with a tiny completion at startup","Cap maxTokens per request to bound generation time"],"tags":["bedrock","proxy","timeout","network","floci"],"backgroundTag":null,"analyzedSha":"62ff490619e7bd3554597c28c704081b4c15add5","analyzedAt":"2026-08-14T14:25:23.764Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}