Skip to main content
One tool execution. Maps to an execute_tool OTel span. arguments and result use the JSONString annotation: callers can assign a dict / list / scalar and the SDK JSON-encodes it at construction or assignment. The stored value is always a string, matching the wire format per GenAI semconv. Tool is a Pydantic model. Set any field below as a keyword argument when you construct it. Tool is a context manager and can be used in a with statement.

Fields

Methods

end

start

Start this span once; context-manager entry uses the same path.

record_error

Record a failure without ending the span; call end() when ready.

set_attributes

Stamp arbitrary OTel attributes on this span. Pass a dict whether you have one key or many; single-key callers use span.set_attributes({"weave.tag": "value"}). Mirrors OTel’s Span.set_attributes. Must be called after a start_* factory, start(), or with starts the span, and before it ends. Outside that window the call is a no-op and logs a warning. For batch ingest, populate the object’s declared fields directly and pass it to log_turn / log_conversation.
Last modified on September 30, 2026