weave_concepts.py
parentFunction) with two child functions (llmCall and nestedToolCall, one of which contains a deeply nested function (deepNestedToolCall).
When to use autopatching
Weave automatically integrates with many popular LLM providers and frameworks. When using a supported integration, you can callweave.init('<your-test-team/your-project-name>') in your code to automatically capture your LLM’s input and output.
However, this method only captures data about top-level interactions with supported LLMs. If you want to trace specific, arbitrary functions in your application, you should use Ops.
Use Ops
An Op is a versioned, tracked function. When you decorate a function with@weave.op() (Python) or wrap it with weave.op() (TypeScript), Weave automatically captures its code, inputs, outputs, and execution metadata. The resulting captured data are Calls.
You can apply Ops to any arbitrary function in your application.
In the sample code, all of the functions are decorated with weave.op(). For example, the Op for the parentFunction() instructs Weave to capture data about it during its execution.
weave_concepts.py
Understand Calls
A Call is a logged execution of a function decorated by an Op. Each time a decorated function is executed, Weave creates an immutable Call object that captures the function’s:- Input arguments
- Output value
- Timing and latency
- Parent-child relationships (for nested calls)
- Any errors that occurred
- Belong to a Trace (a collection of calls in the same execution context)
- Have parent and child Calls, forming a tree structure
Call object for parentFunction
Call object for parentFunction
parentFunction, but also contains the data for the function’s child functions. This results in a data structure called a Trace tree.
You can retrieve and view the sample code’s Call object by appending the following lines to the example:
Understand Traces
Traces are full trees of Calls that share the same execution context. Each Trace contains an ID (trace_id) you can use to retrieve the entire tree of Calls. Retrieving Call information using the Call’s id only returns data about the specified Call and none of its child Calls.
The sample code produces a Trace tree with the following structure:
