DocumentationRecipesReferenceChangelog
Log In
Documentation

Importing agent traces

An agent trace records one run of an AI agent: the user's request, each LLM call and tool call the agent made, in order, and its final answer. Import the traces your tracing tool records into an LLM static project, so that your experts evaluate each step: which step went wrong, why, and what the agent should have done. If an LLM judge scored the traces, its scores come with them, as a label you can compare with your reviewers' answers.

🚧

Private beta

LLM projects are currently in private beta. They are available to selected customers on request, and they may change before general availability. To request access, contact your Kili representative.

Before you start

  • Project type: LLM static. Create one from the LLM static template in the Demo Projects section.
  • Access: Project Admins
  • Sources: OpenTelemetry (OTLP JSON), Langfuse, LangSmith and Braintrust exports, and Kili conversations
  • File formats: .json and .jsonl (JSON Lines). One file can hold many traces.

Setting up the labeling jobs

Each job of an LLM project has a level, which decides where reviewers answer it:

LevelWhere it shows on a traceUse it to
completionBeside each step, in its Evaluate step #n panelJudge each LLM reply and each tool call
roundAfter the steps, once for the user's requestJudge how the agent handled the request
conversationAfter the steps, under Evaluate the conversationJudge the outcome of the whole run

Classification and transcription jobs are supported at every level. For example, a project that evaluates a bank assistant asks, for each step, This step is (Correct, A mistake) and What should the agent have done?; and for the run, Did the agent answer correctly? (Yes, No) and Why, in one sentence.

To set the level of a job, edit the project's JSON interface: refer to Labeling LLM data.

📘
  • Name each job after the judge's score it answers: Kili turns a score into an answer to the job whose ID or instruction is the score's name. Refer to How the judge's scores become a label.
  • Don't add a comparison job: in a project with one, traces show as a side-by-side comparison of models, not as a sequence of steps.

Exporting traces from your tracing tool

Kili reads the exports below as they are: no conversion is needed. You can drop several files at once. The records of one trace can be split across files, for example the observations and the scores of Langfuse.

OpenTelemetry

Export the spans as OTLP JSON: the output of the OpenTelemetry Collector's file exporter, or the body of OTLP/HTTP requests, one per line in a .jsonl file. Kili reads the spans that follow the OpenTelemetry semantic conventions for generative AI:

  • An LLM call is a span whose gen_ai.operation.name is chat, text_completion or generate_content.
  • A tool call is a span whose gen_ai.operation.name is execute_tool, with its gen_ai.tool.name, gen_ai.tool.call.arguments and gen_ai.tool.call.result.
  • A judge's score is a gen_ai.evaluation.result event, on the span it scores.

Langfuse

Export each trace with the public API (GET /api/public/traces/{traceId}), which includes its observations and its scores. You can also drop the observations export and the scores export together.

  • GENERATION observations are LLM calls. TOOL and RETRIEVER observations are tool calls.
  • A generation that answered a structured output, JSON with no message in it, shows as that JSON.
  • A trace downloaded from Langfuse's interface imports too. When the download leaves out the inputs and outputs of the steps, as older downloads and those of large traces do, Kili imports the steps without them and warns you: export the trace with the public API instead.
  • A list of traces (GET /api/public/traces) holds no observations: Kili refuses it, and says how to export the traces.

LangSmith

Export the runs of your traces, with their feedback:

  • Drop the feedback records in the same import as the runs, or export the runs with their feedback inline.
  • Without feedback records, Kili reads each run's feedback summary: for each key, its most frequent value, or else its average.

Runs of type llm and chat_model are LLM calls. Runs of type tool and retriever are tool calls. A trace exported from LangSmith's interface imports too.

Braintrust

Export the spans with Braintrust's API or SDK: GET /v1/project_logs/{project_id}/fetch for logs, or GET /v1/experiment/{experiment_id}/fetch for an experiment.

🚧

Don't use the table download of Braintrust's interface: it holds only the first span of each trace, without the IDs that link its steps. Kili refuses it, and says how to export the spans.


Importing traces

  1. From the project Settings page, open Imports, then click Add in the Assets card.
  2. Select Upload files.
  3. Drag and drop your .json and .jsonl files.
  4. If the judge gave values that match none of the categories of the jobs they answer, the Map the judge's values to Kili categories window opens. For each value, choose the category it becomes in the judge's label, or Leave out, then click Import.

Kili creates one asset per trace, with the trace's ID as its external ID, and a notification gives the number of conversations imported. What could not be imported is listed in the error report: a record no tool exported, a trace with no request, a media missing from the export, judge's scores that could not be added. Click Export CSV in the report for each trace and the reason.

What a trace becomes

  • The request, from the trace's input, opens the conversation.
  • Each step follows, numbered in the order the agent ran it:
    • an Agent reply for each LLM call that answered with text, with the name of the model;
    • a Tool call for each tool call, with its arguments, and its result or its error.
  • The final answer is the agent's last reply. When no LLM call replied with text, the trace's output shows as the last reply.
  • The metadata holds the tool the trace came from (source), its name (trace), all the judge's scores as text (evaluation) and, from Langfuse, LangSmith and Braintrust, the trace's own metadata. Reviewers see it in the information panel (ⓘ) of the labeling interface.

A trace is one round: one request, then its steps. The system prompt of the agent's first LLM call is kept with the conversation and in exports. It shows before the request, under System prompt: click the title to fold it.


How the judge's scores become a label

The judge's scores of a trace become one label of the model LLM judge, kept apart from your labelers' labels. In the Explore view, its answers show in each step's Evaluate step panel, and in the conversation's jobs. Kili scores them against your reviewers' answers: refer to Evaluating an LLM judge.

A score answers a job when:

  • Its name is the job's ID or instruction. Case, spaces and punctuation don't count: a score named outcome answers a job OUTCOME, and a score named tone_of_the_round answers a job whose instruction is Tone of the round.
  • It scores the right level. A score on a step answers a completion job, on that step. A score on the whole trace answers a conversation job, or else a round job. A step's score that names no completion job answers a conversation or a round job.

Its value becomes the job's answer:

  • Classification jobs: the category whose ID or name is the value. Usual yes and no values match the categories that mean the same: true, pass, correct or 1 match Yes or Correct, and false, fail, wrong, mistake or 0 match No or A mistake. For any other value, such as a score of 4 or 0.7, Kili asks you which category it becomes before the import.
  • Transcription jobs: the score's label, or else its comment, or else its value.

A score that answers no job is still in the trace's metadata, for reviewers to read.


Importing the media of a trace

The images, audio, video and PDF files a trace holds are imported with it, and show with the step that received or produced them. A media file the user sent shows with the request.

Kili imports a media file when the export holds its content: as a data URI, or in base64 beside its type. Langfuse and Braintrust keep media files in their own storage by default, and the export then holds only a reference: the trace is imported without them, and the error report says how to export them:

  • Langfuse: pass the trace through resolve_media_references(resolve_with="base64_data_uri") before you export it.
  • Braintrust: replace each attachment with str(ReadonlyAttachment(attachment)), its data URI.

Importing traces with the Python SDK

To import traces from another tool, from your own logs, or on a schedule, convert them to Kili conversations and import them with the Python SDK. Refer to the agent traces tutorial. To have Kili score your judge, add its scores as an inference label with append_labels(): refer to Evaluating an LLM judge.

Limitations

  • Each trace is imported as one round. To evaluate a multi-turn session as one conversation, import it with the Python SDK, one round per user request.
  • From OpenTelemetry, Kili reads the attributes of the generative AI conventions only: your own span attributes, such as a task ID, aren't kept in the metadata.

Related pages


Did this page help you?