Skip to content

Data model

ctxflow receives OpenTelemetry spans and builds a small model from them. This page names each part, so the rest of the docs can use the words.

Tenancy: organization, project, environment

Section titled “Tenancy: organization, project, environment”
Level What it is
Organization Your company or team. Members and their roles belong to it.
Project The boundary of data and permissions. Agents of one project share sources and indexes. Text storage and retention are set per project.
Environment Where the data of one deployment goes. A new project has Development (dev), Staging (staging) and Production (prod); you can add more. Each environment has its own API keys and its own views.

An API key sends data to one environment. See Projects and environments.

Entity Comes from
Agent The service.name of the spans (one per service in the environment).
Conversation session.id or gen_ai.conversation.id on the spans. Turns without one still appear.
User (principal) user.id on the spans, as your agent sent it. It is not verified: do not use it for authorization.
Turn One user request and the agent’s answer: in practice one trace. Its turn span is the outermost agent span of the trace: agent.turn (ctxflow SDK), invoke_agent (OTel GenAI) or an OpenInference AGENT/CHAIN span. It does not have to be the first span of the trace: how the turn is found.

Keep one turn per trace. A trace that holds several user turns is read as one turn.

The turn’s status is the OpenTelemetry status of the turn span: ok, error or unset. unset is the default and means “not set”, not success. A failed tool does not make the turn error: the failure is on the tool call.

A tool call is a span of kind tool: execute_tool <name> (OTel GenAI), an OpenInference TOOL span, an MCP tools/call span, or the agent.tool_call / mcp.tool <name> spans. A call can be seen from two sides:

  • client: the agent side, in the agent process;
  • server: the side that ran it, for example an MCP server.

When both sides are in the trace, ctxflow shows them as one call and counts it once. It joins them in this order:

  1. the same gen_ai.tool.call.id on both spans;
  2. for MCP, the same mcp.session.id and JSON-RPC request id (jsonrpc.request.id). An MCP client that opens a new session for each call reuses the same request id, so the id counts only together with the session id;
  3. without an explicit id, the span tree: the same tool name, with one span enclosing the other or overlapping in time.

If an agent framework wraps an MCP call in its own tool span with the same tool name (for example execute_tool search around MCP send tools/call search), that is also one call. The MCP client span of the MCP Python SDK 2.x (MCP send tools/call <tool>) is a tool call too, so remote calls to MCP servers have a client side and count in metric M5. See MCP for what to instrument.

A remote call crosses a process boundary (span kind CLIENT, an MCP or RPC call). A retrieval is a call of kind retrieval (or rerank). If you wrap a retriever in your own retrieval span and an instrumentation (for example OpenInference for LlamaIndex) also emits one for the same call, ctxflow counts it once.

One definition of a tool call is used in every view (Health, Tools, Usage, Conversations, turn detail, M4): a call of kind tool, or a retrieval call with a name of its own (a native tool that does retrieval, such as a LlamaIndex function tool search_documents, or an MCP search tool). Such a call is in Tools and “Calls per tool”, and its chunks are also delivered context. The generic retriever span of a framework and a rerank are not tool calls. A pair of client and server rows counts once.

A tool call failed when its span status is ERROR. ctxflow.tool.status (OK or ERROR) is optional and read first if present.

source document ──(ingestion: parse, chunk, embed, upsert)──► chunks in your index
ctxflow.source_id chunk id, text hash, C1
ctxflow.source_version │
ctxflow.source_hash ▼
retrieval call ──► retrieval items
(one per returned chunk)
Term Meaning
Source An original document in its source system (a file, a page, a record), named by ctxflow.source_id, for example its path relative to the document root.
Version ctxflow.source_version: the version in which the current content of the source first appeared. Your label, or one derived from the content hash.
Source hash ctxflow.source_hash: the hash of the original document bytes, as indexed. It is how ctxflow tells whether a chunk came from the published version.
Chunk A piece of a source as written to your index, with its id (as the vector store holds it) and the hash of its text.
Index Where chunks are written. ctxflow names an index after the service.name of the pipeline that writes it.
Retrieval item (context item) One chunk (or other item) returned by one retrieval call, with its id, score, metadata (C1 keys) and text hash.

The keys ctxflow.source_id, ctxflow.source_version and ctxflow.source_hash together are C1, the source identity. They travel in the chunk metadata, so the retriever returns them with each item. See Retrieval.

An item without an id and without text (for example a summary the retriever made) is not verifiable: it is never judged current or stale.

ctxflow keeps what your spans say (ids, hashes, names, numbers and the C1 keys) for as long as the environment exists. Text is kept apart, so it can expire after the retention you choose without changing any metric, hash or lineage verdict. See Store text and retention.

  • Context delivered: the items a retrieval returned in a turn, counted once per turn. ctxflow does not judge whether the answer used them. See Context delivered.
  • Omissions: what a turn shows it lacks: no_retrieval, tool_failed, retrieval_failed, stale_context. See Context delivered.
  • Lineage: per retrieved item, whether the chunk was in the index (C4) and whether its source was current (C6) at the moment of the retrieval. See Lineage.