MoonshotAI / MoonshotAI/kimi-cli
[Bug Report]: Foreground subagent timeout defaults to 120s despite schema claiming 'no default timeout'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.4k
- Forks
- 1.3k
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Bug Report
Title: [Bug Report]: Foreground subagent timeout defaults to 120s despite schema claiming "no default timeout"
What version of Kimi Code CLI are you running?
kimi, version 1.44.0
Which platform/provider were you using?
Kimi Code platform (also reproducible with other providers)
What platform is your computer?
Linux (WSL)
What issue are you seeing?
When the root agent calls the Agent tool to spawn a foreground subagent (e.g. subagent_type="explore"), it always passes timeout: 120, causing the subagent to be killed after exactly 120 seconds with:
Agent timed out after 120s.
However, the Agent tool's JSON schema explicitly states:
"Foreground: no default timeout (runs until completion)"
And the timeout field's default in the Pydantic model is null:
# tools/agent/__init__.py
timeout: int | None = Field(
default=None,
description="...Foreground: no default timeout (runs until completion)...",
)
This creates a contradiction: the code/schema say "no default timeout", but the model's behavior is to always supply timeout: 120, effectively making 120s the hard default.
Screenshots / Evidence
Agent tool call as rendered in the TUI:
description "排查NEKO浏览器端报错"
subagent_type "explore"
timeout 120 <-- model always supplies this
prompt > 用户在浏览器直接访问 N.E.K.O (http://<IP>:<PORT>/) 时,控制台报错: ...
Agent timed out (120s)
Error returned to root agent:
error: Agent timed out after 120s.
message: Agent timed out after 120s.
Root Cause Analysis (from local source inspection)
- The
Agenttool'stimeoutparameter hasdefault=Noneintools/agent/__init__.py. - The generated JSON schema also shows
"default": null. - Yet the model consistently fills in
120when calling the tool.
This suggests the model is receiving a tool definition (either via system prompt or server-side schema augmentation) that implies the default/recommended timeout is 120 seconds, overriding the null default from the local schema.
Notably, utils/aiohttp.py sets a _DEFAULT_TIMEOUT of 120s for HTTP requests, but this is unrelated to the Agent tool's task-level timeout parameter.
Impact
- Foreground subagents doing legitimate long-running work (deep codebase exploration, complex planning) are killed after 2 minutes.
- The root agent then re-does the same exploration work itself, wasting tokens and time.
- Users must manually work around this by somehow forcing larger timeouts, but there is no user-facing configuration for foreground agent timeouts.
Expected Behavior
One of the following should be true:
-
If "no default timeout" is the intended behavior: the model should not auto-fill
timeout: 120when the user hasn't specified one. Foreground subagents should run until completion (or untilmax_steps_per_turnis hit). -
If a default timeout is intentional: it should match the CHANGELOG claim of "foreground default 10 min" (600s), not 120s. And this default should be user-configurable in
~/.kimi/config.toml(e.g.[agent] foreground_timeout_s = 600).
Suggested Fixes
Option A: Fix the model-facing schema/prompt
Ensure the tool definition presented to the model correctly reflects default: null (or no default), so the model stops auto-filling 120.
Option B: Add a user-configurable default
Add a config option in ~/.kimi/config.toml:
[agent]
foreground_timeout_s = 600 # default for foreground subagents
The Agent tool should fall back to this config value when timeout is not explicitly provided by the model.
Option C: Change the code default
Change default=None to default=600 (or 3600) in tools/agent/__init__.py so that even if the model doesn't specify, the subagent gets a reasonable timeout.
Related References
- CHANGELOG 1.28.0: "Agent tool gains an optional
timeoutparameter (foreground default 10 min, background default 15 min)" - Issue #2368: mentions that "The timeout description in the Agent tool schema claims 'Foreground: no default timeout (runs until completion)'"
Additional Context
There is currently no [agent] section in config.toml and no environment variable to control this. The only timeout config is [background].agent_task_timeout_s, which only affects background subagents.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tools/agent/init.py and inspect how the Agent schema and timeout value reach the model and foreground subagent. Compare this with utils/aiohttp.py, the CHANGELOG 1.28.0 entry, and the existing [background].agent_task_timeout_s configuration in config.toml. Done means the chosen timeout behavior, schema description, and any user configuration agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100