Skip to content

feat(daemon): emit GenAI spans via the Weave Node SDK#109

Draft
rgao-coreweave wants to merge 5 commits into
mainfrom
migrate-sdk/weave-genai-spans
Draft

feat(daemon): emit GenAI spans via the Weave Node SDK#109
rgao-coreweave wants to merge 5 commits into
mainfrom
migrate-sdk/weave-genai-spans

Conversation

@rgao-coreweave

Copy link
Copy Markdown
Contributor

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 + genaiSpans builders with weave.init() + the SDK genai primitives. Assistant text/thinking become ordered gen_ai.output.messages parts on the chat span; 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.

Test plan

  • npm run build
  • npm test (70 tests)
  • Live Weave server run pending.

🤖 Generated with Claude Code

@socket-security

socket-security Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​anthropic-ai/​claude-agent-sdk@​0.3.202731009210070
Addedweave@​0.16.28210010097100

View full report

@socket-security

socket-security Bot commented Jul 2, 2026

Copy link
Copy Markdown

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.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm @protobufjs/float is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: package-lock.jsonnpm/weave@0.16.2npm/@protobufjs/float@1.0.2

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@protobufjs/float@1.0.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Medium
Install-time scripts: npm protobufjs during postinstall

Install script: postinstall

Source: node scripts/postinstall

From: package-lock.jsonnpm/weave@0.16.2npm/protobufjs@7.6.5

ℹ Read more on: This package | This alert | What is an install script?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/protobufjs@7.6.5. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@rgao-coreweave rgao-coreweave force-pushed the migrate-sdk/weave-genai-spans branch 5 times, most recently from 384d635 to c08c991 Compare July 2, 2026 18:34
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>
@rgao-coreweave rgao-coreweave force-pushed the migrate-sdk/weave-genai-spans branch from c08c991 to f05fd9e Compare July 2, 2026 18:49
rgao-coreweave and others added 4 commits July 6, 2026 18:06
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant