【无标题】opencode +GPT-5.x 频繁超时?一行配置解决 Provider response headers timed out

【无标题】opencode +GPT-5.x 频繁超时?一行配置解决 Provider response headers timed out

opencode + GPT-5.x 频繁超时?一行配置解决 Provider response headers timed out

前两天升级 opencode 到 1.15.11,用 GPT-5.6 的时候发现总是报错:

Provider response headers timed out after 100000ms [retrying in 1s attempt

之前明明用得好好的,升级一下就崩了。查了下 GitHub issues,发现这不是个例。

问题出在哪

opencode 从 1.15.11 开始,给 OpenAI provider 加了一个默认的headerTimeout: 10000,也就是 10 秒钟。

// 源码位置: packages/opencode/src/provider/provider.tsconstOPENAI_HEADER_TIMEOUT_DEFAULT=10_000openai:()=>Effect.succeed({options:{headerTimeout:OPENAI_HEADER_TIMEOUT_DEFAULT},}),

GPT-5.x 在 high reasoning 模式下或者处理大上下文时,首包响应经常超过 10 秒。10 秒一到,opencode 直接掐断连接并重试,就一直卡死在超时循环里。

维护者在 issue 里也确认了,这个 10 秒阈值是故意加的——因为很多用户遇到 OpenAI 长时间无响应,所以加了这个超时来兜底。但问题在于,10 秒对于 GPT-5.x 的推理场景来说太紧了。

解决办法

~/.config/opencode/opencode.json里加这三行配置:

{"provider":{"openai":{"options":{"headerTimeout":60000,"timeout":600000,"chunkTimeout":60000}}}}

然后验证配置是否生效:

opencode debug config|grep-A5"openai"

如果看到headerTimeout: 60000就说明生效了,重启 opencode 就能解决。

几个参数的作用

  • headerTimeout: 等待首包响应头的时间。之前默认 10 秒,我改成了 60 秒。如果网络特别差或者模型特别慢,可以调更大,或者直接设成false关闭限制。
  • timeout: 整个请求的总超时。默认 5 分钟,大任务可以放宽到 10 分钟以上。
  • chunkTimeout: 流式传输中两个 chunk 之间的间隔超时。如果模型输出很慢但一直在输出,这个超时不会被触发。

配置生效优先级

opencode 的配置优先级是:项目配置 > 全局配置 > 默认值。

如果你只在~/.config/opencode/opencode.json里加了,那对所有项目都生效。如果只想对某个项目生效,在项目根目录也放一个opencode.json就行。

相关 issue

  • https://github.com/anomalyco/opencode/issues/29548 — 完全一样的问题
  • https://github.com/anomalyco/opencode/issues/26602 — 本地 provider 5 分钟超时
  • https://github.com/anomalyco/opencode/issues/30252 — provider.timeout 配置不生效的追踪

一点建议

如果你也遇到了这个问题,先确认 opencode 版本是不是 1.15.11 以上,再按上面的配置改就行。如果不想设固定的超时值,headerTimeout: false可以完全禁用这个限制。

另外,GPT-5.x 的 high reasoning 模式确实慢,建议在需要深度推理的任务里单独放宽超时,日常任务用默认值就够了。