- Python
- TypeScript
To create an Op, decorate a python function with Calling an Op creates a new Op version if the code has changed from the last call, and logs the inputs and outputs of the function.Functions that you decorate with
weave.op()@weave.op() behave normally (without code versioning and tracking) if you do not call weave.init('your-project-name') before calling them.Ops can be served or deployed using the Weave toolbelt.Customize display names
- Python
- TypeScript
You can customize the Op’s display name by setting the
name parameter in the @weave.op decorator:Apply kinds and colors
To better organize your Ops in the Weave UI, you can apply custom kinds and colors to them by adding thekind and color arguments to the @weave.op decorators in your code. For example, the following code applies an LLM kind and a blue color to the parent function, and a tool kind and a red color to a nested function:
- Python
- TypeScript

kind values are:
agentllmtoolsearch
color values are:
redorangeyellowgreenbluepurple
Customize logged inputs and outputs
- Python
- TypeScript
If you want to change the data that Weave logs without modifying the original function (for example, to hide sensitive data), you can pass
postprocess_inputs and postprocess_output to the Op decorator.postprocess_inputs takes in a dict where the keys are the argument names and the values are the argument values, and returns a dict with the transformed inputs.postprocess_output takes in any value which would normally be returned by the function and returns the transformed output.Control sampling rate
- Python
- TypeScript
You can control how frequently an Op’s calls are traced by setting the When an Op’s call is not sampled:
tracing_sample_rate parameter in the @weave.op decorator. This is useful for high-frequency Ops where you only need to trace a subset of calls.Note that Weave applies sampling rates only to root calls. If an Op has a sample rate but another Op calls it first, that sampling rate is ignored.- The function executes normally
- No trace data is sent to Weave
- Child Ops are also not traced for that call
Control call link output
If you want to suppress the printing of call links during logging, you can set theWEAVE_PRINT_CALL_LINK environment variable to false. This can be useful if you want to reduce output verbosity and reduce clutter in your logs.
Deleting an Op
- Python
- TypeScript
To delete a version of an Op, call Accessing a deleted Op returns an error.
.delete() on the Op ref.