Skip to main content

Weave by Weights & Biases

Open in Colab Stable Version Download Stats Github Checks

Weave is a toolkit for tracing and evaluating AI agents, built by Weights & Biases.

You can use Weave to:

  • Trace agents. Conversations, turns, LLM calls, and tool calls show up in the Agents tab.
  • Evaluate agents and LLM applications.
  • Trace functions with @weave.op when you want the Calls tab, not the Agents tab.

Documentation

Our documentation site can be found here.

Start here for agents:

  • Choose an agent integration — OpenAI Agents SDK, Claude Agent SDK, and Google ADK. weave.init() is enough for those SDKs.
  • Custom agents — wrap your own loop with start_conversation, start_turn, start_llm, and start_tool.

Prerequisites

Quick start: trace an agent

This example uses the OpenAI Agents SDK. The Python import is agents; the package name is openai-agents. Weave autopatches it after weave.init(). Traces land in the Agents tab, not the Calls tab.

pip install weave openai-agents requests
import asyncio
import requests
import weave
from agents import Agent, Runner, function_tool

weave.init("<your-team>/<your-project-name>")


@function_tool
def wikipedia_search(query: str) -> str:
    """Search Wikipedia for a topic and return its title and intro paragraph."""
    r = requests.get(
        "https://en.wikipedia.org/w/api.php",
        params={
            "action": "query",
            "generator": "search",
            "gsrsearch": query,
            "gsrlimit": 1,
            "prop": "extracts",
            "exintro": True,
            "explaintext": True,
            "format": "json",
        },
        headers={"User-Agent": "weave-demo"},
    ).json()
    page = next(iter(r["query"]["pages"].values()))
    return f"{page['title']}: {page['extract']}"


agent = Agent(
    name="Research assistant",
    instructions=(
        "You are a research assistant. Use the wikipedia_search tool to look up "
        "topics when needed, and cite the article titles you used."
    ),
    tools=[wikipedia_search],
)


async def main():
    history = []
    for question in [
        "Who founded Anthropic?",
        "What is Claude (the AI assistant)?",
        "Summarize what we discussed in one sentence.",
    ]:
        history.append({"role": "user", "content": question})
        print(f"USER: {question}")
        result = await Runner.run(agent, input=history)
        print(f"AGENT: {result.final_output}\n")
        history = result.to_input_list()


asyncio.run(main())

weave.init() prints a project URL. Open the Agents tab.

Claude Agent SDK works the same way: install the framework, call weave.init(), run the agent. For Google ADK, import google.adk before weave.init(). See Choose an agent integration.

Custom agents

If you are not using a supported agent SDK, wrap your own loop. This is the Conversation SDK, not the @weave.op path.

Use start_conversation, start_turn, and start_llm. In Python they are context managers and close on exceptions. start_session and Session still exist; they emit a DeprecationWarning. Do not use them in new code.

import weave

weave.init("<your-team>/<your-project-name>")

with weave.start_conversation(agent_name="research-bot"):
    with weave.start_turn(user_message="Who founded Anthropic?"):
        with weave.start_llm(model="gpt-4o-mini", provider_name="openai") as llm:
            llm.output("Anthropic was founded by former OpenAI researchers.")
            llm.record(
                usage=weave.Usage(input_tokens=12, output_tokens=9),
                response_model="gpt-4o-mini",
            )

Always pass provider_name. Weave does not infer it from the model name.

For a multi-turn loop with tools, see the custom agents quickstart.

Function tracing

@weave.op traces a function. Those traces land in the Calls tab, not the Agents tab. Use it for evaluations, scorers, and LLM calls that are not an agent loop.

Plain openai is also auto-traced into the Calls tab after weave.init(). @weave.op wraps the call in a parent function, so the OpenAI request sits under extract_fruit.

pip install weave openai
import json
import weave
from openai import OpenAI

weave.init("<your-team>/<your-project-name>")


@weave.op
def extract_fruit(sentence: str) -> dict:
    client = OpenAI()
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            {
                "role": "system",
                "content": (
                    "You will be provided with unstructured data, and your task is to parse "
                    "it into one JSON object with fruit, color and flavor as keys."
                ),
            },
            {"role": "user", "content": sentence},
        ],
        temperature=0.7,
        response_format={"type": "json_object"},
    )
    extracted = response.choices[0].message.content
    return json.loads(extracted)


extract_fruit(
    "There are many fruits that were found on the recently discovered planet Goocrux. "
    "There are neoskizzles that grow there, which are purple and taste like candy."
)

Contributing

Interested in pulling back the hood or contributing? Awesome, before you dive in, here's what you need to know.

We're in the process of 🧹 cleaning up 🧹. This codebase contains a large amount code for the "Weave engine" and "Weave boards", which we've put on pause as we focus on Tracing and Evaluations.

The Weave Tracing code is mostly in weave/trace. The trace server it talks to is developed in wandb/core; weave/trace_server only keeps deprecated import aliases for weave.shared.

The Weave Evaluations code is mostly in weave/flow.

Metadata

Release files for weave 0.53.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weave 0.53.13
File Size Uploaded Provenance
weave-0.53.13.tar.gz 805.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for weave 0.53.13
File Interpreter ABI Platform
weave-0.53.13-py3-none-any.whl Python 3 none any Details

Total release size: 2.0 MB

Release files / weave-0.53.13.tar.gz

Download URL weave-0.53.13.tar.gz
Size 805.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5db2ed6638b52463f5177bfdb156ae3747a10c16263343e99a2b218721ba38c8
BLAKE2b-256 checksum
How to use checksums
eca9e6bccb5c964900d3f0cbb736e498296404773fb49f6e76685192877dc769
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / weave-0.53.13-py3-none-any.whl

Download URL weave-0.53.13-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
baf7f1dfdee8d5c28dc554fa905eaf0ff81a4b4dee257d054c9778c3b042ab19
BLAKE2b-256 checksum
How to use checksums
93d5c7b820b334c31eeb21564028fc979219415f75d6279d4af7c23e0a29ef5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for weave 0.53.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for weave-0.53.13.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.53.13 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page