Skip to content

feat(agent-core): configurable subagent timeout with 2h default#1562

Merged
sailist merged 2 commits into
MoonshotAI:mainfrom
sailist:feat/configurable-subagent-timeout
Jul 12, 2026
Merged

feat(agent-core): configurable subagent timeout with 2h default#1562
sailist merged 2 commits into
MoonshotAI:mainfrom
sailist:feat/configurable-subagent-timeout

Conversation

@sailist

@sailist sailist commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

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 Agent and AgentSwarm tools were always settled as timed_out after 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 for kimi -p sessions that are kept alive to wait on background work.

What changed

  • Added a [subagent] timeout_ms config option (overridable by the KIMI_SUBAGENT_TIMEOUT_MS env var) that replaces the hardcoded cap for both foreground and background subagents, including AgentSwarm.
  • Raised the default subagent timeout from 30 minutes to 2 hours when the option is unset.
  • Threaded the value through tool construction so the effective value is used, and the timeout message reflects it.
  • Documented the option (including the 32-bit timer upper bound) and added tests for config parsing and the env / config / default resolution.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

…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-bot

changeset-bot Bot commented Jul 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 16b5771

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 12, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@16b5771
npx https://pkg.pr.new/@moonshot-ai/kimi-code@16b5771

commit: 16b5771

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +49 to +52
if (Number.isInteger(parsed) && parsed >= 1) return parsed;
}
if (configMs !== undefined && Number.isInteger(configMs) && configMs >= 1) {
return configMs;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant