﻿---
title: "background_terminal_max_timeout 是空轮询上限，不是轮询间隔"
summary: "默认 300000 毫秒，只约束后台终端空的 write_stdin 轮询窗口。它不是模型少发请求的间隔，exec_command 首轮也不读这个键。"
category: config
level: intermediate
surfaces: [cli]
tags: ["background_terminal_max_timeout", "unified_exec", "后台"]
canonical: /tips/background-terminal-max-timeout/
---

# background_terminal_max_timeout 是空轮询上限，不是轮询间隔

默认 300000 毫秒，只约束后台终端空的 write_stdin 轮询窗口。它不是模型少发请求的间隔，exec_command 首轮也不读这个键。

官方默认是 5 分钟，用来替换旧键 `background_terminal_timeout`：

```toml
background_terminal_max_timeout = 300000
```

写在任何 `[table]` 之前。这是空 `write_stdin` 轮询的最大等待窗口，不是「每隔多久问一次模型」。空轮询仍有大约 5 秒的下限：模型就算请求 1 秒，运行时也会等到大约 5 秒。有新输出或进程退出会立刻返回。

不要指望把这个值调大就能少烧 token。后台任务仍可能每轮把完整历史送回模型，问「还在跑吗」。把编译、测试丢给子代理，或让长命令在前台跑完，比改这个上限更有效。

`exec_command` 启动后台命令的第一轮 yield 另有大约 30 秒上限，源码里不读 `background_terminal_max_timeout`。所以「我已经写成 5 分钟，为什么第一次还是大约 30 秒就回来」不是配置没生效。这套后台终端还要 `features.unified_exec` 生效，`/ps` 才列得出来；Windows 默认常是关的。

## 来源

- [OpenAI · Configuration reference](https://developers.openai.com/codex/config-reference)
- [openai/codex#13733](https://github.com/openai/codex/issues/13733)
