The concept of success or failure is crucial for AI agent observability. Atla Insights provides explicit functions to mark trace outcomes, enabling better error analysis and performance tracking.

Usage

Use mark_success() and mark_failure() within instrumented functions to indicate trace outcomes:
from atla_insights import (
    configure,
    instrument,
    instrument_openai,
    mark_failure,
    mark_success,
)
from openai import OpenAI

configure(token="<MY_ATLA_INSIGHTS_TOKEN>")
instrument_openai()

client = OpenAI()

@instrument("Math solving agent")
def solve_math_problem(problem: str) -> str:
    result = client.chat.completions.create(
        model="gpt-4o",
        messages=[
            {
                "role": "user",
                "content": f"Solve this math problem: {problem}. Reply with only the answer.",
            }
        ]
    )
    response = result.choices[0].message.content

    # Custom success criteria
    if is_correct_answer(response, problem):
        mark_success()
    else:
        mark_failure()
    
    return response

def is_correct_answer(response: str, problem: str) -> bool:
    # Your validation logic here
    if "2 + 2" in problem:
        return "4" in response
    # Add more validation logic
    return True
Use mark_success() and mark_failure() within an instrumented function (decorated with @instrument).