integrate-arcjet-guard-claude-managed-agents-py

Integrates Arcjet Guard into Python Claude Managed Agents to screen inbound messages and gate custom tools.

1|Updated Apr 8, 2026
One-click install
npx skills add https://github.com/arcjet/arcjet-plugin --skill integrate-arcjet-guard-claude-managed-agents-py-arcjet
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: integrate-arcjet-guard-claude-managed-agents-py
Source: https://github.com/arcjet/arcjet-plugin/tree/main/plugins/arcjet/skills/integrate-arcjet-guard-claude-managed-agents-py
Command: npx skills add https://github.com/arcjet/arcjet-plugin --skill integrate-arcjet-guard-claude-managed-agents-py-arcjet

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires arcjet, anthropic.

What problem does it solve? Hosted Claude Managed Agents run on Anthropic's infrastructure with no pre-execution hook for built-in tools, leaving inbound user messages and custom tool calls unprotected against prompt injection and abuse. This Skill shows how to add Arcjet Guard screening to those two controllable surfaces in Python. ## Core Features & Use Cases - Inbound message screening: Wrap sessions.events.send with guard_events so user.message events are evaluated by rules like DetectPromptInjection before the hosted harness reads them. - Custom tool gating: Wrap custom tool handlers with guard_custom_tool to enforce rate limits (e.g., TokenBucket) and send a user.custom_tool_result with is_error on denial instead of raising. - Caller-owned correlation: Use claude_managed_agents_context to attach your own correlation/session IDs to decisions without minting or reusing Anthropic session IDs. - Use Case: A FastAPI app hosting Claude Managed Agents screens every user message for prompt injection and rate-limits an order-lookup custom tool to 10 calls per minute per authenticated user. ## Quick Start Ask your agent to add Arcjet Guard to the Python Claude Managed Agents integration, screening inbound user messages with guard_events and gating the custom tools with guard_custom_tool.

Frequently Asked Questions about integrate-arcjet-guard-claude-managed-agents-py

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Arcjet Guard to Python Claude Managed Agents?▼

Install arcjet with the claude-managed-agents extra, launch a guard client once at module scope, then wrap sessions.events.send with guard_events for inbound screening and wrap custom tool handlers with guard_custom_tool. Both helpers default to fail-closed denial.

How do I block prompt injection on hosted Claude sessions?▼

Use guard_events with a DetectPromptInjection rule so user.message events are evaluated before sessions.events.send runs. On denial it raises ArcjetDeniedError and the message is never sent to the hosted harness.

Can I gate Anthropic built-in tools like bash or web_search?▼

No. Built-in tools default to always_allow and run on Anthropic's infrastructure, so agent.tool_use fires only after execution. Only custom tools you execute on agent.custom_tool_use can be gated with guard_custom_tool.

Is this the same as the Claude Agent SDK integration?▼

No. Claude Managed Agents uses the hosted client.beta.sessions API with guard_events and guard_custom_tool, while the Claude Agent SDK uses local query() with guard_hooks and PreToolUse. The two adapters are not interchangeable.

What happens when a custom tool call is denied?▼

The original run function is not called, and the helper sends a user.custom_tool_result containing the denial JSON with the is_error field set. You must not raise from the hosted handler, or the session will idle.

Why is arcjet pinned to a git SHA instead of PyPI?▼

The claude_managed_agents module is not yet included in the published arcjet 1.0.0 PyPI release. The Skill pins arcjet to git SHA 582372916d70311873ef24b7a72443c098b3aec9 until the module is published.