feat: auto approval w/ config granularity issue 1631 - #2095
Conversation
| skip_yolo_prompt_injection = false | ||
|
|
||
| [loop_control] | ||
| max_steps_per_turn = 500 |
There was a problem hiding this comment.
🔴 Config template hardcodes stale max_steps_per_turn = 500 instead of the current default 1000
The _DEFAULT_CONFIG_TEMPLATE at src/kimi_cli/config.py:348 sets max_steps_per_turn = 500, but the LoopControl model default was already bumped to 1000 at src/kimi_cli/config.py:79. The CHANGELOG even documents this change ("Raise default max_steps_per_turn from 500 to 1000"), and the docs at docs/en/configuration/config-files.md:73 show 1000. Every new user who gets a freshly generated config file will silently receive the old, lower limit. Additionally, the new test test_load_config_creates_template_with_comments (tests/core/test_config.py:99-102) asserts config.model_dump(...) == get_default_config().model_dump(), which will fail because the template parses to 500 while get_default_config() yields 1000.
| max_steps_per_turn = 500 | |
| max_steps_per_turn = 1000 |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf4639e8b6
ℹ️ 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".
| skip_yolo_prompt_injection = false | ||
|
|
||
| [loop_control] | ||
| max_steps_per_turn = 500 |
There was a problem hiding this comment.
Keep template max_steps_per_turn aligned with runtime default
The new default TOML template hard-codes max_steps_per_turn = 500, but LoopControl.max_steps_per_turn still defaults to 1000. On first run, load_config() now writes and validates this template, so fresh users silently get a lower step limit than the actual default model/config behavior and can hit max_steps_reached earlier. This is a regression from the intended 1000-step default and should be synchronized.
Useful? React with 👍 / 👎.
| if _GLOB_SPECIAL_RE.search(entry): | ||
| self._auto_approve_patterns.append(entry) |
There was a problem hiding this comment.
Preserve exact auto-approve entries containing glob chars
This reclassification treats any persisted action containing *, ?, [ or ] as a pattern on reload, even if it was originally approved as an exact action via approve_for_session. Because persisted state stores only raw strings, exact approvals like plugin:tool[beta] can later stop matching themselves and/or match unrelated actions after restart, widening or changing approval scope across sessions.
Useful? React with 👍 / 👎.
feat:
Wanted this feature myself. It is working live on my machine and in test cases. It does not retain directories or overrides between sessions beyond what the current kimi -r structure does. Changes integrated into config.toml. Config comments added for clarity.
Changes:
Added Support for Approved Commands (any directory). E.x. mcp:Obsidian_*
Added Support for Approved Directories (all commands). E.x. ~.kimi/plans
Related Issue
Resolve #1631
Description
src/kimi_cli/config.py
• Added default_auto_approve_actions (glob patterns) and auto_approve_workspace_dirs (relative dir names) to the Config model.
• New config files are now written from a commented TOML template with inline examples instead of a plain serialized dump.
• Added write_default_config_file(); load_config() validates the template back into a Config on first run.
src/kimi_cli/soul/agent.py
• Merges config.default_auto_approve_actions into the session's ApprovalState at startup.
• Subtracts config defaults before persisting session state so removing a pattern from config actually disables it later.
src/kimi_cli/soul/approval.py
• Auto-approve matching now supports glob patterns via fnmatch.
• Exact match is checked first for safety; then patterns like mcp:obsidian* are expanded.
src/kimi_cli/tools/file/replace.py & write.py
• Both tools read auto_approve_workspace_dirs and skip approval for paths inside those directories.
• Added is_auto_approved_dir() helper; rejects absolute paths with a warning to prevent boundary escapes.
• Plan-file auto-approve behavior is preserved alongside the new directory bypass.
Tests
• test_config.py: verifies commented template generation.
• test_session_state.py: verifies glob patterns (e.g., mcp:obsidian*) auto-approve.
• test_str_replace_file.py & test_write_file.py: verify edits/writes in configured dirs bypass approval.
Docs/Changelog
• Updated English and Chinese changelogs and config-file docs with the two new options and examples.
Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.Wanted this feature myself. It is working live on my machine and in test cases. It does not retain directories or overrides between sessions beyond what the current kimi -r structure does. Changes integrated into config.toml.
Related Issue
Resolve #1631
Description
src/kimi_cli/config.py
• Added default_auto_approve_actions (glob patterns) and auto_approve_workspace_dirs (relative dir names) to the Config model.
• New config files are now written from a commented TOML template with inline examples instead of a plain serialized dump.
• Added write_default_config_file(); load_config() validates the template back into a Config on first run.
src/kimi_cli/soul/agent.py
• Merges config.default_auto_approve_actions into the session's ApprovalState at startup.
• Subtracts config defaults before persisting session state so removing a pattern from config actually disables it later.
src/kimi_cli/soul/approval.py
• Auto-approve matching now supports glob patterns via fnmatch.
• Exact match is checked first for safety; then patterns like mcp:obsidian* are expanded.
src/kimi_cli/tools/file/replace.py & write.py
• Both tools read auto_approve_workspace_dirs and skip approval for paths inside those directories.
• Added is_auto_approved_dir() helper; rejects absolute paths with a warning to prevent boundary escapes.
• Plan-file auto-approve behavior is preserved alongside the new directory bypass.
Tests
• test_config.py: verifies commented template generation.
• test_session_state.py: verifies glob patterns (e.g., mcp:obsidian*) auto-approve.
• test_str_replace_file.py & test_write_file.py: verify edits/writes in configured dirs bypass approval.
Docs/Changelog
• Updated English and Chinese changelogs and config-file docs with the two new options and examples.
Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.