feat: add optional before_tool_call governance hook to OrchestratorAgent#601
Open
foundationx wants to merge 1 commit into
Open
feat: add optional before_tool_call governance hook to OrchestratorAgent#601foundationx wants to merge 1 commit into
foundationx wants to merge 1 commit into
Conversation
Adds an optional before_tool_call: Callable[[str, dict], bool] param to OrchestratorAgent. The hook fires before each tool executes across all three execution paths (sequential function-calling, parallel function-calling, and structured ReAct mode). Returning False injects a denial message instead of running the tool; returning True allows normal execution. Hook defaults to None -- no behaviour change for existing users. Adds TestOrchestratorGovernanceHook to tests/agents/test_orchestrator.py with 6 tests covering every execution path and both allow/deny outcomes. 35/35 tests pass. Ruff lint clean; ruff format applied to changed files.
Collaborator
|
Thanks for the PR. Are you trying to complete #472? This is directionally useful, and I’d like to keep it open, but I don’t think it should merge as-is. A few things need tightening first:
|
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.
Adds an optional before_tool_call: Callable[[str, dict], bool] param to OrchestratorAgent. The hook fires before each tool executes across all three execution paths (sequential function-calling, parallel function-calling, and structured ReAct mode). Returning False injects a denial message instead of running the tool; returning True allows normal execution. Hook defaults to None -- no behaviour change for existing users.
Adds TestOrchestratorGovernanceHook to tests/agents/test_orchestrator.py with 6 tests covering every execution path and both allow/deny outcomes. 35/35 tests pass. Ruff lint clean; ruff format applied to changed files.
What does this PR do?
Adds an optional before_tool_call governance hook to OrchestratorAgent so callers can intercept and approve or deny tool calls before execution. The hook is wired into all three execution paths (sequential, parallel, and structured ReAct). Existing users see no behaviour change.
How was this tested?
Added TestOrchestratorGovernanceHook (6 tests) to tests/agents/test_orchestrator.py covering: no hook set, hook returns True, hook returns False, correct name/args delivered to hook, denial in parallel mode, denial in structured mode. All 35 tests pass.
Checklist
uv run pytest tests/ -v)uv run ruff check src/ tests/)uv run ruff format --check src/ tests/)