> ## Documentation Index
> Fetch the complete documentation index at: https://agentcontrol-abhi-agent-control-auth-contract-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Strands

> Add Agent Control guardrails to AWS Strands agent workflows.

Automatic safety controls for AWS Strands agents using hooks - no decorators needed.

## Quick Start

**Prerequisites:** Python 3.12+, OpenAI API key, AgentControl server

```bash theme={null}
# 1. Install
cd examples/strands_agents
uv pip install -e .

# 2. Configure
cp .env.example .env
# Edit .env: Add OPENAI_API_KEY and AGENT_CONTROL_URL

# 3. Start server (Terminal 1)
curl -fsSL https://raw.githubusercontent.com/agentcontrol/agent-control/docker-compose.yml | docker compose -f - up -d

# 4. Setup controls (Terminal 2)
cd examples/strands_agents/interactive_demo
uv run setup_interactive_controls.py

# 5. Run demo (Terminal 3)
streamlit run interactive_support_demo.py
```

Open `http://localhost:8501` and click test buttons to see safety controls in action.

## Available Demos

### Interactive Demo

Customer support agent with PII blocking and SQL injection prevention. Shows real-time safety checks in `Streamlit` UI.

### Steering Demo

Banking email agent with PII redaction. Combines AgentControl Hook (deny on tool calls) and Strands Steering (steer on LLM draft) for layered governance. Uses a two-phase draft to send flow so steer can guide before tool calls.

## How It Works

AgentControlHook provides automatic safety without code changes.

```python theme={null}
from agent_control.integrations.strands import AgentControlHook
from strands import Agent

import agent_control
agent_control.init(agent_name="my-customer-agent")

hook = AgentControlHook(agent_name="my-customer-agent")

agent = Agent(
    model=model,
    system_prompt="...",
    tools=[...],
    hooks=[hook]
)
```

Hook intercepts events, the server evaluates controls, and the hook enforces the decision.

For steer actions, the steering handler converts AgentControl steer into a Strands `Guide()` retry.

## Controls

### LLM Controls

Apply to all model interactions:

```python theme={null}
{
    "scope": {"step_types": ["llm"], "stages": ["pre"]},
    "condition": {
        "selector": {"path": "input"},
        "evaluator": {"name": "regex", "config": {"pattern": r"\d{3}-\d{2}-\d{4}"}},
    },
    "action": {"decision": "deny"}
}
```

### Tool Controls

Target specific tools:

```python theme={null}
{
    "scope": {
        "step_types": ["tool"],
        "step_names": ["lookup_order"],
        "stages": ["pre"]
    },
    "condition": {
        "selector": {"path": "input"},
        "evaluator": {"name": "regex", "config": {"pattern": r"ORD-\d+"}},
    },
    "action": {"decision": "deny"}
}
```

Hook automatically extracts tool names from events - no decorators needed.

## Architecture

```text theme={null}
User Input
  ↓
Strands fires event (BeforeToolCallEvent, AfterModelCallEvent, etc.)
  ↓
AgentControlHook intercepts → Creates Step → Calls AgentControl server
  ↓
Server evaluates controls → Returns safe or unsafe
  ↓
Hook enforces decision: Continue or Block
```

## Integration Patterns

### Basic Setup

```python theme={null}
hook = AgentControlHook(
    agent_name="my-customer-agent",
    enable_logging=True
)
```

### Steering Integration

* `AgentControlHook` for tool-stage deny (hard blocks)
* `AgentControlSteeringHandler` for LLM steer to `Guide()` (corrective guidance)

See `steering_demo/README.md` for a complete implementation.

## Source Code

View the complete example with all scripts and setup instructions:

[`Strands Agents Integration Examples`](https://github.com/agentcontrol/agent-control/tree/main/examples/strands_agents)

## Troubleshooting

### AgentControl not initialized

Run `agent_control.init()` before creating the hook.

### Controls not triggering

* Server running? `curl http://localhost:8000/health`
* Controls exist? Re-run `setup_*_controls.py`

### Import errors

Install dependencies: `uv sync` or `pip install -e .`

## Files

* `interactive_demo/` - Customer support demo with PII/SQL injection blocking
* `steering_demo/` - Banking email demo with PII redaction
