groundy
Agents & Frameworks

Can You Keep LangSmith Traces When Moving to Pydantic AI?

Keeping LangGraph preserves LangSmith traces when swapping to Pydantic AI, but detailed agent internals require OpenTelemetry and separate evaluation checks.

Published 6 references
A translucent green dinosaur with blocky scales and a skeptical eye stands inside a scuffed black oval. A metal cuff clips one foreleg to the oval, and a separate yellow impression of its curved tail lies on the ivory surface beside it.
On this page12 sections

Yes, if you keep LangGraph as the orchestration layer. LangSmith’s LangGraph tracing guide explicitly covers agents built with LangChain modules or other SDKs, so replacing LangChain components with Pydantic AI does not, by itself, cut off new graph-level traces.

The zero-code experience does change. LangChain modules need only tracing configuration, while other SDKs and custom functions inside LangGraph must be wrapped or decorated. Pydantic AI also has its own instrumentation: it emits OpenTelemetry traces for agent runs, model requests and tool calls, viewable through Logfire or another OpenTelemetry backend. The practical answer is therefore a qualified yes: keep the LangGraph trace, explicitly wire Pydantic AI calls into LangSmith, and expect the most detailed agent internals to remain in OpenTelemetry unless you establish another ingestion path.

That answer concerns continued trace collection. LangSmith’s tracing guides do not address whether existing trace history, datasets, dashboards and evaluation results will remain usable or comparable after the swap. That is a separate migration gate, not a detail to assume away.

Trace continuity is a layer-by-layer question

A framework name is a poor unit for planning this migration. A single agent execution can produce an orchestration record, an agent-run record, model-request and tool-call detail, and material later used for evaluation. Those layers can take different paths after the agent SDK changes.

LayerLangChain modules inside LangGraphPydantic AI inside LangGraphPydantic AI’s native instrumentation
Orchestration graphLangSmith tracing is enabled through environment variablesLangSmith documents LangGraph tracing with other SDKs as well as LangChain modulesPydantic AI’s instrumentation pages make no LangGraph orchestration-tracing claim
Agent loopOrdinary LangChain code traces without additional codeEnvironment variables alone are not documented as sufficient. Wrap calls with @traceable in Python or traceable in JS so wrapped methods can nest in LangSmithOpenTelemetry traces for every run
Model requests and tool callsCovered by the LangChain tracing baseline, though no guide defines span-for-span equivalenceLangSmith does not document automatic capture of Pydantic AI’s internal spansOpenTelemetry traces for every model request and tool call
Datasets, evaluation history and comparabilityOut of scope for the tracing guidesNeither documentation set covers continuity or comparability after the component swapThe instrumentation pages do not address evaluation history

The first three rows combine LangChain’s LangGraph and LangChain tracing documentation with Pydantic AI’s Logfire documentation. The evaluation row is deliberately empty of assurances: no LangSmith tracing guide or Pydantic AI instrumentation page addresses that part of the migration.

There is also an important distinction between nesting and fidelity. LangSmith says it will automatically nest traces from appropriately wrapped methods. That supports a parent-child trace structure. It does not prove that a wrapped Pydantic AI call will reproduce every internal model and tool span that Pydantic AI emits through OpenTelemetry.

The LangGraph boundary is what preserves the outer trace

The architectural premise is sound. LangGraph is a low-level orchestration framework and runtime for long-running, stateful agents, and its overview states: “Docs examples often use LangChain for those integrations, but LangGraph does not require LangChain.”

That makes it possible to change the implementation inside an agent node without replacing the orchestration runtime. LangSmith then documents tracing for LangGraph applications in both Python and JavaScript, whether they use LangChain modules or other SDKs.

This is the strongest continuity guarantee in LangSmith’s documentation. It is still a general LangGraph guarantee, not a demonstration of Pydantic AI running inside a LangGraph node. The reasonable inference is that Pydantic AI falls into the documentation’s “other SDKs” category. The unsupported leap would be to assume that every Pydantic AI operation therefore receives the same automatic LangSmith treatment as a LangChain module.

If your migration also removes LangGraph, this continuity argument no longer applies. What LangSmith documents is tracing for a LangGraph application, which supports keeping LangGraph while replacing agent-layer components, not moving the entire application and expecting the same traces.

What replaces the zero-code LangChain path

With ordinary LangChain code, LangSmith’s LangChain tracing guide says no extra code is required to log traces. It also documents more selective controls: Python users can pass a LangChainTracer instance as a callback for specific invocations or use the tracing_context context manager. LangChain objects invoked inside a traceable function are traced as child runs, which supports mixed LangChain and LangSmith SDK agents.

For other SDKs inside LangGraph, the documented rule is different. Use @traceable in Python, traceable in JavaScript, or an appropriate SDK wrapper such as wrap_openai. Once those methods are wrapped, LangSmith says their traces are automatically nested.

Three consequences follow:

  1. Do not inventory only your LangGraph nodes. Inventory the Pydantic AI calls and custom functions inside them. Those are the places where the generic wrapping rule becomes work.
  2. Do not treat wrap_openai as a Pydantic AI integration. It is LangSmith’s example of an SDK-specific wrapper. Neither LangSmith’s guide nor Pydantic AI’s documentation says that wrapping an underlying OpenAI call captures Pydantic AI’s complete agent loop.
  3. Do not assume your old callbacks transfer. The LangChainTracer and tracing_context behavior is documented for LangChain. Neither Pydantic AI nor LangSmith documents a first-party callback bridge between them.

A wrapped call should be treated as a visible boundary whose contents still need inspection. Check whether the resulting LangSmith run contains the inputs, outputs and intermediate operations your dashboards and reviewers currently use. The documentation establishes nesting, not equivalence with the old LangChain trace.

Pydantic AI’s detailed record follows OpenTelemetry

Pydantic AI approaches the problem from the other direction. Its Logfire integration documentation says it emits OpenTelemetry traces of every run, model request and tool call. Logfire is built in but optional: detailed agent-run information is sent only when the logfire package is installed and configured and agent instrumentation is enabled.

The destination is not restricted to Logfire. Pydantic AI’s overview describes its instrumentation as plain OpenTelemetry and says any backend a team already runs works. That gives the agent layer a portable observability path independent of LangSmith.

It also creates a plausible two-system arrangement after migration:

  • LangSmith holds the LangGraph orchestration trace and whatever wrapped calls contribute.
  • Logfire or another OpenTelemetry backend holds Pydantic AI’s run, model-request and tool-call detail.

This is not necessarily a reason to reject Pydantic AI. A team already operating an OpenTelemetry backend may find that arrangement consistent with the rest of its observability stack. But it is additional operational surface: two instrumentation configurations, potentially two places to investigate an execution, and no documented tie between the records. Neither LangSmith nor Pydantic AI describes shared identifiers or a single combined timeline.

If your requirement is a single LangSmith view containing the full Pydantic AI agent loop, no documented path satisfies it.

LangSmith’s own positioning does not close that gap. Its observability page says LangSmith works with any LLM framework and that OpenTelemetry support connects to existing pipelines. It names OpenAI SDK, Anthropic SDK, Vercel AI SDK, LlamaIndex and custom implementations. Pydantic AI is not named, and the page does not specify that Pydantic AI’s OpenTelemetry spans can be ingested into LangSmith with their structure intact. Treat that as a path to test, not a documented integration.

JavaScript parity has a version condition

The wrapping names differ by language, and mixed JavaScript applications have an additional compatibility check. LangChain’s tracing guide says that starting with langchain@0.2.x, LangChain objects used inside @traceable functions are traced automatically and inherit the client, tags, metadata and tracing destination. Below 0.2.x, a LangChainTracer must be passed manually from the tracing context.

That threshold concerns LangChain objects remaining inside a mixed application. It is not evidence that Pydantic AI receives equivalent automatic treatment in JavaScript or TypeScript. During migration, check the LangChain version for the nodes you retain and apply the separate traceable wrapping rule to other SDK calls. Combining those two requirements in the checklist avoids mistaking a successful LangChain child trace for proof of Pydantic AI coverage.

A completed request does not prove its trace arrived

LangSmith documents a delivery failure mode that matters during acceptance testing. In LangChain Python, tracing runs in a background thread to avoid obstructing the production agent. The documentation warns that “your process may end before all traces are successfully posted to LangSmith.” It identifies serverless environments as particularly exposed because the virtual machine may be terminated immediately after the chain or agent completes.

This can produce a misleading migration test: the application returns the expected answer, but the trace needed for comparison is absent. Test under the deployment’s actual shutdown behavior, especially serverless termination, and confirm arrival in LangSmith rather than judging instrumentation solely from application logs.

The warning is documented for LangChain Python. It should not be generalized into a measured claim about Pydantic AI’s OpenTelemetry delivery, which neither vendor’s documentation examines.

A migration checklist for traces and evaluations

Use the checklist as an acceptance procedure, not as a list of behaviors the vendors have already guaranteed.

  1. Define what “keep” means. Separate continued collection of new traces from retention of historical traces, continued use of dashboards, access to datasets, and comparability of evaluation scores. Each requires its own check.

  2. Record the current baseline. Inventory LangSmith destinations, trace metadata used by dashboards, datasets, evaluator definitions and the trace fields reviewers rely on. Preserve representative pre-migration runs for comparison.

  3. Keep LangGraph in the first migration stage. Confirm that new runs still reach LangSmith after LangChain components are replaced. This isolates the agent-SDK change instead of changing orchestration and instrumentation simultaneously.

  4. Wrap every relevant non-LangChain call. Apply @traceable, traceable, or an appropriate SDK wrapper according to the LangGraph documentation. Inspect the resulting hierarchy and record which internal operations are present or absent. Do not mark this step complete merely because a parent run appears.

  5. Enable Pydantic AI’s native instrumentation where detail is required. Configure Logfire or your existing OpenTelemetry backend and verify run, model-request and tool-call records there. If the goal is to send those spans to LangSmith instead, require a successful ingestion and field-mapping test before designing around that route.

  6. Test the delivery environment. Exercise process exit and serverless termination, then check that expected traces arrived. Include JavaScript version checks where LangChain objects remain inside traceable functions.

  7. Gate evaluation migration separately. Confirm that existing datasets remain accessible, evaluator definitions still run, and the fields required for grading and dashboards still exist. Run representative old and new configurations against the same inputs before comparing scores. Until those checks pass, treat differences as potentially caused by changed trace structure or evaluation conditions rather than agent quality.

When I would approve the swap

I would proceed when LangGraph remains in place and the team accepts either of two verified outcomes: wrapper-level Pydantic AI visibility in LangSmith plus detailed OpenTelemetry records elsewhere, or a separately demonstrated single-backend path that preserves the required detail. I would not approve a plan based only on LangSmith’s framework-agnostic marketing or on the assumption that existing evaluations will remain comparable.

LangSmith’s documentation supports continuity of LangGraph trace collection, not artifact equivalence. Every behavioral claim above comes from vendor documentation and marketing pages, and neither tracing guide pins versions for the behaviors it describes beyond the langchain@0.2.x JavaScript threshold quoted earlier. No documentation surveyed here demonstrates Pydantic AI running inside LangGraph, a first-party Pydantic AI-to-LangSmith integration, ingestion of Pydantic AI spans into LangSmith, or evaluation-history continuity. A small acceptance test on the exact versions slated for production is therefore part of the migration decision, not optional cleanup afterward.

Frequently Asked Questions

How do I trace Pydantic AI calls inside LangGraph?

For other SDKs inside LangGraph, the documented rule is different. Use @traceable in Python, traceable in JavaScript, or an appropriate SDK wrapper such as wrap_openai. Once those methods are wrapped, LangSmith says their traces are automatically nested.

Where does Pydantic AI send its detailed traces?

Its Logfire integration documentation says it emits OpenTelemetry traces of every run, model request and tool call. Logfire is built in but optional: detailed agent-run information is sent only when the logfire package is installed and configured and agent instrumentation is enabled.

What is the risk of traces not arriving in LangSmith?

The documentation warns that “your process may end before all traces are successfully posted to LangSmith.” It identifies serverless environments as particularly exposed because the virtual machine may be terminated immediately after the chain or agent completes.

References

Follow the links in the article for context. The supporting material is collected here for further reading.

  1. LangSmith’s LangGraph tracing guidedocs.langchain.comAccessed
  2. Pydantic AI’s Logfire documentationpydantic.devAccessed
  3. LangGraph overviewdocs.langchain.comAccessed
  4. LangSmith’s LangChain tracing guidedocs.langchain.comAccessed
  5. Pydantic AI’s overviewpydantic.devAccessed
  6. LangSmith observability pagelangchain.comAccessed

Join the discussion

Share a useful perspective or ask a question about this article.

Discussion guidelinesComments privacy