Skip to content

feat(agent): batch write-action approvals into one prompt (#12)#25

Merged
mattmezza merged 2 commits into
mainfrom
feat/batch-write-approval
Jun 25, 2026
Merged

feat(agent): batch write-action approvals into one prompt (#12)#25
mattmezza merged 2 commits into
mainfrom
feat/batch-write-approval

Conversation

@mattmezza

Copy link
Copy Markdown
Owner

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_tool then reuses those decisions instead of prompting again.

Notes

  • The agent-side guard from the original issue (single write_executed bool blocking all subsequent writes) was already fixed on main via per-action signatures. This PR closes out the remaining "Additional note": the one-at-a-time approval UX.
  • Decision is all-or-nothing across the batch (one Approve/Deny covers the list). Per-item selection would need a richer channel UI and is intentionally out of scope.
  • A lone write keeps the existing per-call path — batching only kicks in at 2+.
  • _request_approval refactored 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.

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.
@mattmezza mattmezza merged commit 6c17dd2 into main Jun 25, 2026
1 check passed
@mattmezza mattmezza deleted the feat/batch-write-approval branch June 25, 2026 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request_state write_executed guard prevents all multi-step agentic work

1 participant