Skip to content

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 init or agentfox up and answered Y, the line is already there. Skip to step 2.
  1. 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")

    agent is the name everything is recorded under. Set it, so renaming a file does not make a new agent. intent is 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.

  2. Run your app

    Run it from the folder where init ran, 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.

    An agent's Activity tab listing runs recorded from the app, each with its checks and verdict.
  3. 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 of agentfox up wrote one) never blocks, whatever the libraries say: remove it. agentfox policy enforce names any such line it finds.

Where auto() finds the account key

It takes the first of these it finds:

  1. agentfox.auto(server="https://…", key="nom_api_…")
  2. AGENTFOX_URL and AGENTFOX_API_KEY in the environment
  3. .agentfox/agentfox.env in the working directory, which agentfox init --key writes

With none, the checks run in your process and are kept on this machine. In production, set the two variables:

bash
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 intent if 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

modeWhat 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: openai chat completions and the Responses API, anthropic messages, litellm, LangChain chat models and tools, CrewAI tools, google-genai (Gemini, and Google ADK on it, including the functions it calls for the model), and huggingface_hub chat 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 seeDo this
Nothing patchedNone of the libraries above is installed in this Python. Check the virtual environment.
Nothing on Activityauto() ran after the first model call, or no key was found.
Every tool call is refused in enforce modeGive the agent its tools (Tool access), or use the default mode.