Skip to content

feat(openai): GPT-5 previous_response_id, phase, and verbosity support#385

Draft
luosc wants to merge 3 commits intoChevey339:masterfrom
luosc:feat/gpt5.4-long-tool-stability
Draft

feat(openai): GPT-5 previous_response_id, phase, and verbosity support#385
luosc wants to merge 3 commits intoChevey339:masterfrom
luosc:feat/gpt5.4-long-tool-stability

Conversation

@luosc
Copy link
Copy Markdown
Contributor

@luosc luosc commented Mar 8, 2026

Summary

GPT-5.4 stably truncates during complex multi-tool-call chains, failing to produce a final answer (see #384). Per OpenAI docs, this is caused by missing phase
annotations and lack of previous_response_id chaining, which leads to lost reasoning state and preambles being treated as final answers.

  • Support previous_response_id for tool-call follow-ups in the Responses API, preserving reasoning items and avoiding re-reasoning across rounds
  • Add phase annotations (commentary/final_answer) on assistant messages for GPT-5.4 to prevent early stopping in long tool chains
  • Add configurable verbosity (low/medium/high) for GPT-5 family models, with input bar button (mobile sheet + desktop popover)

Closes #384

luosc added 2 commits March 8, 2026 14:55
Add previous_response_id chaining for tool-call follow-up requests
when using OpenAI's Responses API directly, preserving reasoning items
and avoiding re-reasoning across tool rounds. Add phase annotations
(commentary/final_answer) on assistant messages for GPT-5.4 to prevent
early stopping in long tool-calling chains.

Ref Chevey339#384

Signed-off-by: Shuchen Luo <nemo0806@gmail.com>
Add configurable verbosity (low/medium/high) for GPT-5 family models,
controlling output length. Passes text.verbosity for Responses API and
top-level verbosity for Chat Completions API. Adds a verbosity button
(message-circle-more icon) in the chat input bar, visible only when a
GPT-5 model is active, with mobile bottom sheet and desktop popover.

Signed-off-by: Shuchen Luo <nemo0806@gmail.com>
@luosc luosc marked this pull request as ready for review March 8, 2026 21:30
@Chevey339
Copy link
Copy Markdown
Owner

这周会比较忙,就让AI看了一下,你可以先看下

  1. verbosity 在首个 Responses 请求里会带上,但一旦进入 tool calling,后续 follow-up request 没继续带这个字段。这样用户选了 low/high,只要触发 web search / MCP / function call,最终回答就会退回默认详细度,设置实际上会失效。

  2. 现在这个入口表面上是在改“当前 assistant 的 verbosity”,但实现上会顺手改全局 SettingsProvider.verbosity,然后再把全局值写回 assistant。结果是:

    • 改 assistant A 可能会影响其他未覆写的 assistant;
    • 只要打开面板再关闭,也可能把当前全局值固化成 assistant override;
    • assistant 级别和全局 fallback 被耦合在一起了,语义不干净。
  3. 官方文档里 verbosity 是 optional,默认就是 medium。当前 UI只有 low / medium / high 三档,没有 Default/Unset 选项(不传参数的选项);用户点 medium 实际上会显式发送 "medium",不是回到默认态(“不传参数”)。

  4. 结合上一点,assistant 侧现在也没有真正“清空 verbosity override”的路径。模型层面虽然有 clearVerbosity,但这个入口没有暴露出来,所以一旦设过,基本不能回到“跟随全局/不传参数”。

  5. 我对了 OpenAI 官方文档,previous_response_id 是 Responses API 的通用链路能力,不是 GPT-5 专属;phase 也不是“所有GPT-5 都要加”的意思,文档更接近 “models like gpt-5.3-codex and beyond” 这种范围。当前实现里:

    • previous_response_id 只对直连 OpenAI host 开;
    • phase 只对 gpt-5.4* 开;
      这和官方文档不是完全一致。不是说一定错,但至少现在这套判断更像是经验性 heuristic,需要在 PR 描述/代码注释里明确为什么这么收窄。
  6. 另外 verbosity 现在是按 “modelId 命中 GPT-5 family” 来发参数,但这套文档是 OpenAI 官方 API 的语义;对于OpenRouter / 其他 OpenAI-compatible host,是否完全接受这个字段不一定。这里最好也明确一下预期:是只针对官方 OpenAI,还是确认过兼容 host 也支持。

@luosc
Copy link
Copy Markdown
Contributor Author

luosc commented Mar 9, 2026

@Chevey339 感谢详细回复,我去对齐一下OpenRouter测试一下。

@luosc luosc marked this pull request as draft March 9, 2026 17:25
Decouple input-bar verbosity from global settings so edits apply only to the current assistant, add an explicit Default option, and treat picker dismissal as no-op.

Preserve verbosity across initial and follow-up tool-call rounds for both Responses and Chat Completions, and include phase for gpt-5.4* plus gpt-5.3-codex.

Explicitly narrow request emission scope: send verbosity only for OpenAI host + GPT-5 family with valid values (low|medium|high), deferring broader OpenAI-compatible provider support (e.g. OpenRouter) to follow-up compatibility testing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPT5.4长工具链调用稳定截断无法生成答案

2 participants