feat(daemon): emit GenAI spans via the Weave Node SDK#109
feat(daemon): emit GenAI spans via the Weave Node SDK#109rgao-coreweave wants to merge 5 commits into
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
384d635 to
c08c991
Compare
Replace the hand-rolled OTLP exporter and genaiSpans span builders with weave.init() and the SDK genai primitives (startConversation, startTurn, startLLM, startTool, startSubagent). Integration identity rides the conversation attributes, dropping IntegrationBaggageSpanProcessor. Assistant text and thinking become ordered gen_ai.output.messages parts on the chat span; the model's tools nest under it. Subagents flatten (published SubAgent is a leaf): in-session subagent spans parent under the turn tagged gen_ai.agent.name; cross-session teammates get their own turn-trace stitched by conversation_id. Collapses the stale migrate-sdk stack (#73, #75, #76, #77, #78). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c08c991 to
f05fd9e
Compare
Bumps the weave floor to the released 0.16.2 (the version whose genai record()/agent-identity API this migration targets). Also regenerates package-lock.json, which the SDK-migration commit (f05fd9e) left in its pre-migration state: it still pinned the removed @opentelemetry OTLP-exporter tree and omitted both weave and the @anthropic-ai/claude-agent-sdk dev dependency, so `npm ci` (format-and-lint + publish) failed with EUSAGE. The lock is now in sync: npm ci, build, and 73 tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
initWeaveInMemory() calls weave.init(), which resolves a W&B API key from WANDB_API_KEY/~/.netrc and throws without one, even with a custom offline span processor. The in-process genai tests therefore passed only where a netrc happened to exist and failed on CI (no netrc) with 'wandb API key not found', which surfaced once the lockfile fix let `npm ci` reach the test step. Seed a fake key (as startTestDaemon already does for the subprocess path) so the bridge is hermetic. Pre-existing behavior on 0.16.1 too; not specific to the 0.16.2 bump. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use the 0.16.2 genai setters instead of hand-writing gen_ai.* attributes:
recordChat now calls llm.record({outputMessages, usage, outputType, responseId,
finishReasons}); Turn/SubAgent take agentVersion (and the turn's model) as init
opts; the subagent's agent_id goes through subAgent.record({agentId}). Drop the
subagent's manual conversation.id (inherited from the parent turn) and terse the
touched comments. Behavior-preserving: the same gen_ai.* attributes are emitted,
so the span-snapshot tests are unchanged (73/73).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move resolveProject/resolveApiKey/resolveAgentName (+ their source enums) and resolveDaemonConfig/daemonConfigFingerprint out of cli.ts and daemon.ts into a new config.ts, so both use one implementation without the cli<->daemon import cycle that previously blocked reuse. resolveDaemonConfig now delegates to the per-field resolvers (env param defaulting to process.env), so the env-over-settings precedence is defined once instead of re-implemented. The in-process genai test bridge resolves its project + key through the same path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Collapses the stale migrate-sdk stack (#73/#75/#76/#77/#78) into one change against main, on published
weave@0.16.1. Replaces the hand-rolled OTLP exporter +genaiSpansbuilders withweave.init()+ the SDK genai primitives. Assistant text/thinking become orderedgen_ai.output.messagesparts on thechatspan; tools nest under it. Subagents flatten (publishedSubAgentis a leaf): in-session subagent spans parent under the turn taggedgen_ai.agent.name; cross-session teammates get their own turn-trace stitched byconversation_id.Test plan
npm run buildnpm test(70 tests)🤖 Generated with Claude Code