ITADN

Feature Request: Add `action_guard` Parameter for centralized validation of agent tool calls

#3357Openprane-eth 创建于 2026-03-14
P
prane-ethcommented
### Feature request #### Proposed Change Introduce an `action_guard` parameter in the Python client that allows developers to define a centralized validation function for agent actions. This guard would be invoked whenever the agent attempts a tool call (including MCP actions). The guard function can decide whether to allow or block the action. Example: ```python def my_guard_function(action: ToolCall) -> GuardDecision: # This can use code-based validation or a classifier model ... # GuardDecision options: # - ALLOW # - BLOCK from text_generation import Client client = Client(...) client.chat( "Hello, can you call the tool to fetch data?", tools=[...], action_guard=my_guard_function ) async_client = AsyncClient(...) await async_client.chat( "Hello, can you call the tool to fetch data?", tools=[...], action_guard=my_guard_function ) ``` #### Behavior The guard function receives a `ToolCall` object representing the pending action. Possible outcomes: * **ALLOW** – Execute the action normally. * **BLOCK** – Prevent execution and return an error to the agent. #### Related Work * https://github.com/Pro-GenAI/Agent-Action-Guard This change is within the Python SDK and independent of the API. ### Motivation AI agents have a growing adoption across the industry, including critical applications. AI agents that have access to tools (including MCP servers) can currently call tools directly with no centralized validation layer that inspects these calls before execution, allowing harmful or disallowed tool calls to be executed without oversight. In this package, Action Guard feature automates the validation, making the workflow secure. The [Agent-Action-Guard](https://github.com/Pro-GenAI/Agent-Action-Guard) experiments proved GPT-5.3 has a safety score of 17.33%, which shows a very high vulnerability, proving the requirement for the Action Guard. #### Benefits * Centralized enforcement of action policies * Reduced boilerplate in tool implementations * Improved safety for agentic systems * Seamless integration with existing tool and MCP ecosystems If user approval is made mandatory for each action, the workflow becomes slow and inefficient. ### Your contribution The updated code is available at https://github.com/prane-eth/text-generation-inference-action-guard/tree/feature/agent-tool-call-action-guard, and will be ready for a pull request.
0 条评论