← Table of Contents · Page 292 of 868

TRACING AND SPANS

Part 6 of 10

A WORKED TRACE WALKTHROUGH Suppose a trace for one run contains eight spans. The top span lasted forty seconds. The first model call lasted three seconds, then a search tool call lasted two seconds, then a second model call lasted four seconds. Next, a file-reading tool call lasted twenty-six seconds and ended in a timeout error, after which the agent retried the same call and it succeeded in one second. The final model call lasted three seconds and produced the answer. Reading this trace tells a clear story. Most of the time was lost in one slow tool call that timed out. The fix is therefore not to change the prompt but to give that tool a shorter timeout and a faster retry, which you studied in Chapter 56. Without the trace, the team might have blamed the model for being slow. With the trace, the cause is obvious in seconds. TRACES ACROSS SEVERAL AGENTS When one agent calls another, the trace should continue across the boundary. Pass the trace identifier and the identifier of the calling span to the second agent, so that its spans appear as children of the call. The final picture then shows the supervisor, each worker, and every tool beneath them in one tree. Without this, a slow answer from a team of agents is nearly impossible to explain, because the delay may hide inside any one of them. You will meet this situation again in Chapters 43 and 44.
Advertisement
Read Aloud:
0:00 / 0:00