Python apps
Add one line, and every model call and tool call in your app is checked and shows on the agent's Activity tab.
Before you start
- If you ran
agentfox initoragentfox upand answered Y, the line is already there. Skip to step 2.
Add the line
Put it at startup, before any code that calls a model.
main.py import agentfox agentfox.auto(agent="support-triage", intent="answer customer questions about orders")agentis the name everything is recorded under. Set it, so renaming a file does not make a new agent.intentis the agent's task in a sentence. Tool containment judges an irreversible tool call against it: with no task declared, such a call is held for a person once Tool containment blocks, and recorded as would-hold while it watches (intent.undeclared_irreversible), since nothing says it is part of the job.Run your app
Run it from the folder where
initran, or set the two environment variables. At startup it prints what it patched; with a key it adds "Every check goes to your AgentFox account". Each call then shows up with the checks it went through.
Look at the issues, then block
Every library starts in Watch, so nothing is stopped. When the Issues page shows only what you want stopped, switch that library to Block (Policies → Libraries, or
agentfox policy enforce tool-containment).auto()follows the change with no code change: in its default mode the libraries decide.A line with
mode="observe"(earlier versions ofagentfox upwrote one) never blocks, whatever the libraries say: remove it.agentfox policy enforcenames any such line it finds.
Where auto() finds the account key
It takes the first of these it finds:
agentfox.auto(server="https://…", key="nom_api_…")AGENTFOX_URLandAGENTFOX_API_KEYin the environment.agentfox/agentfox.envin the working directory, whichagentfox init --keywrites
With none, the checks run in your process and are kept on this machine. In production, set the two variables:
export AGENTFOX_URL=https://…
export AGENTFOX_API_KEY=nom_api_…What auto() sends to your account
Only with a key. Each check is one HTTPS request to your account's gateway (/v1/guard/input, /v1/guard/output, /v1/guard/tool_call), with the key in the Authorization header:
- Every request: the agent's name, the environment, and the session id and
intentif you passed them. - Before a model call: the text of each message that is new since the model last answered (the user's turn and any tool results), each marked as coming from the user or from a tool.
- After it: the model's reply text, the model name and the token counts.
- Each tool call: the tool's name and its arguments, and what the tool returned.
That text is sent as it is: nothing is masked before it leaves your process, because the checks need to read it. Not sent: your source code, environment variables, files, or your model provider's API key. On the account, a run's one-line summary is masked, detector matches are kept as a type, a position and a masked sample, and a call held for a person keeps its arguments so they can decide. Settings → Retention sets how long runs are kept. The full account is on the privacy page. Without a key, nothing is sent to AgentFox.
Observe or enforce
mode | What it stops |
|---|---|
"observe" | Nothing. What would have been stopped is recorded. Use it first. |
"policy" (default) | What your rules in Block stop, a stopped agent, and a budget cap. Use it in production. |
"enforce" | Anything a rule would stop, even one still in Watch. Use it in tests and CI. |
A stopped call raises agentfox.Blocked. A refused LangChain tool hands the agent the refusal as the tool's result instead, and the run carries on.
What it covers
- Patched:
openaichat completions and the Responses API,anthropicmessages,litellm, LangChain chat models and tools, CrewAI tools,google-genai(Gemini, and Google ADK on it, including the functions it calls for the model), andhuggingface_hubchat completions and smolagents tools. Sync, async and streamed. - LangChain, LangGraph, CrewAI, LlamaIndex, AutoGen, the OpenAI Agents SDK, Google ADK, smolagents: covered through the client they call the model with. LangChain, CrewAI and smolagents tools are also checked where they run, so a CrewAI agent's text tool calls ("Action: ...") are checked too. For checks on graph nodes, see LangGraph.
- Not covered: a tool your code calls without the model asking (LangChain, CrewAI and smolagents tools excepted), and other processes. Tools OpenAI hosts (web search, file search, code interpreter) are recorded, not stopped: they ran before the response came back.
If something goes wrong
| You see | Do this |
|---|---|
| Nothing patched | None of the libraries above is installed in this Python. Check the virtual environment. |
| Nothing on Activity | auto() ran after the first model call, or no key was found. |
| Every tool call is refused in enforce mode | Give the agent its tools (Tool access), or use the default mode. |