The shared aiohttp.ClientSession in utils/session_pool.py is created with the library default read_bufsize (64 KiB). Some upstream providers emit a single SSE chunk that exceeds this ceiling, causing the stream to fail with:
400, message: Got more than 131072 bytes when reading: b'data: {"id":"gen-...","object":"chat.completion.chunk",...
(The 131072 = 2 × 64 KiB comes from aiohttp internally doubling the buffer once before raising.)
Triggers seen in the wild
OpenRouter routing reasoning models (Kimi K2.6, R1-style, etc.) through providers that batch the entire reasoning trace into a single chunk — observed with Novita, WandB, SiliconFlow.
Image-generation responses returned as a single large SSE message — see discussion #24543, which reports the same error signature and is currently unresolved.
There is no current env or config knob to override this; the only workaround is patching the source.
Fix
Expose AIOHTTP_READ_BUFSIZE (default 1 MiB) and pass it through to ClientSession(read_bufsize=...).
Default of 1 MiB is conservative — handles every real-world case I've reproduced while still rejecting truly runaway payloads.
Falls back gracefully on invalid/empty/negative values.
Logged at session creation alongside the other pool params.
Files
backend/open_webui/env.py — new env constant with validation.
Reproduced the failure with moonshotai/kimi-k2.6 via OpenRouter (Novita provider) on v0.9.5. With the default 64 KiB buffer the stream dies mid-reasoning; with AIOHTTP_READ_BUFSIZE=1048576 (or the new default) the stream completes cleanly through data: [DONE].
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/24928
**Author:** [@shoemoney](https://github.com/shoemoney)
**Created:** 5/19/2026
**Status:** 🔄 Open
**Base:** `dev` ← **Head:** `feat/aiohttp-read-bufsize-env-v2`
---
### 📝 Commits (1)
- [`d1a8722`](https://github.com/open-webui/open-webui/commit/d1a87225454f43f86645b4c91d419f7d1b522292) feat: configurable aiohttp read_bufsize via AIOHTTP_READ_BUFSIZE env
### 📊 Changes
**2 files changed** (+23 additions, -1 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/env.py` (+14 -0)
📝 `backend/open_webui/utils/session_pool.py` (+9 -1)
</details>
### 📄 Description
## Problem
The shared `aiohttp.ClientSession` in `utils/session_pool.py` is created with the library default `read_bufsize` (64 KiB). Some upstream providers emit a **single** SSE chunk that exceeds this ceiling, causing the stream to fail with:
```
400, message: Got more than 131072 bytes when reading: b'data: {"id":"gen-...","object":"chat.completion.chunk",...
```
(The 131072 = 2 × 64 KiB comes from aiohttp internally doubling the buffer once before raising.)
### Triggers seen in the wild
- **OpenRouter routing reasoning models** (Kimi K2.6, R1-style, etc.) through providers that batch the entire reasoning trace into a single chunk — observed with Novita, WandB, SiliconFlow.
- **Image-generation responses** returned as a single large SSE message — see discussion #24543, which reports the same error signature and is currently unresolved.
There is no current env or config knob to override this; the only workaround is patching the source.
## Fix
Expose `AIOHTTP_READ_BUFSIZE` (default **1 MiB**) and pass it through to `ClientSession(read_bufsize=...)`.
- Default of 1 MiB is conservative — handles every real-world case I've reproduced while still rejecting truly runaway payloads.
- Falls back gracefully on invalid/empty/negative values.
- Logged at session creation alongside the other pool params.
## Files
- `backend/open_webui/env.py` — new env constant with validation.
- `backend/open_webui/utils/session_pool.py` — import it, pass to `ClientSession`, update docstring + log line.
## Validated against
Reproduced the failure with `moonshotai/kimi-k2.6` via OpenRouter (Novita provider) on `v0.9.5`. With the default 64 KiB buffer the stream dies mid-reasoning; with `AIOHTTP_READ_BUFSIZE=1048576` (or the new default) the stream completes cleanly through `data: [DONE]`.
Related: #24543
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/24928
Author: @shoemoney
Created: 5/19/2026
Status: 🔄 Open
Base:
dev← Head:feat/aiohttp-read-bufsize-env-v2📝 Commits (1)
d1a8722feat: configurable aiohttp read_bufsize via AIOHTTP_READ_BUFSIZE env📊 Changes
2 files changed (+23 additions, -1 deletions)
View changed files
📝
backend/open_webui/env.py(+14 -0)📝
backend/open_webui/utils/session_pool.py(+9 -1)📄 Description
Problem
The shared
aiohttp.ClientSessioninutils/session_pool.pyis created with the library defaultread_bufsize(64 KiB). Some upstream providers emit a single SSE chunk that exceeds this ceiling, causing the stream to fail with:(The 131072 = 2 × 64 KiB comes from aiohttp internally doubling the buffer once before raising.)
Triggers seen in the wild
There is no current env or config knob to override this; the only workaround is patching the source.
Fix
Expose
AIOHTTP_READ_BUFSIZE(default 1 MiB) and pass it through toClientSession(read_bufsize=...).Files
backend/open_webui/env.py— new env constant with validation.backend/open_webui/utils/session_pool.py— import it, pass toClientSession, update docstring + log line.Validated against
Reproduced the failure with
moonshotai/kimi-k2.6via OpenRouter (Novita provider) onv0.9.5. With the default 64 KiB buffer the stream dies mid-reasoning; withAIOHTTP_READ_BUFSIZE=1048576(or the new default) the stream completes cleanly throughdata: [DONE].Related: #24543
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.