feat(agent): batch write-action approvals into one prompt (#12)#25
Merged
Conversation
The LLM can emit several write tool calls in a single response (e.g. "set reminders for the next 5 days"). Previously each one prompted the user separately, forcing one-at-a-time approval. Collect every write that still needs a decision before the execution loop, ask once with a numbered list, and record the decision per action signature so _execute_tool reuses it instead of prompting again. A lone write keeps the per-call path; the batch decision is all-or-nothing. Refactor _request_approval to share the send/await core (_await_approval). Closes #12.
One prompt for multiple writes, deny blocks all, lone write skips the batch path.
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.
What
The LLM can emit several write tool calls in a single response — "set reminders for the next 5 days", "tell Alice X and Bob Y". Until now each one prompted the user separately, so a multi-write turn meant approving one action at a time across several round-trips.
This collects every write that still needs a decision before the execution loop, asks once with a numbered list, and records the decision per action signature.
_execute_toolthen reuses those decisions instead of prompting again.Notes
write_executedbool blocking all subsequent writes) was already fixed onmainvia per-action signatures. This PR closes out the remaining "Additional note": the one-at-a-time approval UX._request_approvalrefactored to share its send/await core (_await_approval); no behaviour change for single approvals.Tests
tests/test_tools.py: one prompt for multiple writes, deny blocks all, lone write skips the batch path. Full suite: 329 passed.Closes #12.