tp.wrapToolCall() wraps any asynchronous function — a database write, an email send, a web search, or any other tool invocation — and records it as a structured span linked to a parent span in your execution tree. Set isDestructive: true on operations that modify external state so the dashboard surfaces a warning badge, making it easy to audit side effects during debugging.
Signature
Parameters
string
required
A human-readable display name for the tool. This label appears in the dashboard’s execution tree and is used to identify the span when debugging.
() => Promise<T>
required
A zero-argument async function that executes the tool. Wrap your call in an arrow function so TracePilot can time it and capture any errors that are thrown.
string
required
The
spanId of the parent span. Tool calls must always be linked to a parent — typically the spanId returned by the wrapOpenAI call that decided to invoke this tool.number
required
An integer that controls where this span appears among its siblings in the execution tree. Use sequential integers (1, 2, 3…) to preserve the correct order in the dashboard.
boolean
When
true, the dashboard marks this span with a ⚠ Destructive badge. Use this flag for any operation that modifies external state — sending emails, writing to a database, publishing messages, calling payment APIs, and so on. Defaults to false.Return value
T
The value resolved by your
call function, returned unchanged. The generic type T is inferred from your function’s return type.string
The ID of the span created for this tool call. You can pass this as
parentSpanId to downstream wrapOpenAI or wrapToolCall calls to nest them further.