Agent tracing in Weave#6288
Conversation
| ## Tracing (Weave) | ||
|
|
||
| Dashboards: [prod](https://wandb.ai/moz-bugbug/hackbot-prod/weave/agents), [dev](https://wandb.ai/moz-bugbug/hackbot-dev), [test](https://wandb.ai/moz-bugbug/hackbot-test) | ||
|
|
||
| Tracing is handled once in the runtime (`hackbot_runtime.tracing`), so every agent | ||
| gets it for free — there's nothing to add per agent. On startup the runtime calls | ||
| `weave.init()`, which autopatches the Claude Agent SDK (or other supported frameworks) and captures each query, | ||
| model response, and tool call, labelled with the agent's name (so the Weave | ||
| **Agents** view shows `build-repair`, `bug-fix`, etc. instead of a generic | ||
| `claude_agent_sdk`). | ||
|
|
||
| It is **opt-in**: the runtime only traces when it has W&B credentials, and never | ||
| fails a run if Weave can't start. `WEAVE_PROJECT` picks the destination project | ||
| (a bare `project` or `entity/project`; defaults to `hackbot-test`). | ||
|
|
||
| **Locally**, add the key to your root `.env`; the agent's `compose.yml` should | ||
| pass `WANDB_API_KEY` through to the agent container. | ||
|
|
||
| `.env`: | ||
|
|
||
| ```dotenv | ||
| WANDB_API_KEY=... | ||
| ``` | ||
|
|
||
| `compose.yml`: | ||
|
|
||
| ```yaml | ||
| environment: | ||
| - WANDB_API_KEY=${WANDB_API_KEY:-} | ||
| ``` | ||
|
|
||
| **In deployment**, the agent container holds no long-lived key: it authenticates | ||
| via W&B [Identity Federation](https://docs.wandb.ai/platform/hosting/iam/identity_federation). | ||
|
|
There was a problem hiding this comment.
Let us drop this out to keep it short. We could have advanced docs for Hackbot in /docs, we could do this later since it is out of the scope of this PR.
There was a problem hiding this comment.
I'd rather add docs together with functionality, especially since we already have them here. I can move it to another place.
There was a problem hiding this comment.
moved to /docs, we can refactor later if we don't like it
There was a problem hiding this comment.
Let us file a follow-up issue to reduce duplication between wandb_wif.py and anthropic_wif.py.
There was a problem hiding this comment.
I'll add the issue when we land it
|
|
||
| [project.optional-dependencies] | ||
| claude-sdk = ["claude-agent-sdk>=0.1.30", "agent-tools[claude-sdk]"] | ||
| claude-sdk = ["claude-agent-sdk>=0.1.30", "agent-tools[claude-sdk]", "weave>=0.53.1"] |
There was a problem hiding this comment.
I do not think this needs to be specific to the Claude SDK.
Enable Weave tracing for all agents. The agent name will be the same as its folder name.
See test example traces: https://wandb.ai/moz-bugbug/hackbot-test/weave/agents?filters[agent_name]=build-repair
Auth through WIF similar to Anthropic (need to test that on deployment).
fixes #6266