Skip to content

Add Approval capability#173

Draft
DouweM wants to merge 3 commits intomainfrom
capability/approval
Draft

Add Approval capability#173
DouweM wants to merge 3 commits intomainfrom
capability/approval

Conversation

@DouweM
Copy link
Copy Markdown
Contributor

@DouweM DouweM commented Apr 10, 2026

Summary

  • Implements Approval, a capability for human-in-the-loop tool approval workflows using wrap_tool_execute
  • Supports glob-based tool name patterns (delete_*, send_email, *), configurable approval modes (always/once/never), and sync or async approval callbacks
  • Exports as from pydantic_harness import Approval

Closes #29

Test plan

  • 22 tests covering: approval/denial, all three modes, glob pattern matching, async callbacks, for_run isolation, serialization opt-out, and internal helpers
  • pyright strict mode: 0 errors
  • ruff lint + format: clean

Design notes

Uses wrap_tool_execute to intercept tool execution inline. When DeferredToolCallsPresent (#142) lands in core, this capability can be updated to use on_node_run_error + deferred tools for a more structured flow, but the public API would remain the same.

Generated with Claude Code

DouweM and others added 3 commits April 2, 2026 05:31
Implements an `Approval` capability that intercepts tool execution via
`wrap_tool_execute` and calls a user-supplied callback to approve or deny
tool calls. Supports glob-based tool name matching and three approval modes:
`always` (ask every time), `once` (ask first time, remember for the run),
and `never` (auto-approve, for testing).

Refs #29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ol stubs

- Add direct test for mode='once' auto-approval on repeated tool calls
  (covers line 136: the cached approval branch)
- Mark tool function bodies that are intentionally never executed (denied)
  with `# pragma: no cover`

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@DouweM
Copy link
Copy Markdown
Contributor Author

DouweM commented Apr 10, 2026

Originally posted by @DouweM in #156 comment (PR was recreated)

Audit vs prior art: Approval

Worth adding now:

  • Per-tool-category modes via glob patterns
  • Approval with arg modification: callback returns bool or dict
  • Audit log: record all decisions for debugging/compliance

Follow-up opportunities:

  • Timeout on interactive approval, persistent memory across sessions

@DouweM
Copy link
Copy Markdown
Contributor Author

DouweM commented Apr 10, 2026

Originally posted by @DouweM in #156 comment (PR was recreated)

Audit vs prior art: Approval

Worth adding now:

  • Approval with arg modification: callback returns bool or dict
  • Audit log: record all decisions for debugging/compliance

Follow-up opportunities:

  • Timeout on interactive approval, persistent memory

@DouweM DouweM marked this pull request as draft April 10, 2026 15:12
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.

Approval capability

1 participant