Skip to main content
When you call a deployed Agent Server from another service, you can propagate trace context so that the entire request appears as a single unified trace in LangSmith. This uses LangSmith’s distributed tracing capabilities, which propagate context via HTTP headers.

How it works

Distributed tracing links runs across services using context propagation headers:
  1. The client infers the trace context from the current run and sends it as HTTP headers.
  2. The server reads the headers and adds them to the run’s config and metadata as langsmith-trace and langsmith-project configurable values. You can choose to use these to set the tracing context for a given run when your agent is used.
The headers used are:
  • langsmith-trace: Contains the trace’s dotted order.
  • baggage: Specifies the LangSmith project and other optional tags and metadata.
To opt-in to distributed tracing, both client and server need to opt in.

Configure the server

To accept distributed trace context, your graph must read the trace headers from the config and set the tracing context. The headers are passed through the configurable field as langsmith-trace and langsmith-project.
Distributed-tracing headers (langsmith-trace, baggage) are consumed as trusted tracing context. Only configure your server to apply inbound trace context for deployments called by trusted, internal services. If your Agent Server receives requests directly from untrusted third parties or the public internet, do not propagate these headers into the tracing context: strip them at your gateway or proxy instead. Trusting baggage from an external caller lets them influence how your runs are recorded.
Export this graph function in your langgraph.json:

Connect from the client

Set distributed_tracing=True when initializing RemoteGraph. This automatically propagates trace headers on all requests.