Build Policy Interpretation with Claude Opus 4.1

implementationChallenge

Prompt Content

Using the Claude Agents SDK, build the 'Compliance Policy Agent'. This agent should receive transcribed content (from the 'Content Ingestor/Analyzer Agent') and a list of policy rules. The agent must use Claude Opus 4.1's advanced reasoning to determine if the content violates any rules, identify the specific violation type, and provide a clear explanation. Configure the agent to be verbose, demonstrating its thought process in making a decision. Show how you define the agent and its interaction loop.

```python
from anthropic import Anthropic
from claude_agents.api import Agent, AgentBuilder

# Initialize Anthropic client
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))

def check_compliance(content: str, policy_rules: list[str]) -> dict:
    # Agent logic will go here. Example prompt for Claude.
    prompt = f"Given the content: '{content}' and these policy rules: {policy_rules}. " \
             "Determine if any rule is violated. If so, identify the violation type, explain why, and suggest an action." 
    
    response = client.messages.create(
        model="claude-3-opus-20240229", # Use Claude Opus 4.1
        max_tokens=1000,
        messages=[
            {"role": "user", "content": prompt}
        ]
    )
    # Parse response to structured dict
    return {"decision": "violating", "violation_type": "...", "explanation": "...", "recommended_action": "..."}

# Example of how you'd define this as an agent skill
# compliance_agent_skill = AgentBuilder(client=client).tool(
#     name="check_content_compliance",
#     description="Checks content against a set of policy rules."
# )(check_compliance)
```

Try this prompt

Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.

Usage Tips

Copy the prompt and paste it into your preferred AI tool (Claude, ChatGPT, Gemini)

Customize placeholder values with your specific requirements and context

For best results, provide clear examples and test different variations