Skip to content

feat(config): make approval timeout configurable (support timeout_s=0 for unlimited) (#1823)#1837

Draft
bloodycoder wants to merge 1 commit intoMoonshotAI:mainfrom
bloodycoder:autopilot/issue-1823-approval-timeout
Draft

feat(config): make approval timeout configurable (support timeout_s=0 for unlimited) (#1823)#1837
bloodycoder wants to merge 1 commit intoMoonshotAI:mainfrom
bloodycoder:autopilot/issue-1823-approval-timeout

Conversation

@bloodycoder
Copy link
Copy Markdown

Summary

Implements #1823 by making approval request timeout configurable.

What changed

  1. Added approval.timeout_s in config (default: 300).
  2. Runtime behavior:
    • timeout > 0: finite timeout via existing timeout path
    • timeout == 0: wait indefinitely
    • internal None: still treated as unlimited mode
  3. Added validation for timeout values:
    • reject negative values
    • reject non-finite values (NaN, Inf, -Inf)
  4. Wired timeout from config into shared approval state so subagents inherit the same behavior.
  5. Updated EN/ZH config docs with unified semantics.

Files changed

  • src/kimi_cli/config.py
  • src/kimi_cli/approval_runtime/runtime.py
  • src/kimi_cli/soul/approval.py
  • src/kimi_cli/soul/agent.py
  • tests/core/test_config.py
  • tests/core/test_approval_runtime.py
  • tests/core/test_approval_timeout_config.py
  • docs/en/configuration/config-files.md
  • docs/zh/configuration/config-files.md

Expected behavior

  • Default remains 300s.
  • Users can set custom finite timeout via approval.timeout_s.
  • approval.timeout_s = 0 means unlimited wait.

Test plan

Added/updated tests for:

  • config default/valid/invalid timeout parsing
  • runtime timeout behavior (300, 0, cancellation in unlimited mode)
  • timeout config injection + subagent inheritance consistency

Current status

Draft PR due to local environment mismatch:

  • local Python: 3.9
  • repo requires: >=3.12 (.python-version is 3.14)
  • missing tools: uv, tmux

I will rerun and attach full passing logs once environment is aligned.

wbxl2000 pushed a commit to wbxl2000/kimi-cli that referenced this pull request Apr 21, 2026
When the 300s safety timeout in wait_for_response fires (e.g. the user
steps away from their SSH session), _cancel_request sets
request.feedback="approval timed out" on the record before raising
ApprovalCancelledError. The outer Approval.request was dropping that
feedback when constructing the ApprovalResult, so the downstream
ToolRejectedError fell back to the generic "Rejected by user" brief --
leaving users returning to their terminal unable to distinguish a
timeout from a manual rejection.

Read record.feedback back through the existing get_request API and pass
it into ApprovalResult. The rejection surface now reads
"Rejected: approval timed out" on the timeout path, and stays
backward-compatible for any cancel path that doesn't set feedback.

Adds:
- Assertion on the existing runtime timeout test that record.feedback is
  persisted as "approval timed out"
- New regression test driving Approval.request through the cancellation
  path and asserting both ApprovalResult.feedback and
  rejection_error().brief surface the reason

Related to MoonshotAI#1823 (only addresses the UX/display aspect; the broader
configurable-timeout feature request is tracked by MoonshotAI#1837).
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