sub2api icon indicating copy to clipboard operation
sub2api copied to clipboard

OpenAI WS http_bridge 续轮只重放工具调用,丢失 assistant 消息和 reasoning / http_bridge follow-up turns drop assistant messages and reasoning

Open Sterbennicht opened this issue 2 months ago • 0 comments

现象

账号的 WS 模式设为 http_bridge 后,Codex 在多轮工具调用里每一轮都像第一次开口:反复重述整套计划,不记得自己上一轮说过什么。遇到需要轮询的长任务(等构建、等上传)时,表现为不断输出几乎相同的进度说明,看起来像原地循环。

原因

带 previous_response_id 的续轮,bridge 会把历史重放成完整 input 再发给上游 HTTP。但历史里只保留了上一轮响应中的工具调用:

  • openAIWSToolCallReplayCollector.addItem 只收 isCodexToolCallContextItemType 的输出项(function_call / custom_tool_call 等)
  • proxyOpenAIWSHTTPBridgeTurn 把这份列表作为 wsReplayInput,续轮的 bridgeReplayInput 由它累积
  • 含全部输出项的 allItems 只用于换账号重试(wsAccountFailoverReplayInput)

所以 assistant 消息和 reasoning(encrypted_content)在续轮中全部丢失。previous_response_id 在上游代表的是上一轮的完整输出,bridge 重建时应该与之一致。

复现

  1. 账号设为 http_bridge,Codex 的 provider 开 supports_websockets = true
  2. 让 Codex 做一个需要多轮工具调用的任务
  3. 观察每轮的 commentary:每次都重新交代目标和计划;每轮 input token 的增量也明显小于上一轮的输出加工具结果

期望

续轮重放上一轮的全部输出项(消息、reasoning、工具调用)。


Symptom

With an account in http_bridge WS mode, Codex behaves on every tool round as if it were speaking for the first time: it restates the whole plan and does not remember what it said one round earlier. On long tasks that need polling it keeps emitting near-identical progress notes, which looks like a loop.

Cause

For turns that carry previous_response_id, the bridge rebuilds a full input and sends it upstream over HTTP. The rebuilt history only keeps the tool calls of the previous response:

  • openAIWSToolCallReplayCollector.addItem only collects isCodexToolCallContextItemType items
  • proxyOpenAIWSHTTPBridgeTurn returns that list as wsReplayInput, which feeds bridgeReplayInput
  • allItems, which holds every output item, is only used for account failover (wsAccountFailoverReplayInput)

Assistant messages and reasoning items (encrypted_content) are therefore dropped on every follow-up turn. Upstream, previous_response_id stands for the complete previous output, and the rebuilt input should match that.

Expected

Follow-up turns replay every output item of the previous response.

Sterbennicht avatar Oct 01 '26 15:10 Sterbennicht