feat(agent-core): configurable subagent timeout with 2h default#1562
Conversation
…t to 2h - add `[subagent] timeout_ms` config (env `KIMI_SUBAGENT_TIMEOUT_MS` overrides) to replace the hardcoded 30-minute cap for Agent / AgentSwarm subagents - raise the default subagent timeout from 30 minutes to 2 hours - thread the value through tool construction so foreground and background subagents use it, with the timeout message reflecting the effective value
🦋 Changeset detectedLatest commit: 16b5771 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: 39be28da79
ℹ️ 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".
| if (Number.isInteger(parsed) && parsed >= 1) return parsed; | ||
| } | ||
| if (configMs !== undefined && Number.isInteger(configMs) && configMs >= 1) { | ||
| return configMs; |
There was a problem hiding this comment.
Clamp accepted subagent timeouts to the timer ceiling
When KIMI_SUBAGENT_TIMEOUT_MS or [subagent].timeout_ms is set above Node's 32-bit timer limit (2147483647 ms), this resolver returns the oversized value directly; BackgroundManager then passes it to setTimeout via resettableTimeoutOutcome, which schedules overflowed delays almost immediately. In that configuration, a user trying to give Agent/AgentSwarm a very long cap (for example 30 days) will instead have every subagent time out right away, so reject or clamp these values before returning them.
Useful? React with 👍 / 👎.
Two AgentTool tests hardcoded the old 30-minute default (the registered `timeoutMs`, the fake-timer advance, and the "30 minutes" message), so they broke when the default became 2 hours. Read `DEFAULT_SUBAGENT_TIMEOUT_MS` and `formatSubagentTimeoutDescription` instead so the tests follow whatever the default is.
Summary
Make the subagent run timeout configurable instead of a hardcoded 30 minutes, and raise the default to 2 hours. This lets long-running subagents (for example training or evaluation tasks launched via
Agent/AgentSwarm) run to completion, and lets users tune the cap to their needs.Related Issue
No linked issue — see the problem below.
Problem
Subagents spawned by the
AgentandAgentSwarmtools were always settled astimed_outafter a hardcoded 30-minute timeout, with no way to adjust it. Long-running subagents would be killed even while still making progress, which is especially limiting forkimi -psessions that are kept alive to wait on background work.What changed
[subagent] timeout_msconfig option (overridable by theKIMI_SUBAGENT_TIMEOUT_MSenv var) that replaces the hardcoded cap for both foreground and background subagents, includingAgentSwarm.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.