You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some tools, such as [cmd_runner](/usage/chat-buffer/tools.html#cmd-runner), require the user to approve any commands before they're executed. This can be changed by altering the config for each tool:
375
+
CodeCompanion allows you to apply safety mechanisms to its built-in tools prior to execution.
376
376
377
-
```lua
377
+
::: code-group
378
+
379
+
```lua [Require Approval] {7}
378
380
require("codecompanion").setup({
379
381
interactions= {
380
382
chat= {
381
383
tools= {
382
384
["cmd_runner"] = {
383
385
opts= {
384
-
require_approval_before=false,
386
+
require_approval_before=true,
385
387
},
386
388
},
387
-
}
388
-
}
389
-
}
389
+
},
390
+
},
391
+
},
392
+
})
393
+
```
394
+
395
+
```lua [Require Cmd Approval] {7}
396
+
require("codecompanion").setup({
397
+
interactions= {
398
+
chat= {
399
+
tools= {
400
+
["cmd_runner"] = {
401
+
opts= {
402
+
require_cmd_approval=true,
403
+
},
404
+
},
405
+
},
406
+
},
407
+
},
408
+
})
409
+
```
410
+
411
+
```lua [No YOLO'ing] {7}
412
+
require("codecompanion").setup({
413
+
interactions= {
414
+
chat= {
415
+
tools= {
416
+
["cmd_runner"] = {
417
+
opts= {
418
+
allowed_in_yolo_mode=false,
419
+
},
420
+
},
421
+
},
422
+
},
423
+
},
390
424
})
391
425
```
392
426
393
-
You can also force any tool to require your approval by adding in `opts.require_approval_before = true`.
427
+
:::
394
428
395
429
### Auto Submit (Recursion)
396
430
397
431
When a tool executes, it can be useful to automatically send its output back to the LLM. This can be achieved by the following options in your configuration:
Copy file name to clipboardExpand all lines: doc/usage/chat-buffer/tools.md
+20-10Lines changed: 20 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -334,23 +334,33 @@ In the `openai_responses` adapter, the following tools are available:
334
334
335
335
-`web_search` - Allow models to search the web for the latest information before generating a response.
336
336
337
-
## Useful Tips
337
+
## Security
338
338
339
-
### YOLO mode
339
+
CodeCompanion takes security very seriously, especially in a world of agentic code development. To that end, every effort is made to ensure that LLMs are only given the information that they need to execute a tool successfully. CodeCompanion will endeavour to make sure that the full disk path to your current working directory (cwd) in Neovim is never shared. The impact of this is that the LLM can only work within the cwd when executing tools but will minimize actions that are hard to [recover from](https://www.businessinsider.com/replit-ceo-apologizes-ai-coding-tool-delete-company-database-2025-7).
340
340
341
-
The plugin allows you to run tools on autopilot, with YOLO mode. This automatically approves any tool use instead of prompting the user, disables any diffs, submits errors and success messages and automatically saves any buffers that tools may have edited. In the chat buffer, the keymap `gty` will toggle YOLO mode on/off. Alternatively, set the global variable `vim.g.codecompanion_yolo_mode` to enable this or set it to `nil` to undo this.
341
+
### Approvals
342
342
343
-
## Security and Approvals
343
+
> [!NOTE]
344
+
> This applies to CodeCompanion's built-in tools only. ACP agents have their own tools and approval systems.
344
345
345
-
CodeCompanion takes security very seriously, especially in a world of agentic code development. To that end, every effort is made to ensure that LLMs are only given the information that they need to execute a tool successfully. CodeCompanion will endeavour to make sure that the full disk path to your current working directory (cwd) in Neovim is never shared. The impact of this is that the LLM can only work within the cwd when executing tools but will minimize actions that are hard to [recover from](https://www.businessinsider.com/replit-ceo-apologizes-ai-coding-tool-delete-company-database-2025-7).
346
+
In order to give developers the confidence to use tools, CodeCompanion has implemented a comprehensive approval system for it's built-in tools.
347
+
348
+
CodeCompanion segregates tool approvals by chat buffer and by tool. This means that if you approve a tool in one chat buffer, it is _not_ approved for use anywhere else. Similarly, if you approve a tool once, you'll be prompted to approve it again next time it's executed.
346
349
347
-
The plugin also puts approvals at the heart of its workflow. Some tools, such as the [@cmd_runner](#cmd-runner), require the user to approve any actions before they can be executed. If the tool requires this a `vim.fn.confirm` dialog will prompt you for a response. You may also [enforce](/configuration/chat-buffer#approvals) an approval for _any_ tool.
350
+
When prompted, the user has four options available to them:
348
351
349
-
When using CodeCompanion's in-built tools, there are three choices:
352
+
-**Allow always** - Always allow this tool/cmd to be executed without further prompts
353
+
-**Allow once** - Allow this tool/cmd to be executed this one time
354
+
-**Reject** - Reject the execution of this tool/cmd and provide a reason
355
+
-**Cancel** - Cancel this tool execution and all other pending tool executions
356
+
357
+
Certain tools with potentially destructive capabilities have an additional layer of protection. Instead of being approved at a tool level, these are approved at a command level. Taking the `cmd_runner` tool as an example. If you approve an agent to always run `make format`, if it tries to run `make test`, you'll be prompted to approve that command specifically.
358
+
359
+
Approvals can be reset for the given chat buffer by using the `gtx` keymap.
360
+
361
+
### YOLO mode
350
362
351
-
1.**Approve** - The tool will be executed
352
-
2.**Reject** - The tool will **NOT** be executed
353
-
3.**Cancel** - All tools in the queue will **NOT** be executed
363
+
To bypass the approval system, you can use `gty` in the chat buffer to enable YOLO mode. This will automatically approve all tool executions without prompting the user. However, note that some tools such as `cmd_runner` and `delete_file` are excluded from this.
0 commit comments