# config.json Limits

The runtime limits `config.json` can raise, and the package defaults it cannot change.

Missing `reply_lang`, `output_dir`, and `model_tag` are filled with defaults and written back on startup. Since v1.1.2 missing limit fields are no longer filled in, and a limit can only raise its default: the effective value is `max(config value, default)`, so a smaller value is ignored.

| Key | Default | Description |
|---|---:|---|
| `limits.max_tool_iterations` | `256` | Maximum tool iterations per run (`128` before v1.1.2) |
| `limits.agent_send_timeout_seconds` | `600` | Model-request timeout |
| `limits.max_history_messages` | `16` | Recent history messages retained (`24` before v1.1.2) |
| `limits.max_history_bytes` | `4194304` | History-size ceiling. Changed from `5242880` in v1.0.12, where it became `MAX_DOCUMENT_BYTES * 4` — four times the 1 MiB single-document ceiling |

Package defaults that are **not** read from `config.json` (since v1.1.2 all of them live in `configs/configs.go`):

| Constant | Default | Description |
|---|---:|---|
| `MAX_SESSION_TASKS` | `max(NumCPU / 2, 3)` | Concurrent tasks per session; further tasks queue rather than fail (`3` from v1.1.2 to v1.2.3, `NumCPU × 4` before v1.1.2) |
| `MAX_CONCURRENT_SUBAGENTS` | `max(NumCPU / 2, 3)` | Subagent legs running at once; the rest queue (`3` before v1.3.0) |
| `MAX_SUBAGENT_TIMEOUT_MIN` | `30` | Subagent timeout in minutes |
| `MAX_RESUME_WAIT_MIN` | `60` | How long a pending resume waits for answers |
| `MAX_CONCURRENT_TOOLS` | `max(NumCPU / 2, 3)` | Concurrent tool calls within one model turn; the rest queue (v1.0.20; `5` before v1.3.0) |
| `MAX_BACKGROUND_TASKS` | `max(NumCPU / 2, 3)` | Added in v1.3.0. Background commands and background subagent legs running at once in one session; one more is refused (`run_websocket` streams: Removed in v1.3.2) |
| `MAX_BACKGROUND_TIMEOUT_MIN` | `60` | Added in v1.3.0. Upper bound and default of `background_command`'s `timeout_min` (`run_command_background` and `run_websocket`: Removed in v1.3.2) |
| `BACKGROUND_THRESHOLD_MIN` | `5` | Expected run time in minutes above which a job whose output does not decide the next step goes to `background_command` instead of `run_command` |
| `WATCH_SETTLE_SEC` / `WATCH_SETTLE_MAX_SEC` | `2` / `10` | After an error-keyword hit in `background_command` output, the watcher waits for 2 s of quiet, at most 10 s, before reporting |
| `WATCH_REPORT_COOLDOWN_SEC` | `30` | At most one watch report per 30 s per command |
| `WATCH_BUFFER_MAX_BYTES` / `WATCH_LINE_MAX_BYTES` / `WATCH_REPORT_MAX_BYTES` | `32 KiB` / `8 KiB` / `8 KiB` | Watch buffer, per-line cap, and the latest output sent with one report |

The daemon port is **not** configurable: `17989` is a package constant, and a `limits.port` entry is ignored.

There are **no environment variables** for runtime limits — env-based overrides were removed; `config.json` is the only knob.
