Testing the Agent with Examples › Analyzing Test Results

Michael BrenndoerferAugust 2, 20252 min read
AI Agent HandbookAll chapters
Part 11 of 15Evaluation - Measuring Your Agent's Performance
Chapter 31Testing the Agent with Examples › Analyzing Test Results
Reading section 4 of 11 · Analyzing Test Results · 2 minSection 4 of 11 · 2 min

Section 4 of 11 · 2 min read

Reading settings

Notes & comments

Once you've run your tests, you need to understand what they're telling you. Let's create a simple summary function:

PythonIn [7]
CollapseExpand
def summarize_results(results):
    """
    Generate a summary of test results.
    """
    total = len(results)
    passed = sum(1 for r in results if r["passed"])
    failed = total - passed

    print(f"\n{'=' * 50}")
    print("Test Summary")
    print(f"{'=' * 50}")
    print(f"Total tests: {total}")
    print(f"Passed: {passed} ({passed / total * 100:.1f}%)")
    print(f"Failed: {failed} ({failed / total * 100:.1f}%)")

    # Break down by category
    categories = {}
    for result in results:
        # Find the test case to get its category
        test_case = next(
            (tc for tc in test_suite if tc["id"] == result["test_id"]), None
        )
        if test_case:
            cat = test_case["category"]
            if cat not in categories:
                categories[cat] = {"total": 0, "passed": 0}
            categories[cat]["total"] += 1
            if result["passed"]:
                categories[cat]["passed"] += 1

    print("\nBy Category:")
    for cat, stats in categories.items():
        success_rate = stats["passed"] / stats["total"] * 100
        print(
            f"  {cat}: {stats['passed']}/{stats['total']} ({success_rate:.1f}%)"
        )

    # List failed tests
    if failed > 0:
        print("\nFailed Tests:")
        for result in results:
            if not result["passed"]:
                print(f"  {result['test_id']}: {result['input'][:50]}...")

This summary shows the overall pass rate and breaks down performance by category. You might discover that your agent is excellent at tool use but struggles with planning tasks. That tells you exactly where to focus your improvement efforts.

When you run this summary on our example results, you'll see:

Code
CollapseExpand
==================================================
Test Summary
==================================================
Total tests: 5
Passed: 4 (80.0%)
Failed: 1 (20.0%)

By Category:
  tool_use: 1/1 (100.0%)
  memory: 2/2 (100.0%)
  reasoning: 1/1 (100.0%)
  planning: 0/1 (0.0%)

Failed Tests:
  planning_001: Find today's weather and recommend what I should we...

This tells us that our agent handles basic capabilities well but needs work on planning tasks. That's actionable information.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy