# Agent Flight Recorder

> A JSONL telemetry logger and query toolset for agent self-monitoring, cost tracking, and tool error diagnosis.

Agent Flight Recorder is a paid AI agent skill on Agensi by Phil Marcus, in LLM Ops. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $7 (one-time purchase)
- Creator: [Phil Marcus](https://www.agensi.io/creators/phil-marcus)
- Category: [LLM Ops](https://www.agensi.io/skills/llm-ops)
- Version: 1.0
- Last updated: 2026-10-19
- Security: scan passed (2026-10-19); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/agent-flight-recorder
- Tags: llm-ops, ai-agents, python, telemetry, cost-tracking

## About this skill

Agent prompts often include static status updates provided by the harness, forcing the agent to trust external summaries of its own performance. This skill provides a telemetry loop that allows the agent to interrogate its raw execution data. It enables autonomous agents to monitor their own costs, tool reliability, and cycle performance using verifiable logs.

### What it does
- **Verifiable Logging** appends events for LLM calls, tool usage, and cycle metadata to a JSONL file.
- **Cost Analysis** aggregates input, output, and cached tokens to calculate actual spend per cycle.
- **Reliability Tracking** measures tool error rates and captures failure details for self-diagnosis.
- **Fast Telemetry Retrieval** reads only the tail of large log files to maintain performance without context flooding.
- **Performance Metrics** roll up action distributions, duration per cycle, and cache hit ratios.

### How it works
1. **Instrument the Loop** using the `TelemetryLogger` to record starts, LLM usage, tool calls, and decisions.
2. **Define Schema** by mapping your event names and pricing functions to the `FlightRecorder` configuration.
3. **Expose Tools** to the agent via `get_execution_metrics` and `query_telemetry` for self-monitoring.
4. **Agent Interrogation** allows the model to query its recent failures or token usage to adjust its own behavior.

### Frameworks & tools
Python 3.9+ standard library. The skill includes provider-neutral tool specifications compatible with Anthropic, OpenAI, Gemini, and Ollama.

### Why this beats prompting it yourself
Standard prompts only give the agent what you think it needs to know. This skill provides the agent with raw, granular data so it can detect silent tool degradation or budget overruns that a human developer might miss in real-time.

### Use cases
- Debugging intermittent tool failures during long autonomous runs.
- Implementing cost-aware planning where the agent scales back model usage based on measured spend.
- Auditing context cache efficiency by monitoring `cached_tokens` vs `input_tokens`.
- Generating self-diagnostic reports when an agent detects a loop or performance regression.

### Known limitations
Reads are restricted to the last 24 MB of the log file to prevent context overflow. Requires manual instrumentation of the agent loop to capture events.

## Requires

- Python 3.9+

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Agent Flight Recorder skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does the Agent Flight Recorder improve autonomous decision-making?

This skill provides a 'black box' for your agent, enabling it to query its own execution logs to detect silent tool failures, track real-time token spend, and optimize its own performance based on raw telemetry data rather than static status prompts.

### Which AI frameworks and models is this skill compatible with?

It is provider-neutral and includes tool specifications compatible with Anthropic, OpenAI, Gemini, and Ollama, requiring only Python 3.9+ and manual instrumentation of your existing agent loop.

### Will reading large log files cause latency or context window issues for my agent?

The skill uses a high-performance tail-reading method restricted to the last 24 MB of the log file, ensuring the agent receives recent, relevant data without flooding its context window or slowing down inference.

### What is included in the purchase of this skill?

Two standard-library Python modules: telemetry_logger.py (the 70-line append-only JSONL writer with log_llm and log_tool helpers) and telemetry_tools.py (Schema, tail_events, current_life, compute_metrics and the FlightRecorder wrapper that exposes get_execution_metrics and query_telemetry as provider-neutral tool specs with dispatch). Plus a 7-test offline suite and three reference docs: every Schema knob and event shape with agent-facing prompt wording, tool wiring for Anthropic, OpenAI and Gemini, and the design notes on tail-only reads, run scoping and the result size cap.

### Can I customize the cost tracking to account for different model pricing tiers?

Yes, you can define custom pricing functions and event names within the FlightRecorder configuration to accurately track costs across different model providers or internal API usage.

### What does the initial setup process look like for a new project?

No package install: copy the two scripts into your agent package. Then instrument the loop with TelemetryLogger (cycle start and end, each LLM call with its token counts, each tool call with its error and duration, the decision), build a FlightRecorder with your pricing function and a Schema matching your event names, and register its tool_specs() with your provider so the agent can call get_execution_metrics and query_telemetry. The read side also works on an existing JSONL log, since every field and event name is configurable.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
