Bound replay history in the OpenAI/Grok Responses WebSocket HTTP bridge
English
The existing OpenAI/Grok Responses WebSocket HTTP bridge retains both continuation input and account-failover input for a connection. Neither sequence has a byte bound, and output items can grow those sequences on every turn. The size-triggered bridge starts on requests as large as the default 15 MiB threshold, so a handful of long sessions can consume significant memory.
Bound both replay sequences with a per-connection ceiling and a process-wide budget, release reservations on disconnect, and let a full-input request proceed when history cannot be saved. If a later incremental request needs missing or oversized history, close the WebSocket before forwarding that request so a retry can supply the full input. Cover continued requests and account failover in tests.
中文
现有 OpenAI/Grok Responses WebSocket HTTP 桥接会在连接内保存续接输入和账号故障切换输入。两份历史都没有字节上限,且每轮输出都可能增加历史。默认大小触发阈值为 15 MiB,少数长会话便可能消耗大量内存。
为两份历史增加每连接和进程级预算,断开时释放额度。无法保存历史时仍允许转发全量输入。后续增量请求若缺少完整历史或重放输入超限,在发往上游前关闭 WebSocket,使重试可以携带完整输入。测试覆盖续接和账号故障切换。