← ClaudeAtlas

integrate-arcjet-guard-langchain-pylisted

Integrate Arcjet Guard into Python LangChain — wrap a BaseTool you call with guard_tool, put ArcjetMiddleware + ToolPolicy on create_agent, or observe a chain with ArcjetCaptureHandler. Use when asked to add Arcjet to LangChain, create_agent, langchain-core tools, rate limit those tools, screen inbound messages, or block prompt injection / PII. This is Python LangChain, not LangChain JS createAgent and not LangGraph JS.
arcjet/arcjet-plugin · ★ 1 · AI & Automation · score 80
Install: claude install-skill arcjet/arcjet-plugin
# Integrate Arcjet Guard into Python LangChain `arcjet.guard.langchain` wraps the agent's existing Arcjet client. It never talks to the Arcjet API itself. Shared Guard fundamentals (client, rules, labels, decisions, capture, registration) live in [../arcjet/references/guards_python.md](../arcjet/references/guards_python.md). Load that reference for anything that is not LangChain-specific. Four surfaces, one decision rule: - **Any Python callable** → `guard_action` / `guard_action_sync` in core `arcjet.guard`. No LangChain extra. Details in the shared Python Guard reference. - **A LangChain `BaseTool` you call yourself** → `guard_tool`. DENY raises `ArcjetToolDeniedError` (the tool's `handle_tool_error` may convert it). - **`create_agent` (the model chooses tools)** → `ArcjetMiddleware` + `ToolPolicy`. Tools without a policy pass through. - **Observe a chain or agent** → `ArcjetCaptureHandler` / `ArcjetAsyncCaptureHandler`. These cannot deny. This is Python `create_agent`. The merged page https://docs.arcjet.com/guards/langchain/ covers both languages — JS is `@arcjet/guard/langchain/v1` (`createAgent` / `wrapToolCall`), not this module. It is not LangGraph JS `StateGraph` / `ToolNode` (docs https://docs.arcjet.com/guards/langgraph/). Importing `arcjet.guard.langchain` does not load LangGraph. Referencing `ArcjetMiddleware` or `ToolPolicy` without `arcjet[langchain-agents]` raises and names that extra. ## Screen inbound before `agent.ainvoke` — there is no inbou