Migrating Google Adk To Pydantic AI
PydanticOfficialPublished by Pydantic
- Skill
- Workflow
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured methodology for migrating existing Google Agent Development Kit (ADK) applications to Pydantic AI. It emphasizes preserving caller-visible behavior by tracing request paths, separating infrastructure from agent logic, and mapping ADK concepts like sessions, state, and workflows to Pydantic AI primitives. The guide focuses on high-risk areas such as durable execution, callback ordering, and multi-agent delegation to ensure a reliable transition without losing critical application state or side-effect management.
What it does
- Provides a step-by-step migration path from Google ADK to Pydantic AI.
- Maps ADK concepts like LlmAgent, sessions, and workflows to Pydantic AI equivalents.
- Outlines strategies for handling state, memory, and artifact persistence.
- Defines high-risk gates for tool confirmation, callback hooks, and durable execution.
- Offers guidance on multi-agent delegation and sub-agent patterns.
- Includes verification steps to ensure parity through deterministic testing.
When to use it
- When you need to migrate an existing Google ADK application to Pydantic AI.
- When you need to ensure that agent behavior, state management, and tool execution remain consistent during a framework transition.
- When you are unsure how to map complex ADK features like graph workflows or session events to Pydantic AI.
- When you need to verify that your migrated agent maintains the same caller contracts as the original ADK implementation.
Advantages
- Reduces migration risk by focusing on small, verifiable vertical slices.
- Prevents common pitfalls related to state persistence and event ordering.
- Provides clear mapping references for complex ADK features.
- Ensures that application-level infrastructure remains intact during the transition.
Usage examples
- “How do I map an ADK LlmAgent with tools to Pydantic AI?”
- The agent provides a mapping strategy using core Agent objects with typed dependencies and tools, ensuring tool names, schemas, and validation logic are preserved.
- “What is the recommended approach for migrating ADK session state?”
- The agent advises separating model context (message history) from application-owned state stores, ensuring tenant isolation and proper persistence for workflow data.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/pydantic/migrating-google-adk-to-pydantic-ai/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip migrating-google-adk-to-pydantic-ai.zip -d .agents/skills
Documentation by Pydantic
Migrate Google ADK to Pydantic AI
Preserve caller-visible behavior, not ADK's class tree. Migrate the smallest complete request path and leave product infrastructure in the application.
Work from the running application
Read repository instructions, dependencies, tests, and runtime entrypoints. Record the installed Google ADK, Pydantic AI, and optional
pydantic-ai-harnessversions.Trace one real request from
Runner.run_async()or the deployed endpoint through the root agent, instructions, collaboration mode, model calls, tools, workflow nodes, callbacks/plugins, session service, emitted events, state/artifact deltas, and final response. Record only behavior that path uses.Separate the contracts before choosing targets:
Session.eventsused as model context;session-, user-, app-, and invocation-scoped state;
searchable long-term memory;
workflow/node checkpoints and resume IDs;
versioned artifacts and external side effects.
Classify the active slice:
Ordinary
LlmAgent: normally one reusableAgentwith typed dependencies, tools, and output.ADK graph or dynamic workflow: keep simple deterministic control flow in plain async Python; use
pydantic_graphwhen explicit typed nodes, branching, or graph inspection remain valuable.Multi-agent delegation: inspect ADK's collaboration
modein Python 2.x; 1.xsub_agentsusechatbehavior. Use core multi-agent patterns forchattransfer semantics. HarnessSubAgentscan fittaskorsingle_turnonly when their isolated context, return, interaction, and concurrency behavior match.Product runtime: retain auth, session/state stores, artifact stores, queues, transport, A2A endpoints, evaluation, observability, and deployment unless they are explicitly in scope.
Add deterministic characterization tests, then migrate one vertical slice behind its existing caller boundary.
Run the original tests and focused parity tests. Mark unexercised behavior
unverified; similar names are not equivalence evidence.
Read Concept Mapping for the features the slice uses. Read Semantic Gaps for workflows, state, resume, confirmation, callbacks/plugins, event streams, skills, or execution environments. Read Verification and Cutover before removing ADK or changing production traffic.
High-risk gates
Do not pass ADK
Sessionobjects or mutable state dictionaries through model-chosen tool arguments. Put authenticated identity and service clients in typed dependencies; persist product and workflow state through application-owned stores.message_historycontinues model context. It does not replace ADK session state, memory, artifacts, event records, node checkpoints, or invocation resume.ADK resumability replays recorded node/tool results and can execute tools more than once. Choose a durable execution design explicitly and prove restart plus idempotency for side effects.
Keep conversational input, approval, and authorization distinct. Map tool confirmation to deferred tool approval; keep identity and access checks in trusted application code.
Preserve callback/plugin ordering and short-circuit rules deliberately. Pydantic AI hooks have their own capability ordering and exception-based skip/recovery semantics; a list of lookalike hooks is not parity.
ADK partial events are delivered without applying state deltas; each non-partial event applies its delta when appended. Artifact writes happen during the artifact operation, before the current event records the returned version. If callers consume ADK event fields or final-event detection, retain a boundary adapter and test the exact stream and persistence order.
Use Harness only for an observed reusable capability. Ordinary agents need core only, and a command allowlist is not an OS security boundary.
Pydantic AI defaults
Map
instructiontoinstructions; use aRunContextinstructions function when it depends on trusted runtime data.Map function tools to typed Pydantic AI tools. Preserve tool names, descriptions, validation behavior, error shape, retries, confirmation, and concurrency only where callers rely on them.
Map
output_schematooutput_typewhen the terminal output contract is structured. Preserve an existing wire adapter if changing response shape would widen the migration.Persist
ModelMessagehistories separately from workflow and product state. Reuse the application's current stores before adding a new persistence subsystem.Use
Hooksfor local lifecycle interception or a custom capability for reusable policy that also owns tools, instructions, settings, or events.Keep the active model/provider unless changing it is requested. Use provider-prefixed Pydantic AI model IDs and verify provider-specific tools, settings, streaming, and realtime behavior against installed APIs.
Completion
The slice is complete only when every observed caller contract is preserved by executable evidence, explicitly accepted as changed, or not applicable. Treat unverified and blocked contracts as unfinished. Do not remove google-adk while a retained runtime, session migration, deployment command, evaluation, or compatibility path still imports or invokes it.
Files
- ATTRIBUTION.mdAdded by AutoGineer887 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md6.1 KiB
- agents/openai.yaml317 B
- references/CONCEPT-MAPPING.md6.5 KiB
- references/SEMANTIC-GAPS.md7.0 KiB
- references/VERIFICATION-AND-CUTOVER.md3.5 KiB
references/CONCEPT-MAPPING.md
Concept Mapping
Map behavior only after tracing the active ADK caller path. Keep existing application infrastructure unless the migration explicitly includes it.
| Google ADK source | Normal Pydantic AI target | Focused proof |
|---|---|---|
LlmAgent(model, instruction, tools) | Core Agent(model, instructions, tools) | Prompt, tool calls, final output, and errors |
Dynamic instruction / deprecated global_instruction / GlobalInstructionPlugin | Instructions functions using typed RunContext dependencies; attach tree-wide instructions to every migrated agent or one shared capability | Trusted values reach prompts but not tool schemas and apply to the same agents |
input_schema / output_schema | Existing input adapter plus output_type; typed graph/node data where applicable | Accepted/rejected payloads and wire shape |
FunctionTool / Python callable | @agent.tool, @agent.tool_plain, Tool, or FunctionToolset | Name, schema, validation, error, and side effect |
ToolContext / CallbackContext | RunContext plus typed dependencies; application services for persistence | Identity and clients are not model arguments |
Runner.run_async() / Event.is_final_response() | Agent.run(), run_stream_events(), or an application adapter | Sync/async form, IDs, event order, final response |
Session.events | Normalized ModelMessage history when it is model context | Multi-turn replay and persisted reload |
Session.state, including app:, user:, and temp: keys | Application/workflow state with explicit scope and lifetime | Cross-session isolation, invocation lifetime, concurrency |
MemoryService and load_memory | Existing retrieval service, or Harness Memory if its store/search policy matches | Ingestion, search ranking, tenant scope, deletion |
ArtifactService and artifact deltas | Existing versioned blob/file service | Version lookup, user/session scope, cleanup, errors |
output_key | Explicit Python/graph output flow or an application state write | Downstream value and persistence timing |
Workflow graph / node / Event.route | Plain async Python or pydantic_graph | Routes, typed inputs/outputs, fan-out/join, failures |
Dynamic ctx.run_node() | Plain async composition, pydantic_graph, and a durable backend only when required | Scheduling order, execution IDs, retries, restart |
SequentialAgent / ParallelAgent / LoopAgent | Plain Python, pydantic_graph, or explicit agent composition | Order, context isolation, stop condition, race/failure behavior |
sub_agents with mode='chat' | Core delegation/programmatic hand-off/model routing | Which agent sees which history and answers the user |
sub_agents with mode='task' or mode='single_turn' | A typed agent tool or Harness SubAgents only when isolation, return, interaction, and concurrency semantics match | Input visibility, return control, user interaction, parallelism, output |
AgentTool | A typed tool that runs another Agent; Harness SubAgents when the task is self-contained | Input prompt, usage propagation, history isolation, returned output |
before_* / after_* callbacks | Core Hooks | Order, mutation, short-circuit, errors, sync/async behavior |
Runner-wide BasePlugin | One reusable capability or application instrumentation/policy | Global coverage, lifecycle, early exit, cleanup |
require_confirmation, ToolConfirmation | requires_approval or ApprovalRequiredToolset to gate the tool; resolve inline with HandleDeferredToolCalls, or return DeferredToolRequests and resume a later run with DeferredToolResults; use ToolApproved.override_args and deferred metadata when the confirmation payload changes execution | Correlation, approve/deny, overridden arguments, metadata, no side effect before approval |
Workflow RequestInput | Application or graph pause/resume boundary | Prompt, response correlation, restart; do not imply authorization |
LongRunningFunctionTool | Deferred external execution, application jobs, or durable steps | Pending response, correlation, completion/error delivery |
McpToolset | Core MCP toolsets | Transport lifecycle, tool filtering/names, auth, errors |
SkillToolset | Harness Skills for portable SKILL.md instructions | Discovery, selection, instruction loading |
| ADK code executor / environment | Harness FileSystem and Shell, or ModalSandbox | Containment, credentials, timeout, persistence, output |
| Event and text streaming | run_stream_events() for lifecycle events; run_stream() for output streaming | Chunk boundaries, event types/order, completion, cancellation |
| Context compaction | Core/Harness compaction selected by the observed policy | Preserved pinned content and behavior near token limits |
| Resume/replay | Core durable integrations or Harness step persistence, chosen by required guarantees | Kill/restart and idempotent external effects |
| Realtime/live | Core realtime when modality/provider contracts match | Audio/text turns, interruption, tool calls, session closure |
| A2A, CLI/web/API server, deploy, evals | Keep the application/protocol boundary; migrate separately if requested | Existing consumer and operational tests |
Routing rules
Prefer core for the agent loop, normalized messages, typed dependencies, tools, output, hooks, streaming, MCP, approvals, and durable-runtime primitives.
Use Harness for optional reusable policy such as memory, skills, subagents, planning, workspace tools, context management, guardrails, or an isolated execution environment.
Keep auth, stores, queues, endpoints, deployment, and product state in the application.
Record a gap when the target cannot preserve a contract through a supported public API. Build a bounded adapter only after the impact is known.
Google ADK's current concepts are documented under agents, workflows, runtime, sessions, tools, callbacks, plugins, and skills. Check the installed source because experimental and workflow APIs move quickly.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs Node.js
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Pydantic
- Publisher
- Pydantic (Official)
- Source
- pydantic/skills · skills/migrating-google-adk-to-pydantic-ai · commit 98f591c
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- pydantic/skills
AutoGineer is not affiliated with or endorsed by Pydantic or Pydantic.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download migrating-google-adk-to-pydantic-ai.zip