What you'll learn
- what
foxy inspectlooks for, and what it never does; - how to run it on a project, and how to read what it prints;
- what each finding means, and how to fix it;
- how to run it in CI, so a new gap fails the build;
- what a scan of your code cannot see;
- how to watch your program while it runs, and what that watch cannot see.
What it does
foxy inspect reads your project's Python files and this machine's Foxy Audit settings. It answers three questions:
- Which calls to an AI model are not inside a function decorated with
@foxy.? Those calls leave no record in your ledger.audit - For each audited function, which policy and mode would it run with on this machine, and where does each one come from?
- Which settings put your evidence at risk, such as a commitment key that is your API key?
It never imports or runs your code: it reads the files as text. It uses no network, so nothing is sent to Foxy Audit or anywhere else. It writes one folder, the report.
It also opens your spool, the file where records wait to be sent, the way foxy doctor does. On a spool an older version of the SDK wrote, that finishes the upgrade your program would make at its next start: it adds the newer columns, tables and indexes, and a fingerprint of each record's key, and on Linux and macOS it makes the file readable by your user only. Every record stays as it was.
The report holds file names, line numbers, function names and settings. It never holds the text of a prompt or a reply, and it never holds a key.
A scan reads your code; some gaps show only when the code runs. With FOXY_, your program also records what its audited functions did while they ran, and the command shows it beside the scan. Step 4 explains how.
Step 1: Run it on your project
Go to your project's folder and run the command. The dot means "this folder".
foxy inspect .
Here is a small project to try it on. It has one audited function and one call that nothing audits.
import foxy_audit as foxy
from openai import OpenAI
client = OpenAI()
@foxy.audit(policy="hipaa")
def answer(question: str) -> str:
reply = client.chat.completions.create(model="your-model", messages=[{"role": "user", "content": question}])
return reply.choices[0].message.content
def summarise(notes: str) -> str:
reply = client.chat.completions.create(model="your-model", messages=[{"role": "user", "content": notes}])
return reply.choices[0].message.content
What you should see
The output below was printed by a real run on that project, on a machine with no Foxy Audit settings. Your terminal may show a red cross in place of [X].
Foxy Audit · inspect
project : <your project>
scanned : 1 Python file, 2 AI calls, 1 audited function
3 findings: 1 high, 1 medium, 1 low
[X] COV-001 high An AI call is not inside an audited function (1) app.py:14
[X] INT-005 medium Delivery is not required under a regulated policy (1) app.py:8
[X] INT-010 low No AI system is named (1) app.py:8
Report: <your project>/.foxy-inspect/report.html
The first lines say what was scanned. Then each finding gets one line: its id, how serious it is, what it means, how many places, and the first place. Here summarise calls the model with nothing to record it.
answer uses the hipaa policy with no mode, and your workspace's setting could make that mode stricter. This machine has no API key, so it cannot read that setting. The report shows the mode as "not known on this machine" and raises no finding about it, rather than guess. Give answer mode="block", which no workspace setting changes, or run the command where your program runs with its API key.
Step 2: Read the report
The command writes two files in a folder called ., in the folder you ran it from:
report.is the one to open in a browser. It lists each finding with what it means and how to fix it, then the policy in force for each audited function, what was scanned, and this machine's settings.html report.holds the same report for your own tools. Itsjson schemafield isfoxy-.inspect- v1
A program that ran with FOXY_ adds a third file there, run. (Step 4). The folder holds a ., so the report stays out of your repository. Only your user can read the files. Set FOXY_ to put the report somewhere else. Each run replaces the last report. A folder you name keeps its own settings: the command adds its three files, and stops if a file of the same name is already there and is not one it wrote.
Each finding in the report also names the rows of Foxy Audit's regulatory crosswalk whose evidence it puts at risk. A finding is not a verdict: it never says that a law or a standard is met or broken.
The findings
| Finding | How serious | What it means | What to do |
|---|---|---|---|
COV-001 |
high | An AI call is not inside an audited function. Nothing records it. | Decorate the function that makes the call with @foxy.. |
INT-003 |
high | A regulated policy runs in observe mode. The policy is hipaa or gdpr, but nothing stops that data before the model sees it. |
Give the decorator mode="block" or mode="redact", or set FOXY_. |
INT-004 |
high | The commitment key is the API key, which Foxy Audit receives with every request. | Unset FOXY_, so the SDK uses its own key file. |
INT-005 |
medium | Delivery is not required under a regulated policy. A call can return even if its record was never confirmed. | Set FOXY_, or audit_ on the client. |
INT-006 |
medium | The spool is close to full: it holds more than 80% of what it may hold. When it is full, new records are refused. | Run foxy doctor to see why records wait, then foxy spool drain. |
INT-008 |
low | The injection classifier is off. The six injection rules still run. | Remove FOXY_. |
INT-009 |
medium | The response scan is off. The model's replies are not checked. | Set FOXY_, or block for regulated data. |
INT-010 |
low | No AI system is named, so your ledger cannot show which system made a record. | Set FOXY_, or system_ on the client or the decorator. |
The findings about settings are raised only for the clients your audited functions use. A project with no audited function gets COV-001 findings only.
Step 3: Run it in CI
Add -- with a level. The command then exits with 1 when any finding is at that level or above, which fails the build.
foxy inspect . --fail-on high
Exit codes: 0 when it ran and nothing met --, 1 when a finding did, and 2 when the folder does not exist, when the report's folder or a file in it is a link or one the command did not write, when the report cannot be written there, or when there is no report for --. Exit 1 means a finding met --, and nothing else. -- prints the whole report as JSON, and -- prints the last report again without scanning. The foxy command lists every flag.
Step 4: Watch your program while it runs
The scan reads your code. Some gaps show only when the code runs: a prompt passed under a name the SDK does not read, a reply it cannot read, a stream your code stops reading early, a request over plain HTTP, a host that is not an AI provider, a file written, a program started, or an error your function catches and hides. Turn on the watch for a client, run your program or its tests, then run foxy inspect again.
from foxy_audit import FoxyClient
foxy = FoxyClient(inspect="deep")
Or set FOXY_ in the environment, with no change to your code. Use it while you develop and test. It adds a little time to each audited call and to some of Python's own work, such as opening a file, and it changes nothing that is recorded or sent.
inspect= takes off or deep. Any other value raises ValueError, and light says it is not in this version. FOXY_ with any other value logs one line and stays off.
What you should see
Here is a program to try. Its function takes the prompt under a name the SDK does not read, and it catches the error that a reply cut short raises:
import json
from foxy_audit import FoxyClient
foxy = FoxyClient(inspect="deep")
@foxy.audit(policy="default")
def answer(user_input: str) -> str:
reply = '{"text": "' + user_input + '"' # your model's reply; here, one that was cut short
try:
return json.loads(reply)["text"]
except ValueError:
return "Sorry, please try again."
print(answer(user_input="What changed in my plan?"))
Run it with python app., then run foxy inspect .. This output was printed by a real run, on a machine with no Foxy Audit settings:
Foxy Audit · inspect
project : <your project>
scanned : 1 Python file, 0 AI calls, 1 audited function
1 finding: 0 high, 0 medium, 1 low
[X] INT-010 low No AI system is named (1) app.py:9
While it ran: 1 process recorded, 2 findings (not counted by --fail-on)
Report: <your project>/.foxy-inspect/report.html
The line before the last counts what the program recorded while it ran. report. lists it under While it ran, newest first: each process with its date, what was watched, and each audited function with its calls, its findings and the facts the watch stated. Here answer has INT-001, for the text in user_, and RUN-007, for the JSONDecodeError it caught. -- counts the scan's findings only, never these.
Each process writes its report when it exits, into run. in the report's folder, which keeps the last 50 processes. Processes that exit at the same time each keep theirs. To write it sooner, or from a worker, call:
import foxy_audit as foxy
foxy.inspector.report()
It returns what it wrote, or None when no client in the process runs deep. Each write replaces run. whole, so a write cut short leaves the last one as it was. If the report cannot be written, your program carries on, and one warning in its log names the reason.
The findings while it runs
| Finding | How serious | What it means | What to do |
|---|---|---|---|
INT-001 |
high | The prompt was not found in the call. Its arguments held text, but not under a prompt keyword such as prompt= or messages=, nor as a plain string, so the checks and the record covered an empty prompt. |
Pass the prompt as prompt= or messages=, or as a plain string argument. |
INT-002 |
medium | The reply could not be fully scanned: its shape is not one the scan knows, or the scan itself failed. | Return the provider's response object, or its text. |
INT-007 |
medium | A stream was closed before its reply was checked: your code stopped reading it or never read it, its task was cancelled, or it was still open when the report was made. | Read the stream to its end. |
RUN-001 |
high | A request was sent over plain HTTP, to a host other than this machine. | Use an https:// address. |
RUN-002 |
medium | A host that is not a known AI provider was called: not on the Inspector's list, not in FOXY_, not a proxy and not this machine. |
Add a host you expect to FOXY_. Find what calls any other. |
RUN-004 |
low | A file was written outside a temp folder: written, moved or copied there. | Keep working files in the temp folder. |
RUN-005 |
low | Another program was started. | Check that it is one you expect. |
RUN-007 |
low | An error was caught and the call carried on: an error a library raised was caught in the function, which then returned normally. | Let the error reach the caller, or return something you can tell apart from a model's reply. |
A call whose arguments hold no text, such as a scoring model's numbers or an image's bytes, raises no INT-001: the report says "no text input". A reply that is a number, an array, an image or audio raises no INT-002: the report says "not text". Neither is a fault.
What it watches, and when
It watches an audited function while it runs, and for a stream while each chunk is made, not while your code handles the chunk. It watches the function's own thread or asyncio task, and the tasks and asyncio. calls it starts while it runs. It does not watch work handed to threading., a thread pool or another process, or anything after the call returns. Foxy Audit's own work is never counted: the checks, the spool and sending, and also building a client, log_ and foxy. when your function calls them. When one audited function calls another, a finding goes to the inner one when its client runs deep. A function audited by a client that does not is watched as part of the function that called it.
A function that returns a stream counts as called once it returns, so a stream your code never reads raises INT-007. An async def stream runs nothing until your code reads its first chunk, neither your function nor Foxy Audit's checks, so one never read raises nothing: it left nothing unrecorded.
What the watch cannot see
RUN-001sees onlyhttp., whichclient urllib,requestsandurllib3use, on Python 3.10 and later. It never seeshttpx, which the OpenAI and Anthropic SDKs use, noraiohttpor a raw socket. It never guesses from a port number. Anhttps://request through a proxy first sends the proxy a plain-textCONNECTto open its tunnel; that is not counted. A plainhttp://request is counted, whether it goes through a proxy or through a tunnel that never starts encryption.RUN-002sees synchronous clients only. An asyncio client looks up its hosts on another thread, and on Windows asyncio announces no connection at all. Behind a proxy it sees the proxy, not the host behind it. A proxy is a host named inHTTP_,PROXY HTTPS_orPROXY ALL_; a host inPROXY NO_is called directly and counts like any other. The providers' hosts come from each provider's own documentation, read on 12 November 2026.PROXY RUN-004does not see SQLite files, files opened before the call, or writes in a thread the call starts. A lazy import writing its__is not counted.pycache__ RUN-005shows a program's or a document's file name only where the value can be nothing else. It says "a program" for a target with a scheme, such as a web address ormailto:, for a command given as one string, and for a name with a space in it that is not an existing file. On Windows Python gives the command as one line, so it says "a program" unless you passedexecutable=. Arguments are never shown.RUN-007needs Python 3.12 or later. It flags a retry that later succeeds, and it sees only the audited function's own code, not a helper it calls. It uses one of Python's monitoring slots. If a debugger or another tool holds them, it is off, and the report says so.- Which environment variables a call reads, and where in the world a provider runs, are not watched.
- A worker that
multiprocessingforks writes no report of its own: callfoxy.at the end of its task. Any other forked process that exits normally writes its own, starting from zero.inspector. report()
The report holds function names, file paths and line numbers, host names, program file names, argument names and the names of error types. It never holds a prompt, a reply, a web address's path or query, a program's arguments, an environment variable's value or an error's message.
What it cannot see
A scan reads your code. It does not run it, so it cannot see everything:
- calls to a provider outside its list, such as Bedrock;
- a call made through
getattr, or through a name you gave to a method, such ascreate = client.;chat. completions. create - a call made over plain HTTP, with
requestsorurllib, to a provider's address; - a LangChain model built in another file, or passed to your function;
- Google's calls in a file that imports none of
google.,generativeai google.,genai vertexaiandgoogle., such as a model built in one file and called in another;cloud. aiplatform - a client imported from a package outside the folder you scanned. Scan the folder that holds the module that builds the client.
It also flags one thing that is covered when your code runs: a helper function that makes the call, when only the function that calls the helper is decorated. Decorate the helper to clear it.
A setting your code works out when it runs, such as mode=, is shown as "set at run time". The command never guesses it.
The calls it knows are: OpenAI's chat completions, responses and completions; Anthropic's messages; Google's generate_ and chat send_, from Gemini or Vertex AI; LiteLLM's completion functions; and invoke and stream on a LangChain chat model built in the same file, or on what its methods return, such as with_ or bind_.
If it goes wrong
- "is not a folder" and exit
2: give it the folder of your project, not a file. - "not parsed" in the report: that file has a syntax error, or it uses newer Python than the one running
foxy inspect. The rest of the project is still scanned. - "was not written by foxy inspect" and exit
2: the report's folder already holds a.,gitignore report.orjson report.that the command did not write, as a project's own folder does. It never replaces one. Sethtml FOXY_to a folder of its own.INSPECT_ REPORT - "could not be written" and exit
2: the report's folder cannot be made or written, for the reason the line gives, such as a file of that name or a folder you cannot write to. Exit1only ever means a finding met--.fail- on - "is a link" and exit
2: the report's folder, or a file in it, is a link, perhaps one committed to your repository. The command never writes its report through a link. Remove the link, or setFOXY_to another folder.INSPECT_ REPORT - A mode that reads "not known on this machine": your workspace's setting could change that function's mode, and this machine cannot read it. It has no
FOXY_, no program here has fetched the setting yet, or the client's key is set in your code. NoAPI_ KEY INT-003is raised for that function. Give its decoratormode="block", or run the command where your program runs. - A
COV-001you think is wrong: the call is probably in a helper that an audited function calls. Decorate the helper, or accept the finding. - Nothing found at all: check that you ran it from the project's folder, and that your code is not inside a hidden folder or a virtual environment, which it skips.
- "the Inspector's run report was not written", a warning in your program's log: the report's folder, or
run.in it, is a link or a file the Inspector did not write, or the folder cannot be written. On Windows it also happens when another program keptjson run.open for more than a second while the report was written; the file keeps the report it had. Your program was not stopped. Setjson FOXY_to a folder of its own.INSPECT_ REPORT - "the Inspector is off in this process", a warning in your program's log: the watch could not start, for the reason the line gives, such as no usable temp folder. Your program carries on, and nothing is watched in that process until a client built later with
inspect="deep"starts it. - No "While it ran" in the report: no program here has run with
FOXY_and exited normally, or the program wrote its report to another folder. Run the command where the program ran, with the sameINSPECT= deep FOXY_.INSPECT_ REPORT
Foxy Audit