Repository navigation
Description
Which version of integration_openai are you using?
5.0.0
Which version of Nextcloud are you using?
35.0.2
Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.
Brave Origin - Brave 1.97.57 (Build ufficiale) (x86_64) Chromium: 155.0.8059.80
Describe the Bug
Describe the bug
When integration_openai processes a core:text2text:multimodal-chatwithtools task with preferStreaming=true, and the upstream OpenAI-compatible endpoint closes the SSE connection after sending data: [DONE], the task takes ~75-78 seconds instead of <2s.
The delay is the same regardless of model, prompt, or upstream, and disappears entirely if $preferStreaming is forced to false inside MultimodalChatWithToolsProvider::process().
Expected Behavior
Expected behavior
Task should complete in about the time of the upstream response (<2s).
Actual behavior
Task consistently takes ~75-78s. Worker log shows:
Processing task 40 of type core:text2text:multimodal-chatwithtools
Finished processing task 40
(77 seconds apart)
To Reproduce
To Reproduce
- Nextcloud 35 + integration_openai 5.0.0 + assistant 4.1.0.
- Point integration_openai to any OpenAI-compatible local server that supports streaming and correctly sends data: [DONE] then closes the socket.
- From the assistant UI, submit any short prompt (e.g. "Rispondi solo OK").
- Watch oc_taskprocessing_tasks for the new row: started_at and ended_at will be ~77 seconds apart.
- In parallel, run curl -N against the same endpoint with the same payload: the stream finishes in <1s.
Root cause hypothesis
In StreamingService::parseStreamChatResponse():
while (!feof($body)) {
$chunk = fread($body, self::CHUNK_SIZE);
if ($chunk === false) { throw ...; }
if ($chunk === '') { continue; }
foreach ($this->parseSseChunk($chunk, $eventBuffer, $done, $usage, $choices) as $partial) {
yield $partial;
}
}
When the upstream closes the connection after sending data: [DONE], the PSR-7 stream returned by Guzzle in streamed mode does not make feof($body) return true right away; fread() remains blocked until a socket timeout fires. On my system the socket timeout is ~75s, matching net.ipv4.tcp_keepalive_intvl = 75.
The $done flag is set inside parseSseChunk when [DONE] is parsed, but the outer while (!feof($body)) does not check it, so the loop keeps reading.
Suggested fix
Break the outer loop when $done is true, and/or explicitly close the body stream once [DONE] is seen:
while (!$done && !feof($body)) {
// ...
}
or, after the foreach:
if ($done) {
fclose($body);
break;
}
(I have not tested the exact fix; forcing $preferStreaming = false in the provider eliminates the symptom, which confirms the stream parsing is the culprit.)
Environment
- Nextcloud 35.0.2
- integration_openai 5.0.0
- assistant 4.1.0
- Raspberry Pi (ARM64), DietPi/Debian
- Upstream: local OpenAI-compatible proxy on 127.0.0.1
- request_timeout = 240, localai_text_generation_time = 0
- PHP default_socket_timeout = 60, net.ipv4.tcp_keepalive_intvl = 75
Verification data
| Test | Time |
|---|---|
| curl direct to upstream, stream=false | 0.29 s |
| curl direct to upstream, stream=true | 0.77 s |
| Same task with $preferStreaming = false forced in provider | 1 s |
| Same task with default $preferStreaming = true | 77 s |
Diagnosis performed by Claude (Anthropic) on behalf of the server administrator, who provided all environment access, executed all tests, and verified all reported data. The administrator delegated the writing and publication of this issue.
Activity
edward-ly commentedon Nov 2, 2026
Hello! This may have been already fixed in #447. Please re-confirm if this bug is still happening on the
masterbranch of the app.Also, since this is your first issue, please take a look at our AI contribution policy if you haven't already, especially regarding our rules around AI-assisted issue/PR descriptions.
FurettoVolante commentedon Nov 3, 2026
You're right, I didn't see the PR #447, and thanks for pointing out the AI policy, I'll keep that in mind