Skip to main content
Version: 0.0.8 (stable)

Trace Spans

Agentic GraphRAG records the spans below when you pass it a tracer. They cover ingestion, extraction, resolution, the agent, and the judge.

Tracing is opt-in per object. A tracer of None opens no recorded span. Agentic GraphRAG never installs a global provider. You inject the tracer you want. See Trace an agent run for how to build and pass one.

How the span families nest​

A graph call root holds extraction spans, a cutover job, and community spans. The cutover job holds resolution, merge, and storage spans. LLM spans nest below extraction, resolution, and community spans. An agent tool call holds the spans of the evidence tool that made it. Store and embedding spans nest below storage spans.A graph call root holds extraction spans, a cutover job, and community spans. The cutover job holds resolution, merge, and storage spans. LLM spans nest below extraction, resolution, and community spans. An agent tool call holds the spans of the evidence tool that made it. Store and embedding spans nest below storage spans.

Each box is a span family. An arrow points from a parent span to the spans that nest below it.

BoxSpan names
Graph call rootagrag.ingestion.add, update, delete_document, consolidate, detect_communities, and the other root spans in "Ingestion root spans"
Extraction spansagrag.extraction.*
Cutover jobagrag.ingestion.cutover_job and agrag.ingestion.ingest_chunks
Resolution, Merge, Storage spansagrag.resolution.*, agrag.merge.*, agrag.storage.*
Community spansagrag.community.*
LLM spansagrag.llm.call, agrag.llm.attempt, agrag.llm.request
Agent tool callThe OpenInference TOOL span of an agent run
Store and embedding spansagrag.graphdb.*, agrag.embedding.*, only when you pass the same tracer to the stores and the embedder

The LLM span tree​

Every BAML-backed path produces the same three spans, nested. BAML collects data during the attempt. The path writes the request span after the attempt finishes. The span carries the real request and response.

agrag.extraction.extract_chunk (INTERNAL)
agrag.extraction.baml (INTERNAL)
agrag.llm.call (INTERNAL)
agrag.llm.attempt (INTERNAL)
agrag.llm.request (CLIENT, kind LLM)
SpanKindAttributes
agrag.llm.callINTERNALagrag.llm.function, agrag.llm.attempt_count
agrag.llm.attemptINTERNALagrag.llm.attempt (1-based)
agrag.llm.requestCLIENTthe table below

agrag.llm.function is the BAML function name, such as ExtractEntitiesAndRelations. The attempt span records the exception when an attempt fails. The call span reports ERROR when the call as a whole fails.

Ingestion spans​

SpanAttributes
agrag.ingestion.load_documentagrag.source_uri, agrag.loader_name, agrag.normalization (JSON), agrag.loader_exhausted (when the loader has no document left) or agrag.document_key (when it yields one)
agrag.ingestion.chunk_documentagrag.document_key, agrag.chunker.hash, agrag.chunker.settings (JSON), agrag.chunks_produced
agrag.storage.embed_chunksagrag.embedding.heading_context (bool, whether the embedder got the heading path)

Ingestion root spans​

Every public Graph call opens one root span.

SpanOpens whenAttributes
agrag.ingestion.openGraph.open runsnone
agrag.ingestion.resume_incomplete_jobsGraph.open recovers document jobs that an earlier run left unfinishednone
agrag.ingestion.addGraph.add runsnone
agrag.ingestion.updateGraph.update runsnone
agrag.ingestion.delete_documentGraph.delete_document runsnone
agrag.ingestion.purge_documentGraph.purge_document runsnone
agrag.ingestion.consolidateGraph.consolidate runsnone
agrag.ingestion.detect_communitiesGraph.detect_communities runsnone
agrag.ingestion.reevaluateGraph.reevaluate runsagrag.entity_count
agrag.ingestion.deactivate_matchGraph.deactivate_match runsagrag.match_id
agrag.ingestion.reconcile_created_entitiesNew entities are checked against existing ones after a commitagrag.created_entity_count
agrag.candidates.convertGraph.convert_candidates runsagrag.candidate_count
agrag.ingestion.cutover_jobAn add, update, or delete runs as one document jobagrag.verb, agrag.document_key, agrag.job_id
agrag.ingestion.ingest_chunksThe shared step that resolves, merges, and stores extracted chunksnone

The ingestion span tree​

One add call with one chunk and the local extractor produces this tree. load_document appears only for source= input. Store and embedding spans (agrag.graphdb.* and agrag.embedding.*) nest below the step that calls them.

agrag.ingestion.add
agrag.ingestion.load_document only with source=
agrag.ingestion.chunk_document
agrag.extraction.extract_chunk one per chunk (first phase)
agrag.extraction.gliner or agrag.extraction.baml
agrag.extraction.model_load first call only
agrag.extraction.escalate once per batch, in hybrid mode with an LLM extractor
agrag.extraction.extract_chunk one per escalated chunk
agrag.extraction.baml
agrag.extraction.remap_relations only when a relation remap fails and the error policy is not RAISE
agrag.ingestion.cutover_job
agrag.ingestion.ingest_chunks
agrag.resolution.global_exact_match
agrag.resolution.candidate_generation
agrag.resolution.decided_pairs only with persisted candidate pairs and a recording tracer
agrag.resolution.resolve
agrag.resolution.exact_fuzzy_pass
agrag.resolution.embedding_tier
agrag.resolution.precluster_tier
agrag.resolution.llm_tier only with boundary pairs
agrag.resolution.llm_batch
agrag.merge.merge_group one per entity group
agrag.storage.upsert_chunks
agrag.storage.upsert_structure
agrag.storage.upsert_documents
agrag.storage.embed_chunks
agrag.storage.upsert_relations
agrag.storage.upsert_mentioned_in
agrag.storage.upsert_candidates only with candidates
agrag.storage.embed_survivors
agrag.merge.rebuild_components

Resolution, merge, and storage spans​

SpanAttributes
agrag.resolution.global_exact_matchagrag.mention_count, agrag.exact_match_hits
agrag.resolution.candidate_generationagrag.mention_count, agrag.persisted_candidate_count, agrag.in_batch_candidate_count
agrag.resolution.decided_pairsnone; diagnostic read failures are recorded as exception events
agrag.resolution.resolveagrag.entity_count, agrag.pair_count, agrag.ambiguous_count, agrag.failed_llm_requests, agrag.cap_truncated_pairs, agrag.llm_unavailable_pairs, agrag.already_decided_pairs
agrag.resolution.exact_fuzzy_passagrag.pair_count, agrag.exact_match_count, agrag.fuzzy_fast_path_count, agrag.fuzzy_uncertain_count
agrag.resolution.embedding_tieragrag.fuzzy_uncertain_count, agrag.hard_merge_count, agrag.ambiguous_count
agrag.resolution.precluster_tieragrag.boundary_pairs_before, agrag.auto_merged_count, agrag.boundary_pairs_after
agrag.resolution.llm_tieragrag.boundary_pair_count, agrag.selected_pair_count, agrag.cap_truncated_pairs, agrag.ambiguous_count, agrag.failed_llm_requests, agrag.llm_unavailable_pairs
agrag.resolution.llm_batchagrag.batch_size, agrag.uncertain_count
agrag.merge.merge_groupagrag.mention_count, agrag.conflicts_resolved
agrag.merge.rebuild_componentsagrag.component_count
agrag.merge.rebuild_componentagrag.member_count
agrag.merge.deactivate_componentagrag.match_id
agrag.storage.upsert_chunksagrag.record_count, agrag.nodes_written
agrag.storage.upsert_structureagrag.record_count, agrag.nodes_written
agrag.storage.upsert_documentsagrag.record_count, agrag.nodes_written
agrag.storage.upsert_relationsagrag.record_count, agrag.relationships_written
agrag.storage.upsert_mentioned_inagrag.record_count, agrag.relationships_written
agrag.storage.upsert_candidatesagrag.record_count, agrag.candidates_written
agrag.storage.embed_survivorsnone
agrag.community.embed_batchagrag.batch_size

agrag.resolution.decided_pairs reads prior matches only among persisted candidate pairs, and only when its span is recording. The result supplies the agrag.already_decided_pairs count on agrag.resolution.resolve; it does not skip comparisons or change groups. A failed diagnostic read records an exception event, leaves the span status UNSET, and does not enter ingestion failure reports.

agrag.resolution.llm_tier and agrag.resolution.llm_batch open only when boundary pairs reach the model. Like agrag.resolution.llm_verify, a failed model call there counts as agrag.failed_llm_requests and does not set the span to ERROR.

Graph store spans​

The Neo4j store opens these spans. Reads and writes carry the query text and the value of every parameter except vectors and the lexical search terms. A trace shows what each query asked for.

SpanAttributes
agrag.graphdb.build_drivernone
agrag.graphdb.execute_readdb.system.name, db.namespace, db.query.text, db.query.parameter.<name> for each non-vector parameter, agrag.transactional (inside a transaction)
agrag.graphdb.execute_writethe same as execute_read
agrag.graphdb.transactionnone
agrag.graphdb.upsert_nodesdb.collection.name (the label), agrag.record_count, agrag.written, agrag.failures_count, db.operation.batch.size (0 for an empty write, absent for a write of one record)
agrag.graphdb.upsert_relationsagrag.record_count, agrag.written, agrag.failures_count, db.operation.batch.size (0 for an empty write, absent for a write of one record)
agrag.graphdb.load_entitiesagrag.requested_count, agrag.loaded_count
agrag.graphdb.upsert_candidatesagrag.record_count
agrag.graphdb.vector_searchdb.collection.name (the label), agrag.limit, agrag.k_final, agrag.index_missing (when the index does not exist. The search then returns no hits)

Qdrant spans​

Qdrant operations open spans when a tracer is supplied to QdrantVectorStore. Every span carries db.system.name="qdrant" and server.address containing only the hostname. Collection operations also carry db.collection.name. Spans do not record endpoint URLs, API keys, vectors, query text, or source text. SDK errors are translated to sanitized messages before the span ends.

Operations that send a request open a CLIENT span. qdrant.upsert and qdrant.delete open an INTERNAL span that groups one CLIENT span for each batch.

SpanKindAttributesOpens when
qdrant.initializeCLIENTnoneA new client checks server access
qdrant.closeCLIENTnoneAn initialized client closes
qdrant.ensure_collectionCLIENTnoneCollection schema is created or checked
qdrant.collection_infoCLIENTnoneCollection configuration is read, with an exact count unless the caller opts out
qdrant.delete_collectionCLIENTnoneA collection is removed
qdrant.upsertINTERNALagrag.record_countRecords are written in batches
qdrant.upsert_batchCLIENTdb.operation.batch.size (absent for a single record)One batch of dense and BM25 vectors is written
qdrant.searchCLIENTagrag.limitDense vectors are searched, including hybrid alpha one
qdrant.hybrid_searchCLIENTagrag.limit, agrag.alphaBM25 or fused ranks are searched with alpha below one
qdrant.deleteINTERNALagrag.record_countPoint IDs are deleted in batches
qdrant.delete_batchCLIENTdb.operation.batch.size (absent for a single ID)One batch of point IDs is deleted
qdrant.list_idsCLIENTagrag.limitIDs are read in ascending UUID order

Every span except qdrant.initialize and qdrant.close also carries db.collection.name.

Milvus spans​

Milvus operations open spans when a tracer is supplied to MilvusVectorStore. Without a tracer, no spans are emitted. Every span carries db.system.name="milvus" and db.collection.name. Spans do not record endpoint URLs, tokens, vectors, query text, or source text. SDK errors are translated to sanitized messages before the span ends.

Operations that send a request open a CLIENT span. agrag.vectordb.upsert and agrag.vectordb.delete open an INTERNAL span that groups one CLIENT span for each batch.

SpanKindExtra attributesOpens when
agrag.vectordb.ensure_collectionCLIENTnoneCollection schema is created or checked
agrag.vectordb.collection_infoCLIENTnoneCollection configuration is read, with an exact count unless the caller opts out
agrag.vectordb.delete_collectionCLIENTnoneA collection is removed
agrag.vectordb.upsertINTERNALagrag.record_countRecords are written in batches
agrag.vectordb.upsert_batchCLIENTdb.operation.batch.size (absent for a single record)One batch is written
agrag.vectordb.searchCLIENTagrag.limitDense vectors are searched, including hybrid alpha one
agrag.vectordb.hybrid_searchCLIENTagrag.limit, agrag.alphaBM25 or fused ranks are searched with alpha below one
agrag.vectordb.deleteINTERNALagrag.record_countIDs are deleted in batches
agrag.vectordb.delete_batchCLIENTdb.operation.batch.size (absent for a single ID)One batch of IDs is deleted
agrag.vectordb.list_idsCLIENTagrag.limitIDs are read in ascending UUID order

Embedding spans​

SpanAttributes
agrag.embedding.model_loadagrag.model
agrag.embedding.embedagrag.text_count, agrag.cache_hit_count, agrag.model (dense embedder, every call)
agrag.embedding.encodeagrag.text_count, agrag.cache_hit_count (dense embedder, cache misses only)

Domain spans by path​

Each LLM path also opens one small domain span carrying its own ids and counts.

PathDomain spanAttributes
Extraction, BAMLagrag.extraction.bamlagrag.chunk_id, agrag.entities_extracted, agrag.relations_extracted, agrag.candidates_extracted, agrag.extraction.heading_context (bool, whether a section line was sent), agrag.extraction.unparsable (bool, set when the reply held no usable answer)
Extraction, GLiNERagrag.extraction.gliner, and agrag.extraction.model_load around the one-time model buildagrag.chunk_id, agrag.entities_extracted, agrag.relations_extracted, agrag.candidates_extracted. agrag.model is on the load span
Extraction, escalateagrag.extraction.escalateagrag.chunks_total, agrag.chunks_eligible, agrag.chunks_escalated, agrag.chunks_zero_relation (eligible chunks with at least two kept entities and no relation, counted before the budget cut)
Extraction, chunkagrag.extraction.extract_chunkagrag.chunk_id, agrag.extraction.phase, agrag.entities_extracted, agrag.relations_extracted, agrag.candidates_extracted, agrag.long_entity_names (entities whose name is longer than 120 characters)
Resolutionagrag.resolution.llm_verifyagrag.pair_count, agrag.match_count, agrag.uncertain_count, agrag.request_failed (bool), agrag.llm_unavailable (bool)
Mergeagrag.merge.resolve_descriptionagrag.description_count, agrag.summarized (bool)
Communityagrag.community.report_batchagrag.batch_size
Judgeagrag.eval.judgeagrag.eval.judge_model

agrag.merge.resolve_description opens only when the field conflicted. The field conflicted when more than one distinct candidate exists. A field that every entity in the group agrees on adds no span.

agrag.resolution.llm_verify never carries an ERROR status. A failed LLM call leaves its pairs undecided, not rejected, and is not an error. The span stays UNSET and sets agrag.request_failed instead. When no LLM settings are available, it sets agrag.llm_unavailable instead.

The agrag.llm.request span​

This is the only span a BAML path tags with the OpenInference LLM kind.

AttributeValue
openinference.span.kind"LLM"
span kindCLIENT
llm.providerOpenInference value mapped from BAML's provider id, table below
llm.model_namethe model named in the response body, else the model in the request body
llm.token_count.prompt / .completionUsage.input_tokens / output_tokens, omitted when None
llm.token_count.totalprompt plus completion, only when both are present
llm.token_count.prompt_details.cache_readUsage.cached_input_tokens, only when greater than 0
agrag.llm.usage_missingtrue when the call succeeded and every usage field was None
input.value, input.mime_typethe request body text, application/json
output.value, output.mime_typethe response body text, application/json, or text/plain if it does not parse
http.response.status_codethe response status
error.typethe status as a string, when it is 400 or higher
agrag.llm.baml_providerBAML's raw provider id
agrag.llm.client_namethe client that made the request
agrag.llm.requested_modelthe model in the request body
agrag.llm.selectedwhether BAML used this call's reply

The span's status is ERROR when the status is 400 or higher, or when the call got no response at all.

Provider mapping​

BAML's provider ids map to the same OpenInference values the agent path emits.

BAML provider idllm.provider
openai, openai-generic, openai-responsesopenai
azure-openaiazure
anthropicanthropic
google-ai, vertex-aigoogle
aws-bedrockaws

An id outside this table stays unchanged. A newly added provider still produces a usable span.

Counting calls and tokens​

To count the LLM calls in a trace, count the spans tagged with the OpenInference LLM kind:

def count_llm_calls(spans):
return sum(
1
for span in spans
if span.attributes.get("openinference.span.kind") == "LLM"
)

Token counts live only on agrag.llm.request spans and on the agent and judge LLM spans. The parent spans never carry them. A sum of llm.token_count.prompt over every span with that kind is exact because no token is counted twice.

What is recorded, and what is not​

Nothing withholds text. agrag.llm.request records the full request and response bodies, and the agent and judge spans record the question, tool inputs and evidence text. The OpenInference redaction environment variables no longer change any span, on any path. To record less, scrub attributes in a SpanProcessor you configure, or run without a tracer.

No span attribute records the request headers, which carry the provider key, or the request URL. Error text can still contain the URL; see Known limits. Graph store spans record the query text and the value of every parameter except vectors and lexical search terms. A parameter can hold source text or entity names.

Known limits​

  • An unparsable extraction reply raises UnparsableExtractionError. The agrag.extraction.baml span sets agrag.extraction.unparsable and ends with an error status.
  • Retries below BAML are invisible: LangChain and the provider SDKs retry internally, and one agent or judge LLM span can cover several HTTP requests. The agrag.llm.request spans, read from BAML's collector, are exact for the requests BAML itself made.
  • Token semantics match an OpenAI-compatible endpoint only. For anthropic, google-ai, vertex-ai, aws-bedrock and azure-openai, the counts are whatever BAML's Usage reports.
  • The SDK caps attributes at 128 by default. A long agent run can reach that limit. The SDK then drops attributes without a warning. Raise SpanLimits.max_attributes on your provider. Use a sampling processor in production.
  • BAML error text includes the request URL. It reaches exception events and StageFailure.error_message. output.value holds only a response body, so a connection failure leaves it empty. Never put a provider key in a base_url query string.