feat(agent-core): drop default timeouts for print-mode background tasks - #1737
Conversation
- add `bash_task_timeout_s` config under [background] (0 = no timeout), covering the background Bash default and the re-arm after a foreground command is moved to the background on timeout - allow `[subagent] timeout_ms = 0` (no timeout) and thread it through Agent/AgentSwarm task registration and the swarm batch timer - fill both with 0 in print-mode config defaults so `kimi -p` never kills background work by wall-clock and only the model stops a task; interactive defaults are unchanged - sync the Bash tool description/parameter text with the effective default and update user docs (en/zh) plus changeset
🦋 Changeset detectedLatest commit: 30abb48 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1ae22da948
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // give it the background default so it is not still bounded by the | ||
| // shorter foreground deadline (`undefined` = no timer when the | ||
| // config disables the background timeout). | ||
| detachTimeoutMs: this.backgroundTimeoutMs, |
There was a problem hiding this comment.
Clear the foreground timer on no-timeout detach
When background.bash_task_timeout_s=0 and a foreground Bash command is manually detached (Ctrl+B/RPC) before its foreground timeout, this passes undefined as detachTimeoutMs. BackgroundManager.detach only resets the timer when detachTimeoutMs !== undefined, so the original foreground deadline remains armed and the now-background task is still killed at the foreground timeout, contrary to the no-timeout default. Pass a value that clears the timer, such as 0, or update the manager to clear on no-timeout detach.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — fixed in 30abb48. detachTimeoutMs is now 0 (clear-on-detach) instead of undefined when the background timeout is disabled, so a manually detached foreground command no longer keeps its armed foreground deadline. Added a regression test that drives a manual detach before the foreground timeout and asserts the task stays running.
…kground timeout is disabled `detach()` only re-arms when `detachTimeoutMs` is defined, so passing `undefined` with `bash_task_timeout_s = 0` kept the armed foreground deadline and a manually detached command was still killed at its foreground timeout. Pass `0` instead so the reset clears the timer. Caught by Codex review on MoonshotAI#1737.
Related Issue
No tracking issue — the problem is explained below (happy to open one for prior discussion if maintainers prefer).
Problem
In print mode (
kimi -p), background work was still bounded by interactive-era wall-clock timeouts, which breaks long headless runs:Bashtasks were killed after a 600s default timeout unless the model remembered to passtimeout/disable_timeout(observed end-to-end: a 30-minutesleeplaunched in a-prun was killed at 600s).Agent/AgentSwarm) inherited a 2h cap (72h in print mode) — still a wall-clock kill a headless run cannot reason about.Meanwhile print mode already defaults to
print_background_mode = "steer"with effectively unbounded wait limits (#1722), so the remaining per-task timeouts were the last thing that could cut a-prun's work short.What changed
Print mode (
kimi -p) now never stops background work by wall-clock; only the model itself stops a task. Interactive defaults are unchanged.[background] bash_task_timeout_sconfig (seconds;0= no timeout). It drives the default deadline for backgroundBashtasks and the re-arm deadline for foreground commands moved to the background. Explicit per-calltimeoutis still honored (and capped at 24h).[subagent] timeout_msnow accepts0= no timeout; the0is threaded throughAgent/AgentSwarmtask registration, and the swarm batch no longer armssetTimeoutfor non-positive timeouts (previously0would have aborted a task instantly).0(per-key, explicit user config always wins), alongside the existing unboundedmax_steps_per_turn.Bashtool description and JSON-schema parameter text are rewritten when the effective default is "no timeout", so the model is not told tasks die at 600s nor nudged into defensive timeout arguments.Verification:
resolveSubagentTimeoutMs0-semantics, and print-defaults fill/override; fullagent-coresuite passes (3798 tests).Bashtask launched with no timeout arguments runs to completion and its completion steers a new main turn (previously killed at 600s); a 30-minute background task keeps the run alive and is answered; concurrent mixed tasks (3 Bash + 1 subagent) each steer a turn and are all answered; one-shot crons fire and are answered before exit.config-files,tools, en/zh) updated for the new key and corrected defaults; changeset included (minor).Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.