feat(config): make approval timeout configurable (support timeout_s=0 for unlimited) (#1823)#1837
Draft
bloodycoder wants to merge 1 commit intoMoonshotAI:mainfrom
Draft
Conversation
5 tasks
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #1823 by making approval request timeout configurable.
What changed
approval.timeout_sin config (default:300).timeout > 0: finite timeout via existing timeout pathtimeout == 0: wait indefinitelyNone: still treated as unlimited modeNaN,Inf,-Inf)Files changed
src/kimi_cli/config.pysrc/kimi_cli/approval_runtime/runtime.pysrc/kimi_cli/soul/approval.pysrc/kimi_cli/soul/agent.pytests/core/test_config.pytests/core/test_approval_runtime.pytests/core/test_approval_timeout_config.pydocs/en/configuration/config-files.mddocs/zh/configuration/config-files.mdExpected behavior
300s.approval.timeout_s.approval.timeout_s = 0means unlimited wait.Test plan
Added/updated tests for:
300,0, cancellation in unlimited mode)Current status
Draft PR due to local environment mismatch:
3.9>=3.12(.python-versionis3.14)uv,tmuxI will rerun and attach full passing logs once environment is aligned.