migrating-langchain-to-pydantic-ai

migrating-langchain-to-pydantic-ai is a skill for Codex from pydantic/pydantic-ai. It costs 69 tokens per session (1,504 once invoked), scanned A, original, MIT.

A guide for moving Python applications from LangChain or LangGraph to Pydantic AI, three frameworks for building software that calls language models and tools. It focuses on preserving the application's actual behavior and public interfaces during the move.

In plain words
What is it for?
Use it to migrate agents, chains, graphs, retrieval, model and tool calls, persistence, streaming, or related runtime behavior from LangChain or LangGraph to Pydantic AI.
Why use it?
It prevents a migration from breaking callers, streaming, saved state, interrupts, callbacks, or persistence that the application already relies on. It also helps define the smallest complete part of the application to migrate.

Skill for Codex

Written for Codex: agents/openai.yaml present. Also seen: mentions subagents; installed under .agents/ (shared by several agents).

Good fit Use it to migrate agents, chains, graphs, retrieval, model and tool calls, persistence, streaming, or related runtime behavior from LangChain or LangGraph to Pydantic AI.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pydantic/pydantic-ai/migrating-langchain-to-pydantic-ai
About the project

Pydantic AI is a typed Python SDK for building AI agents that can use different language models and interfaces, including voice, image generation, and embeddings. Developers use it for applications ranging from structured data extraction to long-running multi-agent work. The catalogue entries provide workflows and configuration for its coding-agent and harness features.

pydantic/pydantic-ai · 19,869 stars · on GitHub · pydantic.dev

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add pydantic/pydantic-ai --skill migrating-langchain-to-pydantic-ai
Clone the repo
git clone --depth 1 https://github.com/pydantic/pydantic-ai

Made for: Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for migrating-langchain-to-pydantic-ai

README.md
[![agentmods](https://agentmods.dev/badge/skills/pydantic/pydantic-ai/migrating-langchain-to-pydantic-ai/github.svg)](https://agentmods.dev/skills/pydantic/pydantic-ai/migrating-langchain-to-pydantic-ai)
Your own site
<a href="https://agentmods.dev/skills/pydantic/pydantic-ai/migrating-langchain-to-pydantic-ai"><img src="https://agentmods.dev/badge/skills/pydantic/pydantic-ai/migrating-langchain-to-pydantic-ai/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for migrating-langchain-to-pydantic-ai

Your own site · 80×15
<a href="https://agentmods.dev/skills/pydantic/pydantic-ai/migrating-langchain-to-pydantic-ai"><img src="https://agentmods.dev/badge/skills/pydantic/pydantic-ai/migrating-langchain-to-pydantic-ai.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 69 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,504 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00069 $0.01504
Opus 5 $0.00034 $0.00752
Sonnet 5 $0.00014 $0.00301
Haiku 4.5 $0.00007 $0.00150

Measured 13d ago against content hash 637f86253272, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

migrating-langchain-to-pydantic-ai scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 13d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-langchain-to-pydantic-ai/SKILL.md · 51 lines

How it starts

The opening of the file, as written. The whole thing — 51 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Migrate LangChain and LangGraph to Pydantic AI

Preserve behavior, not framework shape. Migrate the smallest behaviorally complete slice and leave application infrastructure outside that slice unchanged.

Work from the running application

  1. Read repository instructions, dependency files, tests, and the actual runtime entrypoints. Identify the installed LangChain, LangGraph, and Pydantic AI versions.
  2. Trace one representative request through prompts, retrieval, model and tool calls, state, persistence, interrupts, emitted events, tracing/metrics callbacks, and the public result. Inspect every caller and sibling endpoint that consumes the migrated component; a narrow implementation slice can still have several public contracts. Include keyword parameter names and the sync, async, callback, and streaming forms callers actually use. Record only contracts those paths actually use.
  3. Run the cheapest useful baseline. When the migration surface is broad or unclear, search dependency files and source for langchain, langgraph, langsmith, and deepagents, then confirm findings against imports, factories, and call sites.
  4. Classify the slice before choosing a target:
    • Chain or LCEL pipeline: keep deterministic retrieval and transformation in plain Python; use a Pydantic AI agent only where a model/tool loop adds value.
    • LangChain agent: normally use one reusable pydantic_ai.Agent with typed dependencies, tools, and outputs.
    • Direct LangGraph workflow: use plain async Python for simple fixed control flow, or pydantic_graph when explicit typed nodes and branching remain useful. Treat persistence as a separate design decision.
    • Product runtime: retain queues, configured database backends, sandboxes, auth, schedulers, webhooks, tracing, and transport adapters unless the user placed them in scope. Extend an existing application seam before creating a parallel persistence or provider subsystem.
  5. Add or preserve deterministic characterization tests, then migrate one vertical slice behind the existing public boundary.
  6. Run the original tests and focused parity tests. Classify each observed contract by its evidence; never describe the migration as one-to-one merely because the happy path or trace shape looks similar.

Read the full file on GitHub · 51 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 13d ago First seen · 51 lines · 69 tokens per session scan A 637f86253272

Subscribe to this mod's changes

migrating-langchain-to-pydantic-ai is a skill published in the GitHub repository pydantic/pydantic-ai (19,869 stars, last pushed today), licensed MIT. It adds 69 tokens to every session and 1,504 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.