Strands Agents + ACP: Policy & Audit Install Guide
Strands Agents is AWS’s open-source Python SDK for building agents. It fires typed events around every tool call, and one of them lets a hook cancel the call before it runs.
acp-governance plugs into those events. Before each tool call it asks the ACP gateway for an allow or deny, and after the call it sends the output back for logging and a PII scan. Your Claude Code, LangChain, and CrewAI agents can use the same workspace rules and land in the same audit log.
Starter, about 5 minutes.
pip install acp-governance, add oneHookProvider, bind the user’s JWT per request. See the runnable starter or the frameworks index.
Install
pip install acp-governance strands-agents
Minimal governed agent
from strands import Agent, tool
from strands.hooks import AfterToolCallEvent, BeforeToolCallEvent, HookProvider, HookRegistry
from acp_governance import configure, pre_tool_use, post_tool_output, set_context
configure(base_url="https://api.agenticcontrolplane.com")
class ACPHookProvider(HookProvider):
def register_hooks(self, registry: HookRegistry, **kwargs) -> None:
registry.add_callback(BeforeToolCallEvent, self.before_tool)
registry.add_callback(AfterToolCallEvent, self.after_tool)
def before_tool(self, event: BeforeToolCallEvent) -> None:
allowed, reason = pre_tool_use(event.tool_use["name"], event.tool_use.get("input") or {})
if not allowed:
event.cancel_tool = f"[ACP] Denied: {reason}"
def after_tool(self, event: AfterToolCallEvent) -> None:
if event.cancel_message is not None:
return # cancelled pre-execution; nothing ran
verdict = post_tool_output(
event.tool_use["name"], event.tool_use.get("input") or {},
"".join(b.get("text", "") for b in event.result["content"]),
)
if verdict and verdict.get("action") == "redact":
event.result = {"toolUseId": event.result["toolUseId"], "status": "success",
"content": [{"text": verdict["modified_output"]}]}
elif verdict and verdict.get("action") == "block":
event.result = {"toolUseId": event.result["toolUseId"], "status": "error",
"content": [{"text": f"[ACP] Blocked: {verdict.get('reason', '')}"}]}
@tool
def lookup_record(id: str) -> str:
"""Look up a record by ID."""
return db.records.find_one({"id": id})
agent = Agent(tools=[lookup_record], hooks=[ACPHookProvider()])
set_context(user_token=user_jwt, agent_name="my-strands-agent", agent_tier="interactive")
agent("Look up record abc-123")
One provider covers every tool registered on the agent. You don’t need per-tool decorators or wrapper functions.
What happens on every tool call
BeforeToolCallEventfires. The provider POSTs the tool name, the input, and the user JWT fromset_contextto ACP’s/govern/tool-use.- Deny: the provider sets
event.cancel_tool. Strands skips the tool function and returns an error result with the reason, and the model adapts. The executor enforces this, so the model can’t argue its way past it. - Allow: your function runs.
AfterToolCallEventfires. The output goes to/govern/tool-outputfor the audit log and a PII scan. If policy saysredactorblock, the provider rewritesevent.resultbefore it reaches the conversation. The audit row is tied to the end user’s identity.
Per-tier policy
set_context(agent_tier="...") picks the policy tier:
interactive: a human at the keyboard. The default is permissive.subagent: invoked by another agent, with no human in the immediate loop.background: autonomous and the most restrictive.api: a programmatic call from your backend.
Strands-specific notes
- Most event fields are read-only. Strands rejects writes except to the fields built for intervention:
cancel_tool,selected_tool, andtool_useon the before event, andresultandretryon the after event. The integration uses only those. - Denied calls still fire
AfterToolCallEventwithcancel_messageset. The provider skips output processing for them, since nothing ran. - Any model provider.
BedrockModel(the default),AnthropicModel,OpenAIModel,OllamaModel, and the rest share one tool executor, so the same hooks cover all of them. - Multi-agent setups. Graph and swarm nodes have their own
BeforeNodeCallEventandAfterNodeCallEvent. Each member agent carries its ownhooks=[ACPHookProvider()], so tool coverage follows the agent, not the orchestrator.
Limitations
- Fail-open. If the gateway is unreachable or returns no decision (5 s timeout,
configure(timeout_s=...)), the tool runs ungoverned. The SDK warns once per cause and appends every such call to~/.acp/lapse.log. The executor-level cancel applies only to calls the gateway answered. - Tool calls only. Model calls go straight to your provider with your own key. ACP checks and records the tool calls.
- Pre-release.
acp-governanceis on 0.x. A packagedacp-strandswith a ready-madeACPHookProvideris planned.