Skip to main content

Flight Recorder

Record every step of an AI agent run: each model call (messages, response, tokens, cost, latency) and each tool call (arguments, result, effect), in local JSONL files you can list and read.

v0.1 records. Replay in CI, cost budgets and approval gates come in later releases.

Quickstart

Python 3.11 or newer. No API key needed.

pip install ai-flight-recorder

Save this as agent.py:

import flight_recorder as fr


@fr.tool(effect="read")
def lookup_order(order_id: str) -> dict[str, str]:
    return {"order_id": order_id, "status": "shipped"}


@fr.tool(effect="irreversible")
def issue_refund(order_id: str, amount: float) -> str:
    return f"refunded {amount} on {order_id}"


with fr.run("refund-desk", inputs={"order_id": "A-17"}) as run:
    order = lookup_order("A-17")
    run.output = issue_refund(order["order_id"], 19.99)

print(run.run_id)

Run it, then look at what was recorded:

python agent.py          # prints the run id
fr runs                  # list runs, newest first
fr show <run id>         # every step, in order (a unique prefix of the id works)

Runs are written to .fr/ in the current directory (set FR_DIR or fr.configure(dir=...) to change it).

Recording model calls

Wrap the client instance. Calls, streams and async calls behave exactly as before.

pip install 'ai-flight-recorder[openai]'      # or [anthropic]
from openai import OpenAI

client = fr.wrap(OpenAI())

with fr.run("triage"):
    client.chat.completions.create(model="gpt-4.1-mini", messages=[...])

fr.wrap also takes AsyncOpenAI, Anthropic and AsyncAnthropic. Cost comes from the shipped pricing table; a model missing from it records a null cost and warns once. Add or override prices with fr.configure(pricing="prices.toml").

LangChain and LangGraph

pip install 'ai-flight-recorder[langchain]'
model = fr.langchain.wrap_model(ChatOpenAI(model="gpt-4.1-mini"))
tools = fr.langchain.wrap_tools(tools, effects={"search": "read"})

Steps inside a LangGraph graph are tagged with their node (node:agent).

What is recorded, and what is not

  • Secrets are redacted before anything is written. Add your own rules with fr.configure(redact=[fr.redact.pattern(...), fr.redact.path(...)]).
  • Recording fails open: if a write fails, the agent keeps running and one warning is logged.
  • Nothing leaves your machine except your own model and tool calls. With fr.configure(otel=True) (the otel extra), each run is also exported to your OpenTelemetry tracer provider, with message content off by default.
  • Overhead is under 2 ms per call, checked in CI.

License

Apache-2.0

Metadata

Release files for ai-flight-recorder 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-flight-recorder 0.1.0
File Size Uploaded Provenance Actions
ai_flight_recorder-0.1.0.tar.gz 39.2 kB Without provenance Details for ai_flight_recorder-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ai-flight-recorder 0.1.0
File Interpreter ABI Platform Actions
ai_flight_recorder-0.1.0-py3-none-any.whl Python 3 none any Details for ai_flight_recorder-0.1.0-py3-none-any.whl

Total release size: 87.6 kB

Release files / ai_flight_recorder-0.1.0.tar.gz

Download URL ai_flight_recorder-0.1.0.tar.gz
Size 39.2 kB
Tags Source
SHA-256 checksum
How to use checksums
adfee3230b49aa69c7dce2950bdb9d210e0e3b068210365b201029475498c8c1
BLAKE2b-256 checksum
How to use checksums
951a3c2153d2e4ae1f6c1ac7744d91ca3169c23bded208627e868ee4cb47b4cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ai_flight_recorder-0.1.0-py3-none-any.whl

Download URL ai_flight_recorder-0.1.0-py3-none-any.whl
Size 48.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5dd49ea55f6aa4b21f605ad86ab1f26c3bb47a1606720f6ddac3485ad437a71
BLAKE2b-256 checksum
How to use checksums
f9b2b68d38b7293749cfd98e9a0c0fc3c476cd191c4d1932ffc954da1f939fb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ai-flight-recorder 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page