Skip to content

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

Open
aajais wants to merge 1 commit intomainfrom
aayush/nested-traces
Open

feat: support nested traces under external Weave parent ops#38
aajais wants to merge 1 commit intomainfrom
aayush/nested-traces

Conversation

@aajais
Copy link
Copy Markdown

@aajais aajais commented Apr 9, 2026

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
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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


You can retrigger this bot by commenting recheck in this Pull Request. 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
Copy link
Copy Markdown
Collaborator

@chance-wnb chance-wnb left a comment

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?


# 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
Collaborator

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
Collaborator

Also @aajais could you please sign the CLA?

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.

2 participants