Add W&B Weave Tracing
Instrument an existing AI application, run a representative task, and verify that the resulting Weave trace explains the application's behavior. Preserve the application design unless the user explicitly requests a refactor.
Operating Rules
- Verify current SDK and integration behavior with official W&B Weave documentation before relying on exact APIs or auto-patching claims.
- Add observability without changing prompts, control flow, retries, tool behavior, or user-visible output.
- Initialize Weave once at the application boundary. Reuse an existing valid
weave.init() call.
- Prefer a small trace tree of meaningful workflow, model, retrieval, and tool boundaries over decorating every helper.
- Do not duplicate calls already captured by a supported provider or framework integration.
- Trace only serializable inputs and outputs. Summarize or reference large objects and documents.
- Never send credentials, access tokens, private notes, unpublished documents, or unnecessary personal data to Weave.
- Do not introduce
weave.Model, datasets, assets, scorers, or evaluations unless the user separately requests them.
Workflow
1. Preflight
- Detect the project language, package manager, entrypoint, and normal test or run command.
- Search for existing Weave setup and classify the task:
- Fresh: no Weave integration exists.
- Evolve:
weave.init(), @weave.op, or framework tracing already exists.
- Identify model providers, agent frameworks, tools, retrieval, callbacks, retries, and async boundaries.
- Confirm the target Weave project from existing configuration or
team/project. Do not put credentials in source code.
- Read
references/codebase-analysis.md for a repository-wide integration scan.
2. Build a Compact Trace Map
Present the proposed root and child Calls before editing. Include file, symbol, reason, and capture behavior.
run_agent() root workflow Op
|- provider model call automatic integration
|- retrieve_context() custom Op
`- execute_tool() custom Op
Recommend an Op when its inputs and outputs help answer at least one question:
- What decision did the application make?
- Which model, retrieval, or tool step failed?
- Where did latency or an incorrect value first appear?
- Which step produced the user-visible result?
Do not create a plan file unless the user asks for one. When the user has requested implementation, continue after presenting the compact map without adding mandatory approval gates.
3. Apply Minimal Instrumentation
- Add the dependency using the repository's existing package manager.
- Place or reuse one
weave.init() call before traced work begins.
- Preserve supported automatic provider or framework tracing.
- Add
@weave.op() only to selected application-owned functions.
- Keep Op names stable and inputs and outputs compact and serializable.
- Add redaction, summaries, IDs, hashes, or references when raw content is too sensitive or large.
For Fresh vs Evolve rules, auto-patched wrappers, and unsafe inputs, follow references/codebase-analysis.md. For operation names, privacy, and granularity, follow references/trace-patterns.md.
4. Validate End to End
- Run formatting, static checks, and focused tests appropriate to the changed files.
- Run one representative smoke task when credentials and network access permit.
- Open the emitted Weave URL and verify:
- one expected root Call;
- expected model, retrieval, and tool children;
- useful inputs, outputs, latency, usage, and error state;
- no duplicate spans from wrapping auto-patched calls;
- no secrets or unnecessary private content.
- If a live run is not possible, provide the exact command and expected trace tree. Do not claim that UI verification happened.
- Remove noisy Ops or add a missing decision boundary based on the observed trace.
Hands-on
Use skills/wandb/hands-on/handson_weave.ipynb when the user asks for a guided introduction rather than integration into an existing codebase.
- Part 1: create and inspect a deterministic nested trace.
- Part 2: inspect one simple tool-calling agent trace.
- Optional Codex integration: explain content capture and get confirmation before changing hooks or credentials.
References
- Read
references/codebase-analysis.md before scanning or patching an application.
- Read
references/trace-patterns.md when selecting boundaries, naming Ops, or reviewing privacy and noise.
- Workflow informed by the official wandb/weave-integration-skills repository, narrowed here to tracing-only hackathon workflows.
Response Shape
Return:
- The compact proposed or implemented trace tree.
- Changed files and instrumentation points.
- Auto-patched calls intentionally left unwrapped.
- Privacy or serialization risks.
- Validation performed and expected Weave UI behavior.
1---2name: weave-add-tracing3description: Add W&B Weave tracing to an existing LLM, agent, RAG, or tool-using application with minimal behavioral change. Use when the user asks to integrate Weave, instrument code with @weave.op, trace model or tool calls, choose trace boundaries, account for framework auto-patching, protect sensitive trace data, debug missing traces, or verify a real trace tree. Keep this skill focused on tracing; route evaluations, assets, and general W&B documentation elsewhere.4---56# Add W&B Weave Tracing78Instrument an existing AI application, run a representative task, and verify that the resulting Weave trace explains the application's behavior. Preserve the application design unless the user explicitly requests a refactor.910## Operating Rules1112- Verify current SDK and integration behavior with official W&B Weave documentation before relying on exact APIs or auto-patching claims.13- Add observability without changing prompts, control flow, retries, tool behavior, or user-visible output.14- Initialize Weave once at the application boundary. Reuse an existing valid `weave.init()` call.15- Prefer a small trace tree of meaningful workflow, model, retrieval, and tool boundaries over decorating every helper.16- Do not duplicate calls already captured by a supported provider or framework integration.17- Trace only serializable inputs and outputs. Summarize or reference large objects and documents.18- Never send credentials, access tokens, private notes, unpublished documents, or unnecessary personal data to Weave.19- Do not introduce `weave.Model`, datasets, assets, scorers, or evaluations unless the user separately requests them.2021## Workflow2223### 1. Preflight24251. Detect the project language, package manager, entrypoint, and normal test or run command.262. Search for existing Weave setup and classify the task:27 - **Fresh**: no Weave integration exists.28 - **Evolve**: `weave.init()`, `@weave.op`, or framework tracing already exists.293. Identify model providers, agent frameworks, tools, retrieval, callbacks, retries, and async boundaries.304. Confirm the target Weave project from existing configuration or `team/project`. Do not put credentials in source code.315. Read `references/codebase-analysis.md` for a repository-wide integration scan.3233### 2. Build a Compact Trace Map3435Present the proposed root and child Calls before editing. Include file, symbol, reason, and capture behavior.3637```text38run_agent() root workflow Op39|- provider model call automatic integration40|- retrieve_context() custom Op41`- execute_tool() custom Op42```4344Recommend an Op when its inputs and outputs help answer at least one question:4546- What decision did the application make?47- Which model, retrieval, or tool step failed?48- Where did latency or an incorrect value first appear?49- Which step produced the user-visible result?5051Do not create a plan file unless the user asks for one. When the user has requested implementation, continue after presenting the compact map without adding mandatory approval gates.5253### 3. Apply Minimal Instrumentation54551. Add the dependency using the repository's existing package manager.562. Place or reuse one `weave.init()` call before traced work begins.573. Preserve supported automatic provider or framework tracing.584. Add `@weave.op()` only to selected application-owned functions.595. Keep Op names stable and inputs and outputs compact and serializable.606. Add redaction, summaries, IDs, hashes, or references when raw content is too sensitive or large.6162For Fresh vs Evolve rules, auto-patched wrappers, and unsafe inputs, follow `references/codebase-analysis.md`. For operation names, privacy, and granularity, follow `references/trace-patterns.md`.6364### 4. Validate End to End65661. Run formatting, static checks, and focused tests appropriate to the changed files.672. Run one representative smoke task when credentials and network access permit.683. Open the emitted Weave URL and verify:69 - one expected root Call;70 - expected model, retrieval, and tool children;71 - useful inputs, outputs, latency, usage, and error state;72 - no duplicate spans from wrapping auto-patched calls;73 - no secrets or unnecessary private content.744. If a live run is not possible, provide the exact command and expected trace tree. Do not claim that UI verification happened.755. Remove noisy Ops or add a missing decision boundary based on the observed trace.7677## Hands-on7879Use `skills/wandb/hands-on/handson_weave.ipynb` when the user asks for a guided introduction rather than integration into an existing codebase.8081- Part 1: create and inspect a deterministic nested trace.82- Part 2: inspect one simple tool-calling agent trace.83- Optional Codex integration: explain content capture and get confirmation before changing hooks or credentials.8485## References8687- Read `references/codebase-analysis.md` before scanning or patching an application.88- Read `references/trace-patterns.md` when selecting boundaries, naming Ops, or reviewing privacy and noise.89- Workflow informed by the official [wandb/weave-integration-skills](https://github.com/wandb/weave-integration-skills) repository, narrowed here to tracing-only hackathon workflows.9091## Response Shape9293Return:94951. The compact proposed or implemented trace tree.962. Changed files and instrumentation points.973. Auto-patched calls intentionally left unwrapped.984. Privacy or serialization risks.995. Validation performed and expected Weave UI behavior.