All features
03NESTED TRACES

Spans, tools & chains

Real LLM apps aren't one call — they're retrievers, tool calls, and chains of model steps. Currai nests spans inside a trace so you get the full tree of a request and can pinpoint exactly which step was slow or wrong.

  • Arbitrary nesting: spans inside spans inside the root trace.
  • Mix generations, retriever spans, and plain function spans freely.
  • Each node carries its own input, output, timing, and metadata.
  • Works with agent loops, RAG pipelines, and multi-model chains.

Nest a RAG trace 🌳

trace = currai.trace(name="rag-answer")

retrieval = trace.span(name="retrieve-docs", input={"query": question})
docs = vector_store.search(question, k=4)
retrieval.end(output={"doc_ids": [d.id for d in docs]})

gen = trace.generation(name="answer", model="gpt-4o", input=prompt(docs))
gen.end(output=answer)