๐Ÿš€ Everything is free โ€” help us improve! Submit feedback and shape the platform.
๐ŸงชTDD Challengeยทintermediateยทโฑ๏ธ 30โ€“45mยทโญ 175 XP

M-072Trace a Multi-Step Agent

Description

Nebula Corp's customer support agent makes multiple LLM calls and tool executions per request, but there's no visibility into what happens between the user's question and the final answer. Build a tracing wrapper for the agent loop that captures each LLM call, tool execution, and the overall trace with cumulative metrics. Include loop detection to flag when the agent calls the same tool with the same arguments more than twice.

Test Cases (3)

Traces agent execution
Should create spans for each LLM call and tool execution
Input:runTracedAgent('Look up C001')
Expected:CONTAINS:generation
Captures tool calls
Should record all tool calls
Input:runTracedAgent('Look up C001')
Expected:CONTAINS:lookup_customer
Produces final answer
Should capture the agent's final answer
Input:runTracedAgent('Look up C001')
Expected:CONTAINS:FINAL

Related Lessons

Click Run / Check to validate your solution