Official agent skill

Migrating Langchain To Pydantic AI

by pydantic in pydantic/pydantic-ai

Migrate Python LangChain, LangGraph, or Deep Agents applications to Pydantic AI and, when the source uses harness features, Pydantic AI Harness.

OfficialMITAuto-check passedAI & LLM Engineering

Install Migrating Langchain To Pydantic AI

skills CLI
$ npx skills add pydantic/pydantic-ai --skill migrating-langchain-to-pydantic-ai -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install pydantic/pydantic-ai migrating-langchain-to-pydantic-ai --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/pydantic/pydantic-ai.git skills-src && mkdir -p .claude/skills && cp -r skills-src/pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-langchain-to-pydantic-ai .claude/skills/migrating-langchain-to-pydantic-ai && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
migrating-langchain-to-pydantic-ai
GitHub stars
21k
Token cost
~2.5k tokens
SKILL.md length
1,293 words
Files
8 (incl. references)
Skills in repo
20
Repo updated
First seen
Licence
MIT

At a glance

Migrate Python LangChain, LangGraph, or Deep Agents applications to Pydantic AI and, when the source uses harness features, Pydantic AI Harness.

  • Works in 6 steps: Read repository instructions, dependency… → Trace one representative request through… → Run the cheapest useful baseline. When… → …
  • LangChain agents
  • SKILL.md covers Work from the running…, Explain semantic differences, Match rigor to risk and Pydantic AI defaults, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Migrating Langchain To Pydantic AI is an agent skill from pydantic/pydantic-ai, published by the product's own GitHub organization. Migrate Python LangChain, LangGraph, or Deep Agents applications to Pydantic AI and, when the source uses harness features, Pydantic AI Harness. Use for LangChain agents, chains, LCEL, direct LangGraph graphs, persistence, interrupts, streaming, and createdeepagent projects with planning, filesystem or sandbox backends, skills, memory, subagents, permissions, approvals, or Deep Agents Code hosts.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 9 other files, including reference files (for example `agents/openai.yaml`, `references/CONCEPT-MAPPING.md` and `references/DEEP-AGENTS-MAPPING.md`).

It sits in AI & LLM Engineering, covering Building AI agents. It works with Pydantic AI, LangChain, LangGraph and Python. The repository describes itself as: How Python does AI. Agents, realtime voice, image generation, embeddings. Every model, every interface, typed end to end. The licence is MIT.

When your agent uses it

  • LangChain agents
  • Direct LangGraph graphs
  • Createdeepagent projects with planning
  • Sandbox backends

Example prompts

  • “/migrating-langchain-to-pydantic-ai”

Requirements

  • Python 3

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Read repository instructions, dependency files, tests, and the actual runtime entrypoints. Identify the installed LangChain, LangGraph…
  2. Trace one representative request through prompts, retrieval, model and tool calls, state, persistence, interrupts, emitted events…
  3. Run the cheapest useful baseline. When the migration surface is broad or unclear, search dependency files and source for langchain…
  4. Classify the slice before choosing a target
  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…

What it can do on your machine

Read from SKILL.md and the folder at commit 69ea1e5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Migrating Langchain To Pydantic AI loads about 2.5k tokens when it runs, and up to ~29k if it reads all its reference files. Until then it costs about 110 tokens; SKILL.md has 1,293 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~110
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~29k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from pydantic/pydantic-ai at commit 69ea1e5, republished under its MIT licence (© pydantic). 1,293 words, ~2,527 tokens.

Download SKILL.mdSave it as .claude/skills/migrating-langchain-to-pydantic-ai/SKILL.md (or your agent's skills folder). This skill also uses 7 other files; get the full folder from GitHub.
name
migrating-langchain-to-pydantic-ai
description
Migrate Python LangChain, LangGraph, or Deep Agents applications to Pydantic AI and, when the source uses harness features, Pydantic AI Harness. Use for LangChain agents, chains, LCEL, direct LangGraph graphs, persistence, interrupts, streaming, and `create_deep_agent` projects with planning, filesystem or sandbox backends, skills, memory, subagents, permissions, approvals, or Deep Agents Code hosts.

Migrate LangChain, LangGraph, and Deep Agents to Pydantic AI

Preserve behavior, not framework shape. Migrate the smallest behaviorally complete slice and leave application infrastructure outside that slice unchanged. LangChain, LangGraph, and Deep Agents are one source ecosystem; Pydantic AI, pydantic_graph, and Pydantic AI Harness are the matching target ecosystem, and this skill maps across all of it.

Work from the running application

  1. Read repository instructions, dependency files, tests, and the actual runtime entrypoints. Identify the installed LangChain, LangGraph, Deep Agents, Pydantic AI, and Harness 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. Resolve where create_deep_agent comes from: the upstream package and a vendored copy that reproduces its contracts both count as Deep Agents.
  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.
    • Deep Agents harness: create_deep_agent bundles file tools, shell execution, subagent delegation, summarization, skills, memory, permissions, prompt caching, and approval middleware on top of the LangChain agent loop, and a harness profile can add or hide more. Migrate the loop with the LangChain mappings, then map each bundled feature the slice actually uses to a Harness capability, a core primitive, or an application service with Deep Agents Mapping. Inventory implicit defaults the application code never mentions.
    • 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 Concept Mapping for the detected source features. Read Deep Agents Mapping whenever deepagents is in the slice. Read Semantic Gaps only for state, middleware, retries, approval, concurrency, streaming, or other behavior where similar-looking APIs may differ. Use Workaround Recipes after a concrete gap is identified, not as a mandatory checklist. Read Logfire Verification when adding observability, comparing source and target runs, or debugging a semantic difference. Read Verification and Cutover before a production cutover.

Explain semantic differences

When an observed source contract has no direct equivalent, explain it to the user before making a consequential design choice. State the source behavior, how the proposed Pydantic AI design differs, the user-visible or operational impact, and the available choices. Recommend one option and name its residual risk. Keep this proportional: do not turn ordinary import or naming changes into semantic warnings.

Do not stop at "unsupported." When nothing maps directly, recommend an existing core or Harness composition, a narrow adapter or application service, a new capability built from public primitives, or a core change, in that order of preference. Ask before choosing only when the options materially change behavior, architecture, public API, or scope.

Match rigor to risk

  • For a stateless chain or ordinary agent port, focused characterization tests and a short residual-risk note are enough. Do not require a semantic-gap register or durability exercise for behavior the source does not have.
  • For middleware, structured output transport, retrieval, tool retries, or streaming, probe the affected contract against the installed versions.
  • For checkpointed graphs, interrupts, approvals, durable execution, concurrent fan-out, or external side effects, create a migration ledger. Separate dependencies, messages, workflow state, checkpoint state, and long-term memory. Fit those owners into the repository's existing backend-selection and service interfaces where possible. Test restart, replay, correlation, authorization, and idempotency only to the extent the source promises them.
  • A deepagents dependency alone changes nothing. When the active slice calls create_deep_agent or depends on its planning, filesystem, sandbox, skills, memory, subagent, permission, or deployment contracts, those are in-scope features with Harness or application owners, not a reason to stop. Files, sandboxes, permissions, subagents, and background work carry the same ledger and restart obligations as checkpointed graphs.
Show full SKILL.md (492 more words)Show less

Pydantic AI defaults

  • Put authenticated identity, service clients, and configuration in typed dependencies, never model-chosen tool arguments.
  • Strengthen observed unstable seams, not the whole application: parameterize the agent's dependency and output types, and validate terminal choices, persisted workflow records, and framework adapters. Preserve stable public wire shapes and do not invent types for paths outside the migrated slice.
  • Preserve public request, response, error, and event shapes with a small adapter while callers migrate.
  • Keep retrieval, storage, provider, and transport integrations in place when they are outside the requested slice. Transitional LangChain integrations are acceptable when named and bounded.
  • Use Pydantic models for terminal structured output when that preserves the contract; retain an existing parser when changing the wire contract would expand the migration.
  • Do not force an Agent onto deterministic LCEL or pydantic_graph onto every StateGraph.
  • Inspect the installed Pydantic AI API before choosing model classes, provider transports, hooks, streaming methods, or durable integrations.
  • Add pydantic-ai-harness only for observed harness behavior: planning, workspace files, shell or sandboxed execution, Agent Skills, memory notebooks, repository context, model-directed subagents, model-agnostic compaction, tool-output limits, guardrails, spend limits, or step persistence. Add capabilities one at a time, import each from its owning public submodule, treat pydantic_ai_harness.experimental.* as version-sensitive, and run an import-and-construction smoke test in the target environment. Harness composes onto the core agent loop; it is not a second runtime and does not replace application infrastructure.
  • When adding Pydantic AI, prefer a currently supported stable release. Use the newest compatible release unless that would expand the migration through an unrelated major/runtime upgrade; explain and pin any exception. Resolve the whole project from a clean environment and run an import probe because an existing environment can hide incompatible transitive versions. Prefer pydantic-ai-slim with only the required provider and integration extras when the dependency surface is bounded, and use the full distribution when its broader integrations are actually needed. Do not pin an older release merely to match a remembered example.
  • If the source already uses LangSmith, Langfuse, or another observability system, do not replace it silently. Explain that Logfire is the first-party Pydantic AI integration and normally provides the most direct agent, model, tool, retry, error, usage, and timing experience. Contrast that with the continuity of retaining the current system, including its dashboards, alerts, evaluations, retention, and export pipeline; recommend a choice and obtain agreement before switching. Offer Logfire at application startup when no tracing system exists or the user chooses it, make content capture an explicit privacy decision, and keep executable contract tests as the authority for parity.

Completion

The slice is complete when every observed contract is either preserved by an executable check, intentionally changed by an accepted decision, or explicitly not applicable. An untested contract is unverified, not equivalent; an unresolved requested contract is unfinished work, not completion evidence. Constrain the slice or ask the user to accept the deferral. Remove LangChain, LangGraph, or Deep Agents dependencies only after no retained path needs them.

© pydantic, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 7 other files (references) in pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-langchain-to-pydantic-ai of pydantic/pydantic-ai.

  • SKILL.md
  • agents/openai.yaml
  • references/CONCEPT-MAPPING.md
  • references/DEEP-AGENTS-MAPPING.md
  • references/LOGFIRE-VERIFICATION.md
  • references/SEMANTIC-GAPS.md
  • references/VERIFICATION-AND-CUTOVER.md
  • references/WORKAROUND-RECIPES.md

Open the folder on GitHubat commit 69ea1e5

Used in 1 other repository

We found 2 copies of this SKILL.md (exact, near-identical or edited) in other folders. This page covers the copy in pydantic/pydantic-ai, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Migrating Langchain To Pydantic AI next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Migrating Langchain To Pydantic AI compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Migrating Langchain To Pydantic AI this skillpydantic/pydantic-ai21k—~2.5kAutomated safety check: PassMIT
Failproof AI SDK IntegrationFailproofAI/failproofai5.3k—~6kAutomated safety check: PassCustom licence
Building Pydantic AI Agentsdocling-project/docling69k—~2.8kAutomated safety check: PassMIT
Add Example AgentGetBindu/Bindu10k—~1.1kAutomated safety check: NotesCustom licence
Omnigent Framework Detectionomnigent-ai/omnigent11k—~610Automated safety check: PassApache-2.0
LangGraph Decision Modelslangchain-ai/langchain-skills1.3k—~2.3kAutomated safety check: PassMIT

Similar skills

  • Failproof AI SDK Integration

    FailproofAI/failproofai

    Helps instrument a custom Python or TypeScript agent to record events for Failproof AI, verify what gets written, and run an evaluator worker that scores the runs.

    5.3k GitHub stars~6k tokensUpdated 4 days ago
    AI & LLM EngineeringAuto-check passed
  • Building Pydantic AI Agents

    docling-project/docling

    Patterns and tested examples for building agents with Pydantic AI: tools, capabilities, structured output, dependency injection, hooks, YAML specs, streaming and testing.

    69k GitHub stars~2.8k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Add Example Agent

    GetBindu/Bindu

    Add a new self-contained example agent under examples/. An agent skill from GetBindu/Bindu.

    10k GitHub stars~1.1k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Omnigent Framework Detection

    omnigent-ai/omnigent

    Scans Python agent code for framework imports and recommends the matching Omnigent executor type, or says when the framework is not natively supported yet.

    11k GitHub stars~610 tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • LangGraph Decision Models

    langchain-ai/langchain-skills

    Official

    Routes LangGraph agents with typed decision models that return probabilities, and finds LLM calls that only exist to produce a routing decision.

    1.3k GitHub stars~2.3k tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check passed
  • Tool Design

    agentailor/fullstack-langgraph-nextjs-agent

    Design and verify tools that AI agents can actually use — for any framework or language (MCP servers, LangChain/LangGraph, function-calling, raw JSON schema; TypeScript, Python, or otherwise).

    132 GitHub stars~3.2k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check passed

More from pydantic/pydantic-ai

All 20 skills in this repo
  • Pydantic AI Harness

    pydantic/pydantic-ai

    Official

    Adds optional capabilities to Pydantic AI agents from pydantic-ai-harness, led by Code Mode, which runs many tool calls as one sandboxed Python script.

    21k GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Building Pydantic AI Agents

    pydantic/pydantic-ai

    Official

    Build AI agents with Pydantic AI — tools, capabilities (including on-demand loading), workspaces, structured output, streaming, testing, and multi-agent patterns.

    21k GitHub stars~8.2k tokensUpdated today
    Auto-check passed
  • Complete Partial PR

    pydantic/pydantic-ai

    Official

    Evaluate and complete an issue or PR where the submitted patch fixes only a narrow symptom of the reported pain point.

    21k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Testing Skill

    pydantic/pydantic-ai

    Official

    Record, rewrite, and debug VCR cassettes for HTTP recordings.

    21k GitHub stars~839 tokensUpdated today
    Auto-check: notes
  • Migrating Agno To Pydantic AI

    pydantic/pydantic-ai

    Official

    Migrate Python Agno applications to Pydantic AI and, only when needed, Pydantic AI Harness.

    21k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Official

    Migrate Python applications from the Claude Agent SDK to Pydantic AI and, only when needed, Pydantic AI Harness.

    21k GitHub stars~1.6k tokensUpdated today
    Auto-check passed

Questions about Migrating Langchain To Pydantic AI

What does Migrating Langchain To Pydantic AI do?

Migrate Python LangChain, LangGraph, or Deep Agents applications to Pydantic AI and, when the source uses harness features, Pydantic AI Harness. Migrating Langchain To Pydantic AI is an agent skill from pydantic/pydantic-ai, published by the product's own GitHub organization. Migrate Python LangChain, LangGraph, or Deep Agents applications to Pydantic AI and, when the source uses harness features, Pydantic AI Harness.

When should I use Migrating Langchain To Pydantic AI?

Migrating Langchain To Pydantic AI fits situations like: langChain agents; direct LangGraph graphs; createdeepagent projects with planning; sandbox backends.

How do I install Migrating Langchain To Pydantic AI in Claude Code?

Run `npx skills add pydantic/pydantic-ai --skill migrating-langchain-to-pydantic-ai -a claude-code`. Or copy the skill folder (pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-langchain-to-pydantic-ai in pydantic/pydantic-ai) into .claude/skills/migrating-langchain-to-pydantic-ai in your project. Claude Code loads it when a task matches its description.

How do I install Migrating Langchain To Pydantic AI in Codex?

Run `npx skills add pydantic/pydantic-ai --skill migrating-langchain-to-pydantic-ai -a codex`. Or copy the skill folder (pydantic_ai_slim/pydantic_ai/.agents/skills/migrating-langchain-to-pydantic-ai in pydantic/pydantic-ai) into .agents/skills/migrating-langchain-to-pydantic-ai in your project. Codex loads it when a task matches its description.

Can I use Migrating Langchain To Pydantic AI in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add pydantic/pydantic-ai --skill migrating-langchain-to-pydantic-ai -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/migrating-langchain-to-pydantic-ai, .gemini/skills/migrating-langchain-to-pydantic-ai, .github/skills/migrating-langchain-to-pydantic-ai and .opencode/skills/migrating-langchain-to-pydantic-ai in your project.

What does Migrating Langchain To Pydantic AI need to run?

SKILL.md names no scripts, command-line tools or credentials: Migrating Langchain To Pydantic AI is instructions for the agent only. Our summary lists: Python 3.

Does Migrating Langchain To Pydantic AI access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Migrating Langchain To Pydantic AI safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Migrating Langchain To Pydantic AI use?

Migrating Langchain To Pydantic AI is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Migrating Langchain To Pydantic AI use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 26k tokens, read only when the agent opens those files.

What are the alternatives to Migrating Langchain To Pydantic AI?

Skills that share tags, products or a category with Migrating Langchain To Pydantic AI: Failproof AI SDK Integration (FailproofAI/failproofai, 5.3k stars), Building Pydantic AI Agents (docling-project/docling, 69k stars), Add Example Agent (GetBindu/Bindu, 10k stars) and Omnigent Framework Detection (omnigent-ai/omnigent, 11k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Migrating Langchain To Pydantic AI?

pydantic (a GitHub organization, an official publisher) maintains it in pydantic/pydantic-ai, which has 20,537 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on October 11, 2026.

Source: pydantic/pydantic-ai on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.