Skip to content

chore(weave): add weave-instrument agent skill - #7370

Merged
andrewtruong merged 2 commits into
masterfrom
andrew/weave-instrument-skill
Jun 30, 2026
Merged

chore(weave): add weave-instrument agent skill#7370
andrewtruong merged 2 commits into
masterfrom
andrew/weave-instrument-skill

Conversation

@andrewtruong

@andrewtruong andrewtruong commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Adds the weave-instrument skill which helps an agent add Weave to a Python or TypeScript LLM codebase based on how their code is structured. Supported instrumentation includes the OTEL auto-instrumentation, Session-based manual implementation, and a generic OTEL export.


Doc:

Instrument your agent with the weave-instrument skill

weave-instrument is an agent skill that adds Weave tracing to an existing LLM or
agent codebase. Point your agent at your project and ask it to add Weave using this skill.
It will:

  1. wire up weave.init();
  2. set up authentication; and
  3. instrument your code so your runs show up in the Weave UI.

It works for Python and TypeScript!

What it does

The skill picks the right tracing approach for your code instead of applying a fixed
template. It decides based on the kind of traces you want and the structure of your code,
not on which framework you use, so it works for any agent: a known framework, an in-house
one, or a plain loop with no framework at all. It can:

  • Wrap your agent with the Session SDK (Turn, LLM, Tool, and SubAgent spans) to
    produce agent-shaped traces in the Weave Agents tab. This is the universal path and
    works for any agent.
  • Enable OTEL auto-instrumentation for libraries Weave already recognizes, where a
    single weave.init() call captures everything with no per-call code.
  • Send an existing OpenTelemetry pipeline to Weave when your app already emits OTel
    spans or owns its own tracer.

It then verifies that traces actually arrive, and tells you the exact URL where your data
will land.

How to use it

  1. Install the skill. Put the weave-instrument folder wherever your coding agent loads
    skills from. For Claude Code, that's ~/.claude/skills/ (available in every project) or a
    project's .claude/skills/ (just that project). Your agent discovers it automatically.
  2. Authenticate to W&B in your own terminal. Set WANDB_API_KEY (from
    https://wandb.ai/authorize) or run wandb login. The skill never handles your key.
  3. Ask your agent to instrument your project, in plain language. For example:
    • "Add Weave to my agent."
    • "Get my agent into the Weave Agents tab."
    • "Trace my tool calls with the Weave Session SDK."
    • "Set up Weave logging for this app."

Your agent reads your code, proposes a short plan, makes the edits, and asks you to confirm
the project name (entity/project).

What you get

Tracing that matches how your agent is built, added without changing its behavior: the same
outputs, the same exceptions, and spans that always close. Your runs appear at
https://wandb.ai/<entity>/<project>/weave.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@andrewtruong
andrewtruong force-pushed the andrew/weave-instrument-skill branch 2 times, most recently from ffa1c9b to 2b1f673 Compare June 26, 2026 16:50
@andrewtruong
andrewtruong marked this pull request as ready for review June 26, 2026 19:40
@andrewtruong
andrewtruong requested a review from a team as a code owner June 26, 2026 19:40
Comment thread skills/weave-instrument/SKILL.md Outdated
Comment on lines +104 to +106
(`pyproject.toml` or `requirements.txt`, and `package.json`). Note the *exact* libraries: `openai`,
`anthropic`, `langchain`, `openai-agents` (`import agents`), `claude_agent_sdk`, `google.adk`,
`crewai`, `llama_index`, and so on. Step 3 is where you resolve whether the installed Weave

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These package names are bit different in package.json.

2. **What is the structure?** The turn boundary (one input maps to one cycle), the model calls, tool
dispatch, sub-agents, and any streaming or concurrency. This is what you instrument, and it exists
whatever the library is.
3. **Probe auto-coverage.** Do not trust a memorized list, because it rots. Check whether the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it rots

v dramatic

## Procedure

1. **What shape is wanted?** An agent-shaped tree goes to the Agents tab. Flat model-call traces
("just my LLM calls") go to the Traces tab.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this might be getting renamed? https://github.com/wandb/core/pull/46847

Comment on lines +47 to +49
- **Agent-shaped, lands in the Agents tab, no extra code:** the OpenAI Agents SDK (`import agents`),
the Claude Agent SDK (`claude_agent_sdk`), and Google ADK (`google.adk`, with an import-order
caveat).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we detail the specific js packages name like we do below as well?

The Session SDK models Session, then Turn (`invoke_agent`), then a set of LLM (`chat`), Tool
(`execute_tool`), and SubAgent (`invoke_agent`) spans. It covers loops, unknown frameworks, streaming
(hold the LLM span open, accumulate, then close it), sub-agents, async work (Python contextvars, or
TypeScript `runIsolated`), and post-hoc logging (`log_turn` or `log_session`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TS SDK doesn't have these log* fns, worth mentioning?

Comment on lines +35 to +39
for (const tc of msg.tool_calls ?? []) {
const tool = weave.startTool({name: tc.function.name, args: tc.function.arguments, toolCallId: tc.id});
try { tool.result = await runTool(JSON.parse(tc.function.arguments)); }
finally { tool.end(); }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is in the wrong block -- msg wouldn't be in scope here.

Comment on lines +40 to +41
} finally { turn.end(); }
} finally { session.end(); }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's worth running this through prettier so the agent has example of code more similar to what users' might have set up w/their repos?

`WANDB_API_KEY`, or call `await weave.login(apiKey)` once. The user does this; never hard-code a
key.

## Canonical pattern (try/finally, because JS has no `with`, so close in `finally`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding to our pod sync list: we should talk about some more friendly APIs to support this.

@drtangible drtangible left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Comment thread skills/weave-instrument/SKILL.md Outdated
calls, since registry membership alone does not prove it.
- If you cannot run it (because of missing provider keys or heavy setup), give the user an exact
copy-paste command to run themselves, and tell them what to look for: the printed
`https://wandb.ai/.../weave` link, and a trace in the Agents or Calls tab.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call out the parameterized https://wandb.ai/<entity>/<project>/weave thing elsewhere, should we be consistent?

Comment thread skills/weave-instrument/SKILL.md Outdated
Comment on lines +162 to +163
test, or a tiny script that exercises one turn) and confirm that a Weave URL is printed and a trace
shows up at the project URL.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any urls when running the TS examples -- we have a printCallLink setting that appears only relevant to some op-related stuff. Following up in Slack, since the skill seems to be relying on this.

@andrewtruong
andrewtruong force-pushed the andrew/weave-instrument-skill branch from 0f3e658 to 52bf68a Compare June 26, 2026 21:51
@andrewtruong
andrewtruong requested a review from a team as a code owner June 26, 2026 21:51
@andrewtruong
andrewtruong changed the base branch from master to andrew/ts-init-print-weave-url June 26, 2026 21:51
Base automatically changed from andrew/ts-init-print-weave-url to master June 26, 2026 22:03
@andrewtruong andrewtruong changed the title chore(weave): add weave-instrument Claude Code skill chore(weave): add weave-instrument agent skill Jun 30, 2026
@andrewtruong
andrewtruong merged commit 095c41b into master Jun 30, 2026
110 checks passed
@andrewtruong
andrewtruong deleted the andrew/weave-instrument-skill branch June 30, 2026 00:38
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants