The Complete Production SOP: How to Deploy and Run Weights & Biases Weave LLM Prompt Logger in Autonomous AI Agents
Step-by-step SOP to install and run Weights & Biases Weave LLM Prompt Logger in Codex, Claude Code, and Cursor. Track prompts, versions, and evals cleanly.
Technical Overview & Architectural Context
Autonomous coding agents frequently create unversioned LLM call wrappers, inline raw API keys, or omit evaluation traces when refactoring AI microservices. Without deterministic tracking boundaries, agents modify prompt templates directly in application code without logging iterations, making latency regressions, token surges, and semantic drift impossible to detect across deployments. The Weights & Biases Weave LLM Prompt Logger skill establishes rigid operational guardrails. It enforces the automatic wrapping of generation call-sites with the `@weave.op()` decorator, mandates structured `weave.init()` initialization tied to explicit project parameters, and prevents LLM agents from leaking sensitive payloads or prompt variants into untracked code commits.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Create the local skill manifest directory and inject verified procedural rules into agent runtime path.
Autonomous runtimes parse contextual markdown specs from `.agents/skills` or `.claude/skills`. Installing the `SKILL.md` file locally exposes frontmatter triggers ('log prompts with wandb weave', 'version prompt templates weave', 'track llm experiments weave') so the agent runtime invokes the correct Weave instrumentation patterns deterministically.
mkdir -p .agents/skills/weights-biases-prompts-logger && curl -fsSL https://askills.dev/api/skills/weights-biases-prompts-logger/raw -o .agents/skills/weights-biases-prompts-logger/SKILL.md---
name: "weights-biases-prompts-logger"
description: "Log, version, and evaluate LLM inputs, outputs, and dataset iterations with W&B Weave."
metadata:
author: "Weights & Biases"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "log prompts with wandb weave"
- "version prompt templates weave"
- "track llm experiments weave"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Place the SKILL.md in project root `.cursor/rules/weights-biases-prompts-logger.md` if using Cursor to guarantee zero-shot rule inheritance without prompt preamble overhead.
Ensure directory permissions match agent process execution rights; restricted execution sandboxes reject hidden directory reads if set to 0700 by root.
Dependency Installation & Secret Configuration
Install the official weave package and configure authentication securely through workspace environment boundaries.
Weave requires the `weave` Python library and an authenticated W&B environment. The agent must never commit API keys or output raw credentials in trace messages. We specify environmental boundaries via `.env.local` and add it directly to `.gitignore`.
pip install --upgrade weave && echo 'WANDB_API_KEY=your_wandb_api_key_here' >> .env.local && echo '.env.local' >> .gitignoreimport os
import weave
from dotenv import load_dotenv
load_dotenv(".env.local")
# Initialize trace project with Weave
weave.init(project_name=os.getenv("WEAVE_PROJECT", "agent-prompt-evals"))
@weave.op()
def generate_rag_response(user_query: str, system_context: str) -> dict:
# Simulated LLM generation block with traced inputs and outputs
payload = {"role": "system", "content": system_context}
response = f"Synthesized response for: {user_query}"
return {"query": user_query, "system_context": system_context, "output": response}Use `weave.init(project_name=...)` inside an initialization utility rather than global script scope to prevent duplicate network calls during agent test suite discovery.
Do not hardcode `weave.init()` with absolute corporate entity strings inside generic reusable modules, or agent test suites will fail in localized CI runs.
Intent Matching & Trigger Invocation
Verify deterministic activation using tested natural language prompts matching the SKILL triggers.
Instruct the autonomous agent to wrap existing extraction or generation functions with Weave tracing. By matching the trigger phrase 'log prompts with wandb weave', the agent will load the SOP and apply `@weave.op()` rather than writing legacy `wandb.log()` calls.
Use precise triggers such as 'version prompt templates weave' to force the agent to separate model hyperparameters from prompt templates using Weave Models or Objects.
Avoid prompt instructions like 'just log LLM outputs' which could trigger legacy Wandb logger tools or generic python print logging.
Verification, Linting & Output Quality Gate
Execute automated self-healing checks to verify that Weave operations compile and pass local tests.
Run type checking and unit tests with mocked LLM calls to ensure `@weave.op()` decorators preserve method signatures and do not break async coroutines or dependency injection.
python -m pytest tests/test_llm_service.py -k "test_weave_tracing" && ruff check llm_service.pyimport pytest
from llm_service import generate_rag_response
def test_weave_tracing_contract():
res = generate_rag_response("test prompt", "system prompt")
assert "output" in res
assert res["query"] == "test prompt"In local offline mode, set `WANDB_MODE=offline` during testing to prevent network timeouts when validating agent-generated Weave ops.
Wrapping generator functions yielding streams with `@weave.op()` can consume generators eagerly if not using Weave's native streaming integration.
Real-World Scenario: Instrumenting Multi-Step Support Prompt Chain with W&B Weave Traces
“We have an unmonitored ticket routing script `support_router.py`. Please log prompts with wandb weave, version prompt templates weave, and set up an evaluation harness to benchmark classification accuracy without breaking existing sync calls.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent decorated module functions with `@weave.op()` and invoked them at import time or during unit tests prior to calling `weave.init()`.
Ensure `weave.init('project-name')` is called prior to executing any `@weave.op()` function, or wrap test setups in a fixture: `weave.init('test-project')`.Root Cause: Missing or invalid `WANDB_API_KEY` in environment, or target project entity path does not exist for the authenticated user.
export WANDB_API_KEY="<valid_key>" && python -c "import weave; weave.init('default-workspace')"Frequently Asked Questions (Weights & Biases Weave LLM Prompt Logger SOP)
Q:Can I use Weights & Biases Weave LLM Prompt Logger across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification. You can place the file inside `.agents/skills/` or runtime-specific rule locations (`.cursor/rules/`, `.claude/skills/`), and all supported runtimes will apply the same operational boundaries.
Q:How does Weights & Biases Weave LLM Prompt Logger prevent context window overflow during long agent sessions?
By providing concise, procedural boundaries focused strictly on Weave's idiomatic API (`weave.init`, `@weave.op`, evaluation scaffolding), eliminating the need for verbose in-prompt explanations and unvetted multi-page documentation snippets.
Q:Does this skill require escalated root or container permissions?
No. The skill is audited with a 98/100 security score. It requires only standard workspace file access (`fs_read: true`, `fs_write: workspace`) and does not require shell root access or container escalation.
Ready to equip your autonomous agent with Weights & Biases Weave LLM Prompt Logger?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.