Skip to content

feat: support nested traces under external Weave parent ops - #38

Merged
chance-wnb merged 2 commits into
mainfrom
aayush/nested-traces
Apr 13, 2026
Merged

feat: support nested traces under external Weave parent ops#38
chance-wnb merged 2 commits into
mainfrom
aayush/nested-traces

Conversation

@aajais

@aajais aajais commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Forwards WEAVE_PARENT_CALL_ID and WEAVE_TRACE_ID environment variables from the hook handler into the daemon event payload, enabling Claude Code sessions invoked inside a @weave.op to be recorded as child calls.
  • Uses the parent's trace ID (when present) instead of creating a new standalone root trace, and sets parent_id on the session call to form a proper parent-child hierarchy in Weave.

Changes

hooks/hook-handler.sh

  • Reads WEAVE_PARENT_CALL_ID and WEAVE_TRACE_ID from the environment and injects them into the JSON event payload before sending to the daemon socket.

src/daemon.ts

  • Adds parentCallId to the SessionState interface.
  • Extracts weave_parent_call_id and weave_trace_id from the incoming event payload.
  • Prefers the parent trace ID over the auto-resolved trace ID when available.
  • Sets parent_id on the claude_code.session call to the parent call ID (instead of null), nesting the session under the external op.

Test plan

  • Run a Claude Code session without WEAVE_PARENT_CALL_ID / WEAVE_TRACE_ID set.
image
  • Run a Claude Code session with both env vars set (e.g. from within a @weave.op)
image

@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@aajais
aajais force-pushed the aayush/nested-traces branch from 5ab40b9 to 3b6530c Compare April 9, 2026 18:52
@aajais
aajais requested a review from chance-wnb April 9, 2026 18:52

@chance-wnb chance-wnb 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.

Hey Aayush! Thanks for your contribution! I love it!

I made one suggestion, could you please take a look?

Comment thread hooks/hook-handler.sh Outdated

# Inject parent Weave call context so the daemon can nest this session
# under an external @weave.op (values are UUIDs — safe for literal embedding).
EXTRA=""

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.

  1. I think JSON handling in the form of string manipulation is fragile. can we avoid it if we can?

  2. I think the daemon is capable of reading the same env vars, why don't you just have the daemon process read it directly instead of getting passed over?

@chance-wnb

Copy link
Copy Markdown
Contributor

Also @aajais could you please sign the CLA?

@aajais
aajais force-pushed the aayush/nested-traces branch from 3b6530c to 91862db Compare April 13, 2026 21:30
@aajais

aajais commented Apr 13, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Apr 13, 2026

@chance-wnb chance-wnb 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.

LGTM. Thanks for your contribution!

@chance-wnb
chance-wnb merged commit 45693cc into main Apr 13, 2026
4 of 5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 13, 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