Skip to main content
TracePilot’s rule is simple: if your code makes an async call, you can wrap it. Use tp.wrapOpenAI for any call to OpenAI’s chat completions API, and tp.wrapToolCall for any other async operation you want to trace — web searches, database queries, external API calls, file reads, or anything else. This works with AutoGen, custom agent loops, event-driven systems, or any orchestration pattern you’ve built.

Core pattern

Every wrapped call returns { result, spanId }. Pass spanId as parentSpanId to subsequent calls to build a parent-child span tree in the dashboard. The result is the original return value, unchanged.

Patterns

Each step passes its spanId as parentSpanId for the next step, creating a chain of linked spans.

AutoGen compatibility

AutoGen uses async function calls internally. Wrap at the same level — intercept the OpenAI call inside your AutoGen agent’s reply function, or wrap the tool functions your agent registers.
AutoGen support is available for any async call pattern. If AutoGen exposes a custom reply function hook in your version, use tracedReplyFunction there. Refer to your AutoGen version’s docs for the exact hook name.

Building a custom orchestration loop

If you’re running your own agent loop, wrap every call inside the loop body and thread spanId values forward.
The key rule: wrap any async call you want to trace, and pass parentSpanId to link related spans. Even if you only wrap some calls, those spans still appear in the dashboard — you don’t need to wrap everything at once.