Skip to content

feat: propagate W3C trace context to LLM providers - #60

Open
siglp wants to merge 1 commit into
langfuse:mainfrom
siglp:feat/trace-context-propagation
Open

siglp wants to merge 1 commit into
langfuse:mainfrom
siglp:feat/trace-context-propagation

Conversation

@siglp

@siglp siglp commented Nov 3, 2026

Copy link
Copy Markdown

Summary

Add opt-in W3C trace context propagation (traceparent and tracestate) from OpenCode to LLM providers, enabling end-to-end distributed tracing through gateways such as AgentGateway.

Changes

  • Support OpenCode V1 and V2.
  • Preserve existing trace headers.
  • Persist and restore V2 trace context across plugin restarts.
  • Enable with LANGFUSE_PROPAGATE_TRACE_CONTEXT=true (disabled by default).
  • Add integration tests and documentation.

Validation

  • 89 integration tests passed; build, typecheck, lint and formatting checks passed.
  • Successfully tested end-to-end with OpenCode V2, AgentGateway and Langfuse.

Related

Limitation: V2 transport hooks expose only the session ID, so propagation uses the current turn context rather than a specific generation. Langfuse metadata is not automatically propagated.

This branch has not been deployed

No deployments
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