Skip to main content

Overview

Artanis provides four main methods for recording data in traces:
  • input() - Data going into an operation
  • output() - Final result of an operation
  • state() - Context needed for replay
  • event() - Discrete decisions or milestones

trace.input()

Record inputs at any stage. You can call this multiple times to progressively add inputs.
# Single input
trace.input(question="What is X?")

# Multiple inputs in one call
trace.input(question="What is X?", context=docs)

# Add more inputs later
trace.input(prompt=final_prompt, model="gpt-5.1")
**kwargs
any
Any key-value pairs to record as inputs. Values are JSON-serialized.

trace.output()

Record the final output. Typically called once at the end.
# Simple value
trace.output(response)

# Structured data
trace.output({
    "answer": response,
    "confidence": 0.95
})
value
any
The output value to record. Can be any JSON-serializable value.

trace.state()

Capture state that existed at inference time. Essential for replay functionality.
Why capture state? When debugging or replaying a trace, you need to know not just what inputs were used, but what context existed at the time.
# Document corpus at time of inference
trace.state("documents", [doc.id for doc in corpus])

# Configuration that affected behavior
trace.state("config", {
    "model": "gpt-5.1",
    "temperature": 0.7,
    "guidelines": guidelines_text,
})

# Retrieved chunks
trace.state("retrieved_chunks", [
    {"id": chunk.id, "score": chunk.score}
    for chunk in chunks
])
name
string
required
Name of the state variable
value
any
required
The state value to record. Can be any JSON-serializable value.
Best practice: Capture IDs and references, not full content. For large documents, store references or summaries rather than full text.