Skip to content

Integrate Your Agent

Get your agent ready for testing

testing works with a simple yet powerful trace format as the common denominator for testing agents.

This trace format is a list of dictionaries, where each dictionary represents a message in the conversation. It is equivalent to the OpenAI chat format.

Each message has a role key that specifies the role of the speaker (e.g., user or assistant) and a content key that contains the message content.

{
    "role": "user", 
    "content": "Hello there"
},
{
    "role": "assistant", 
    "content": "Hello there", 
    "tool_calls": [
        {
            "type": "function",
            "function": {
                "name": "greet",
                "arguments": {
                    "name": "there"
                }
            }
        }
    ]
},
{
    "role": "user", 
    "content": "I need help with something."
}

Based on this simple format, it is easy to integrate your agent with Invariant testing.

Extended Format Support testing also supports additional custom properties in the trace format, e.g. for metadata. Note, however, that convenience methods like Trace.tool_calls() assume the standard format. Similarly, if you are planning to visualize the trace in Explorer, we advise you to stick to the standard format.

To learn about how to do this, follow one of the example guides below: