Skip to main content
Derivations are snippets of code that run against traces and experiments to extract data, monitor for errors, and more. Derivations can optionally run an agent to analyze the trace (a variant of LLM-as-judge that we call Agent-as-judge). They show up as columns in the Gentrace UI. Derivations example

Structure of a derivation

Language

Write derivations in Python or JavaScript.

Return type

All derivations must return a typed value. The type is specified in the dropdown at the bottom of the derivation and must match the return type of the function. Some types can be marked as “eval”. Eval derivations are averaged to compute a trace’s score. Derivation return type dropdown

Function signature and arguments

Derivations are functions written in Python or JavaScript. Derivations receive the following arguments:
  • The trace
  • (If available) The source test case from the test dataset
  • All other derivations in the same view

LLM-as-judge (Agent-as-judge)

Derivations can use an LLM to analyze traces with callAgent() / call_agent(). The function accepts parameters for instructions, resources (like the trace), output schema, and optionally images.

Running derivations

Derivations run in the context of a view. Derivations are run in three ways:
  • Automatically by Gentrace Chat
  • Automatically on trace ingest when sampled according to the view’s auto-run settings
  • Manually, by:
    • Pressing “Run last 10” or “Run last 100” in the top bar of the view
    • Right clicking on a column header in the table
    • Right clicking on a row or cell in the traces table
    • Pressing “Run” with a derivation selected
Manual run

Example derivations

Use the prompts below in Gentrace Chat to analyze your traces.

Understand agent execution

Understand user experience

Measure cost and performance

Monitor for errors

Write evaluations with LLM-as-judge