fix(agent-core-v2): refuse, don't hang, when approval is needed unattended - #10
Merged
Conversation
…ended Excluding Bash from auto-mode approval left headless runs with a tool that falls through to an ask — and nothing in a `kimi -p` session can answer one, so the process waited forever instead of finishing. Verified against a built CLI: the run never exited. Auto mode is documented as never asking questions, so treat it the way a missing broker is already treated and resolve the request as a refusal. The message names the tool and points at the [permission] allow rule, so an unattended pipeline fails with something actionable rather than hanging. This mirrors auto-mode-ask-user-question-deny, which solves the same problem for AskUserQuestion. Add FetchURL to the auto-mode exclusion set while the behaviour is safe to extend: it is the tool that sends caller-chosen bytes to a caller-chosen host, and an unattended session is where that would go unnoticed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem — a regression from the hardening work, found by running the CLI
Excluding
Bashfrom auto-mode approval (PR #5) left headless runs in a state nothing could resolve:kimi -pforces auto mode, the model callsBash, the policy chain falls through to an ask — and a print-mode session has no UI to answer it. The process hangs forever.This was not visible in the unit tests, because there the approval broker is absent and the fail-closed path (PR #2) returns a refusal. In a real session the broker is bound; it just never gets an answer.
Reproduced against a built CLI driven by a stub model endpoint: the run was still alive after 60s and had to be killed. Test suites were green throughout — this only shows up when the binary actually runs.
What changed
[permission]allow rule so an unattended pipeline fails with something actionable. It mirrorsauto-mode-ask-user-question-deny, which already solves exactly this forAskUserQuestion.FetchURLadded to the auto-mode exclusion set. It was removed from the default approve set in PR chore(hardening): stop auto-approving Bash in auto mode and FetchURL by default #5, but auto mode still approved it, so headless runs could still send caller-chosen bytes to a caller-chosen host unprompted. Safe to close now that an unreachable ask fails fast instead of hanging.Verified against the built CLI
Driven end-to-end through
dist/main.mjsagainst a local stub model endpoint (no credentials), in an isolatedKIMI_CODE_HOME:Bashin-pFetchURLin-pReadof an ordinary fileAlso confirmed unchanged in the same harness: symlink escape refused,
.envrefused,package.jsonwrite refused, and a[[permission.rules]]deny rule refusing the named tool.Testing
agent-core-v2suite green: 310 files / 4906 tests.oxlintclean on changed files (one pre-existing warning elsewhere);tsc --noEmitclean.Checklist
patch).