Skip to content

feat: governance hook for deterministic policy-based tool call authorization#1054

Open
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1022-governance-hook
Open

feat: governance hook for deterministic policy-based tool call authorization#1054
ashishpatel26 wants to merge 1 commit into
anthropics:mainfrom
ashishpatel26:fix/issue-1022-governance-hook

Conversation

@ashishpatel26

Copy link
Copy Markdown

Summary

  • Adds governance_hook to ClaudeAgentOptions — policy-as-code layer before every tool call
  • GovernanceDecision(allowed, reason, modified_input) to allow, block, or rewrite tool inputs
  • Fires before can_use_tool; auto-installs passthrough can_use_tool if not set
  • Supports sync and async callables

Changes Made

  • GovernanceDecision TypedDict and GovernanceHook alias in types.py
  • governance_hook field in ClaudeAgentOptions
  • Passthrough can_use_tool logic in client.py
  • Hook wired into Query._handle_permission_request() in _internal/query.py
  • Exports in __init__.py

Testing

  • tests/test_governance_hook.py added (25 tests, all passing)
  • All existing tests pass (15 pre-existing failures on this branch, none introduced)

Related Issue

Closes #1022

- GovernanceDecision TypedDict: allowed, reason, modified_input
- GovernanceHook callable type (sync and async supported)
- governance_hook field in ClaudeAgentOptions
- Passthrough can_use_tool auto-installed when only governance_hook set
- Hook fires before can_use_tool; can block or rewrite tool inputs

Resolves anthropics#1022
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.

feat: governance hook integration for deterministic tool call authorization (TealTiger)

1 participant