Today we open-sourced the ctxflow SDKs: OpenTelemetry distributions for AI agents in Python, Node.js and PHP, under the Apache-2.0 license. They are on PyPI (ctxflow-otel), npm (@ctxflow/otel) and Packagist (ctxflow/otel, ctxflow/otel-prism). You add them to an agent with zero code or one line, and each turn of the agent then tells you four things: what it retrieved, what it was given, what it did, and whether that context was still current.
This post explains why we built them, what they send, how to install each one, which libraries they support today and what they do not do yet. The source is at github.com/ctxflow-sh/ctxflow-edge.
In this guide
- Key takeaways
- Why we built context observability
- What do the ctxflow SDKs do
- Why OpenTelemetry and not a new protocol
- How do you install the Python SDK
- How do you install the Node.js SDK
- How do you install the PHP SDK
- Which frameworks and libraries are supported
- What data leaves your environment
- How much overhead does the SDK add
- What the SDKs do not do yet
- Frequently asked questions
Key takeaways
- Three languages, one specification: Python 3.12+, Node.js 22.15+ and PHP 8.2+, tested against the same conformance scenarios.
- Plain OpenTelemetry: OTLP/HTTP and the standard
OTEL_*variables. No proprietary protocol. - Keep your current instrumentation: OpenInference, OTel GenAI and OpenLLMetry spans work as they are.
- Four questions per turn: Retrieved, Given, Did and Current.
- Open source SDKs, hosted app in beta: the SDKs are Apache-2.0; the ctxflow app that reads the traces is in beta.
Why we built context observability
I have spent years taking AI from demo to production. The failure I see most often is not a bad model or a bad prompt. It is a bad document.
The story repeats every week. An agent tells a customer something false. Someone opens the traces, reads the whole conversation and decides the prompt needs work. They change the prompt, test it, and it looks fine. Two weeks later it breaks again.
The prompt was never the problem. The agent read a document that someone changed a month ago, and nobody reindexed it. The agent did not invent anything. It repeated old content with full confidence.
Most tracing tools show you what your agent said. Very few show you what it read, and whether what it read was still true. A trace shows a retrieval span with five chunk ids and some scores. It does not tell you which document each chunk came from, which version of that document, or whether that version was still the published one when the agent answered.
That gap is what ctxflow closes. To close it, we need data from two places:
- The read side: the agent, at the moment it retrieves and answers.
- The write side: the ingestion pipeline, at the moment it parses, chunks, embeds and writes to the index.
Both sides run in your code, not ours. So the part of ctxflow that runs in your environment has to be small, standard and easy to audit. That is why it is open source.
What do the ctxflow SDKs do?
The ctxflow SDKs are thin OpenTelemetry distributions. They configure the OpenTelemetry SDK, put the conversation and the user on every span, add a stable identity to each retrieved item, and export the spans over OTLP/HTTP.
With those spans, ctxflow turns raw traces into conversations and turns, and answers four questions about each turn:
| Question | What you see |
|---|---|
| Retrieved | Every retrieval call, with its chunks, their scores, their source document and its version. |
| Given | The chunks that each retrieval delivered to the model in that turn. |
| Did | Every tool call, on the client and on the server, with its user, its status and its failures. |
| Current | Whether each chunk was still in the index, and whether its source document was still the published version, at the moment of the retrieval. |
Two design rules shape everything else.
ctxflow never polls your systems. It does not connect to your vector database, your buckets or your folders. It observes the processes that write to your index and the processes that read from it. If you want to know what is in the index, the honest source is whoever wrote it.
A missing signal is never a zero. If an input never arrived, the number is shown as not measured, and the app tells you which integration would unlock it. A dashboard that shows “0 stale documents” when it simply has no data is worse than no dashboard.
What is in the repository
| Component | What it does |
|---|---|
ctxflow-otel (Python) |
OpenTelemetry distribution: conversation identity, retrieval identity, ingestion spans and MCP propagation. |
@ctxflow/otel (Node.js, TypeScript) |
The same SDK specification for Node.js. |
ctxflow/otel and ctxflow/otel-prism (PHP) |
The same specification for PHP, plus GenAI spans for Laravel Prism. |
ctxflow-semconv / @ctxflow/semconv |
The ctxflow.* semantic conventions, generated from one registry for every language. |
| Collector (optional) | An OpenTelemetry Collector distribution built from upstream components only. |
Why OpenTelemetry and not a new protocol?
Because your agent already has telemetry, and a second protocol is a second problem. Observability that asks you to replace your tracing stack is a migration project. Most teams will not do it for a tool they are still evaluating.
So the SDKs follow three rules:
- OpenTelemetry end to end. OTLP/HTTP, the standard
OTEL_*environment variables and the W3C trace context. - Keep your tracing stack. If your instrumentation already emits OpenInference, OTel GenAI or OpenLLMetry spans, ctxflow reads them as they are. The semantic conventions package includes the content-key maps of all three dialects.
- No rewrite of your retrieval. You choose the level of control: zero code with a launcher, one line with
init(), or only the processors if you already own theTracerProvider.
There is one more benefit. The optional collector exports standard OTLP, so the same traces can also go to any other OTLP backend you already use. ctxflow does not need to be the only place your traces go.
How do you install the Python SDK?
Install ctxflow-otel from PyPI and run your agent through the ctxflow-instrument launcher. It needs Python 3.12 or later.
pip install ctxflow-otel
OTEL_SERVICE_NAME=my-agent OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318 \
ctxflow-instrument python agent.py
If you prefer to start it from code, use one line in your entrypoint:
import ctxflow_otel
ctxflow_otel.init()
To tie spans to a conversation and a user, wrap the turn:
from ctxflow_otel import conversation
with conversation("conv-42", user_id="u1", session_id="s1", turn=3):
... # every span started here carries the identity
Then check the host with ctxflow-otel check. It verifies the configuration, tries the exporter endpoint and tells you if the API key is accepted, without sending any data.
Extras add integrations: ctxflow-otel[mcp], ctxflow-otel[llamaindex], ctxflow-otel[docling] and ctxflow-otel[unstructured]. The Python SDK guide covers each one.
A naming note: install ctxflow-otel, not ctxflow. The package called ctxflow on PyPI is a different project.
How do you install the Node.js SDK?
Install @ctxflow/otel from npm and start Node with its register hook. It needs Node.js 22.15 or later.
npm install @ctxflow/otel
OTEL_SERVICE_NAME=my-agent OTEL_EXPORTER_OTLP_ENDPOINT=http://collector:4318 \
node --import @ctxflow/otel/register agent.js
Or start it from code:
import { conversation, init } from "@ctxflow/otel";
const sdk = init(); // idempotent; reads CTXFLOW_* and OTEL_*
await conversation("conv-1", { userId: "u1", turn: 0 }, async () => {
// every span started in here, also after an await, carries the identity
});
await sdk.shutdown(); // flush the batch before the process exits
The same naming note applies: install the scoped package @ctxflow/otel. The unscoped ctxflow package on npm belongs to someone else. Details are in the JavaScript guide.
How do you install the PHP SDK?
Install ctxflow/otel with Composer and enable the OpenTelemetry autoloader. It needs PHP 8.2 or later.
composer require ctxflow/otel
For zero code, set OTEL_PHP_AUTOLOAD_ENABLED=true in the environment of the PHP process. With php-fpm, set it in the pool configuration. The SDK installs itself when Composer’s autoloader loads.
For explicit control, use one call:
use Ctxflow\Otel\Ctxflow;
use function Ctxflow\Otel\conversation;
Ctxflow::init();
$tracer = \OpenTelemetry\API\Globals::tracerProvider()->getTracer('my-app');
conversation(function () use ($tracer) {
$span = $tracer->spanBuilder('chat')->startSpan();
// ... call the model ...
$span->end();
}, 'conv-1', userId: 'u1', turn: 0);
If you use Laravel with Prism, add the Prism package too:
composer require ctxflow/otel-prism
Why PHP? A large share of the web still runs on it, and teams are adding AI features to Laravel and WordPress apps every day. Most AI observability SDKs we looked at start with Python and TypeScript and stop there. We wanted the same visibility for PHP teams, from the same specification. The PHP guide has the full setup.
Which frameworks and libraries are supported?
The SDKs work with any code that emits OpenTelemetry spans, and they add direct support for the libraries below. “Tested” means the version runs in our test matrix; “not tested” means it should work but we have not verified it.
| Language | Library | Status |
|---|---|---|
| Python | LlamaIndex (agent, LLM, tool and retriever spans via OpenInference, plus ingestion) | Tested on llama-index-core 0.14.x |
| Python | MCP Python SDK 1.x and 2.x (identity propagation) | Tested from mcp 1.24 |
| Python | Docling ingestion | Tested on docling 2.151.1, Python 3.12 |
| Python | Unstructured ingestion (Markdown path) | Tested on 0.27.x |
| Node.js | Vercel AI SDK 7 | Tested |
| Node.js | OpenInference instrumentations (for example OpenAI) | Supported |
| Node.js | MCP via @arizeai/openinference-instrumentation-mcp |
Supported |
| Node.js | Vercel AI SDK 6, OpenLLMetry (Traceloop) | Not tested |
| PHP | openai-php/client 0.19.2+ |
Tested |
| PHP | LLPhant 1.10.11+ (OpenAI chat only) | Tested |
| PHP | Neuron AI 4.x | Tested |
| PHP | Laravel Prism 0.103.x (via ctxflow/otel-prism) |
Tested |
All three SDKs implement one written specification. A shared set of conformance vectors and language-neutral scenarios runs against every SDK in CI, so a turn traced in PHP produces the same normalized spans as the same turn traced in Python.
The write side: ingestion
The read side tells you what the agent retrieved. To say whether that content was current, ctxflow also needs to see how it got into the index. The Python ingestion extras emit ingest.* spans (run, document, parse, chunk, embed, upsert) with ids, hashes and lengths only.
With CTXFLOW_DETERMINISTIC_IDS=on, each chunk gets an id derived from its source, the source version, the chunker version and its position. Re-ingest the same version and the ids stay the same. Change the document or the chunker settings and the ids change. That is what lets ctxflow tell “this chunk came from the current version” apart from “this chunk came from a version that was replaced last month”. The ingestion guide explains the setup.
What data leaves your environment?
By default, the text of prompts, answers, chunks, tool calls and errors is sent to ctxflow as your app wrote it. We chose this on purpose. Without the text, the app cannot show you what each step saw, and that is the whole point of the product.
If your data must not leave your network, a self-hosted deployment is available on request. The full list of what is sent, field by field, is on the What is sent page.
Two details that matter for security reviews:
- Identity comes from baggage. The conversation id, the session id and the user id travel as OpenTelemetry baggage. That baggage also reaches every MCP server you call, third-party ones too. Do not put in a conversation anything those servers must not see, and never use this identity for authorization.
- The collector keeps the key in one place. If you run the optional collector, the API key lives in the collector, not in every service. Run it in a private network: its OTLP receivers do not have authentication or TLS yet.
How much overhead does the SDK add?
About 0.65 ms per turn at the median, measured on a 9-span turn. We measured ctxflow_otel.init() against no OpenTelemetry at all, on a turn with five agent spans and four MCP spans, using a fake LLM so that only the instrumentation cost remains (600 turns per mode, Python 3.12).
| Metric | No OTel | ctxflow | Delta |
|---|---|---|---|
| p50 | 0.463 ms | 1.114 ms | +0.651 ms |
| p95 | 0.913 ms | 1.918 ms | +1.005 ms |
In relative terms that is more than double, because the fake turn takes less than half a millisecond. A real turn calls a model that takes hundreds of milliseconds or more, so in practice the added time is about one millisecond per turn. The benchmark script is in the repository, so you can run it on your own hardware.
What the SDKs do not do yet
We would rather you read this here than find it in production:
- The app is in beta. The SDKs are public, but you need an API key from the ctxflow app to see the four questions. You can create one at app.ctxflow.sh.
- The collector has no auth or TLS on its receivers yet. Private network only.
- PHP: a tracer provider you build yourself is not supported yet. Prism streams, embeddings, images and audio are not traced. LLPhant covers OpenAI chat only.
- Node.js: Vercel AI SDK 6 and OpenLLMetry are not tested.
- Python: LlamaIndex is tested on 0.14.x only. Unstructured is tested on the Markdown path; PDF, DOCX and the hosted API are not covered.
- No usage judgement. ctxflow reports which chunks were delivered to the model, not whether the answer “used” them. An earlier version guessed that with text overlap. We removed it because a guess presented as a fact is exactly what this product is meant to prevent.
Frequently asked questions
Is ctxflow open source?
The SDKs, the semantic conventions and the collector distribution are open source under Apache-2.0. They are everything that runs in your environment. The ctxflow service that turns traces into conversations and turns is a hosted product in beta, with self-hosting available on request.
Do I need to replace my current tracing tool?
No. The SDKs use standard OpenTelemetry, and spans from OpenInference, OTel GenAI or OpenLLMetry instrumentation work as they are. With the optional collector, you can send the same traces to ctxflow and to any other OTLP backend you already run.
Which package names should I install?
Install ctxflow-otel from PyPI, @ctxflow/otel from npm, and ctxflow/otel (plus ctxflow/otel-prism for Laravel Prism) from Packagist. The unscoped ctxflow packages on PyPI and npm belong to unrelated projects, so do not install those.
Does ctxflow connect to my vector database?
No. ctxflow never polls your vector database, buckets or folders. It learns about your index from the spans of the processes that write to it and read from it. That keeps its access to your systems at zero and its view tied to what actually happened.
What does “Current” mean for a chunk?
At the moment of the retrieval, ctxflow checks two things: whether the chunk was still in the index, and whether its source document was still the published version. If the source changed or was deleted after ingestion, the chunk is flagged, so you can see that the agent answered from outdated content.
How do I get access to the ctxflow app?
The app is in beta. Sign in at app.ctxflow.sh, create a project and copy its API key, or message me on LinkedIn. We are looking for teams with agents in production that want to see what their agents actually read.