Migrating Agno 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 Agno-based applications to Pydantic AI and Pydantic AI Harness. It emphasizes preserving observable behavior and application contracts rather than replicating Agno's internal object model. The process involves tracing existing agent paths, mapping features to Pydantic AI components, and implementing changes through verified vertical slices.
What it does
- Traces existing Agno agent, team, and workflow execution paths.
- Maps Agno features to Pydantic AI core, graph, and harness components.
- Provides a contract ledger for tracking migration parity.
- Guides the implementation of adapters for persistence, sessions, and hooks.
- Defines testing strategies for verifying agent behavior and side effects.
- Outlines cutover procedures for replacing Agno dependencies.
When to use it
- When migrating an existing Python application that imports agno.
- When transitioning Agno agents, teams, or workflows to Pydantic AI.
- When replacing Agno-specific memory, knowledge, or tool implementations.
- When refactoring AgentOS-based applications to use Pydantic AI infrastructure.
Advantages
- Focuses on maintaining application-level contracts and observable behavior.
- Encourages incremental migration through vertical slices.
- Provides a clear mapping between Agno concepts and Pydantic AI primitives.
- Includes rigorous verification steps for state, persistence, and human-in-the-loop flows.
Usage examples
- “How do I migrate my Agno Agent to Pydantic AI?”
- The agent will guide you through tracing your current Agent.run() calls, identifying the necessary Pydantic AI dependencies, and constructing a baseline test to ensure parity.
- “How should I handle Agno sessions during migration?”
- The agent will help you decide between one-time conversion, read-through adapters, or starting fresh, while ensuring your application store remains the owner of session state.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/pydantic/migrating-agno-to-pydantic-ai/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip migrating-agno-to-pydantic-ai.zip -d .agents/skills
Documentation by Pydantic
Migrate Agno to Pydantic AI
Preserve observable behavior, not Agno's object model. Migrate the smallest complete caller path and keep application infrastructure in place.
Trace the source before choosing a target
Read repository instructions, dependencies, tests, and the runtime entrypoint. Record the installed Agno, Pydantic AI, and Harness versions.
Trace one real request from
Agent.run()/arun(),Team.run()/arun(), aWorkflow, or an AgentOS endpoint through instructions, model and tool calls, hooks, session loading, memory or knowledge retrieval, events, results, state, and side effects. Establish a focused baseline or characterization test.Separate these source contracts when present:
trusted dependencies, model-chosen tool input, session state, and workflow state;
conversation history, session summaries, user memories, knowledge retrieval, workflow checkpoints, and model-owned plans;
final content, structured output, token deltas, run events, pauses, and terminal status;
confirmation, user input, external tool execution, authenticated authorization, and process isolation;
team delegation, deterministic workflow control, AgentOS transport, queues, and deployment.
Record each observed contract, its owner, semantic difference, and executable proof. An unused Agno feature is not migration scope.
Read Research and concept mapping for the detected features. Read Verification and cutover before implementation.
Choose the smallest target
Core: use
pydantic_ai.Agentfor the agent loop, typed dependencies, tools, outputs, normalized messages, generic hooks, streaming, MCP clients, approvals, usage limits, instrumentation, realtime, and durable-runtime integrations.Graph: use
pydantic_graphonly when explicit typed nodes, branches, and joins remain useful; use plain async Python for simple fixed control flow.Harness: add
pydantic-ai-harnessonly for observed reusable policy such as memory notebooks, planning, model-directed subagents, Agent Skills, coding tools, guardrails, model-agnostic compaction, or step persistence. Harness capabilities compose through the core agent loop; Harness is not a second runtime.Evals: add the separate
pydantic-evalspackage for observed datasets and evaluators.Application: retain authentication, databases, vector search, queues, AgentOS/API routes, storage schemas, deployment, product state, and UI transports unless the requested slice includes them.
Gap: name behavior that no supported public seam preserves, explain its impact, and test a bounded adapter. Do not rebuild Agno's registry, database abstraction, event taxonomy, or AgentOS merely to hide a difference.
The normal migration is one reusable Agent, application services supplied through typed dependencies, typed tools and output, and application-owned storage of serialized result.all_messages() for later turns. Preserve an existing HTTP, job, or UI boundary with a small adapter and its current field names.
Apply high-risk gates
Agno
dependencies,user_id,session_id, and authenticated identity are trusted runtime context, not model arguments. Put them in typed dependencies and authorize storage or effects in application code.Agno sessions combine distinct owners. Map chat history to serialized Pydantic AI messages; keep mutable product/session state in an application store; treat summaries, user memories, knowledge retrieval, workflow checkpoints, and Harness
Memoryas separate contracts. Choose and test record conversion, a read-through adapter, or starting fresh as an accepted change.Inspect a
Team's actual delegation mode and caller-visible member events. Use HarnessSubAgentsonly for model-directed, isolated task delegation. Keep routing, broadcast, deterministic fan-out, shared-context collaboration, aggregation, and retries in application or graph code unless parity is proved.Keep Agno
Workflowsteps, conditions, routers, loops, and parallel joins deterministic. Do not move them into an agent prompt. Graph state alone is not a persisted checkpoint.Agno pauses for confirmation, user input, and external execution have different payloads and owners. Core deferred tools can preserve pending model tool calls; the application still owns identity, authorization, UI, audit, persistence, correlation, and idempotency. Prove restart when the source pause survives one.
Map pre/post hooks, tool hooks, and guardrails by firing point, mutation, short-circuit behavior, ordering, retries, streaming visibility, and persistence. Similar hook names do not prove lifecycle parity.
Map consumer intent for streaming. Pydantic AI output streaming, run-event streaming, capability events, UI adapters, and graph iteration are different surfaces; none promises Agno's run-event taxonomy or resume cursor.
Agno Skills can expose instructions, references, and scripts. Harness
SkillsloadsSKILL.mdinstructions on demand but does not load bundled resources or execute scripts; add explicitFileSystem,Shell, or application tools only for observed, trusted behavior.AgentOS routes, auth, session APIs, telemetry, control plane, database selection, and deployment are product infrastructure. Keep or replace each deliberately rather than treating an agent port as an AgentOS port.
Tool allowlists, path checks, and guardrails are policy, not OS isolation. Use a container, VM, or cloud sandbox when untrusted execution is in scope.
Implement and prove one vertical slice
Preserve the supported caller boundary and replace only agent-owned internals.
Start core-only. Add
pydantic_graph, Harness, Evals, or a durable runtime only after a source contract requires it.Test inputs, typed outputs, errors, event order, tool arguments/results, hook decisions, state across turns, and side effects at that boundary. Use deterministic models and fake application services offline; add a focused recorded or live test only when provider behavior is the contract.
For persistence, pauses, concurrent workflows, or external effects, test interruption and restart, lineage, authorization, failure aggregation, and idempotency at the exact boundary Agno promised.
Remove
agno, AgentOS setup, and Agno storage or event adapters only after no retained path needs them.
Explain any consequential semantic change before implementing it: state the source behavior, target behavior, caller impact, recommended choice, and remaining risk.
Completion
Apply the completion criterion in Verification and cutover. Label evidence from fakes, recordings, live providers, and operational tests accurately.
Files
- ATTRIBUTION.mdAdded by AutoGineer875 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md7.0 KiB
- agents/openai.yaml293 B
- references/RESEARCH-AND-MAPPING.md9.1 KiB
- references/VERIFICATION-AND-CUTOVER.md5.8 KiB
references/VERIFICATION-AND-CUTOVER.md
Verification and cutover
Prove parity through the application's supported boundary. Do not require high-risk exercises for behavior the source does not use.
Build a contract ledger
For each traced source behavior, maintain one row:
| Source lifecycle | Observable contract | Owner | Target difference | Evidence |
|---|---|---|---|---|
| What initiates and completes it | Inputs, outputs, events, errors, ordering, state, or effects callers observe | Application, Core, Graph, Harness, Evals, or Gap | What will not remain identical | Baseline and focused target test |
Use these evidence states:
| Status | Meaning |
|---|---|
verified-equivalent | Source and target preserve the same observable contract in executable checks. |
verified-adapter | Internal semantics differ, but an adapter preserves the public contract in executable checks. |
intentional-change | The difference and impact were explained and explicitly accepted. |
external-owner | A named application or infrastructure component preserves the contract, with evidence at that boundary. |
not-applicable | The observed source path does not provide or consume this behavior. |
unverified | Evidence is incomplete or only a candidate design exists; do not call it equivalent. |
blocked | A required contract has no acceptable proved construction; do not cut over the slice. |
Match testing to the slice
Ordinary agent or tool
Characterize the public call and result before rewriting it.
Use
TestModelorFunctionModelto prove prompts, dependency-backed tool calls, validated output, retry/error mapping, messages, and usage without network access.Add a provider recording or live probe only when transport, native tools, structured-output mode, provider events, or multimodal behavior is part of the contract.
Sessions, state, memory, and knowledge
Choose and test how existing Agno records cross cutover: one-time conversion, a read-through adapter, or starting fresh as an
intentional-change.Serialize normalized target messages through the application's real store and load them in a fresh process for the next turn.
Test user/session ownership, retention, incomplete tool calls, store failures, and concurrent updates.
Test mutable session state, summaries, user memory/learning, knowledge retrieval, workflow state, checkpoints, and model-owned plans independently. Similar facts appearing in a prompt do not prove equivalent lifecycle or ownership.
Teams and workflows
Characterize member selection, input/history sharing, aggregation, branch selection, step inputs/outputs, joins, concurrency limits, ordering, partial failures, cancellation, retries, and terminal status that callers consume.
Keep deterministic collaboration and workflow control in Python or
pydantic_graph; use deterministic agents only inside steps that actually call them.For pause/resume or durable execution, kill and restart at each promised boundary. Assert persisted state and step identity, validate resume input, and prove external effects are idempotent.
Human-in-the-loop and protected effects
Distinguish confirmation, free-form user input, and external execution in the ledger.
Persist the pending request's category, validated arguments, call ID, and required metadata when it crosses a run or process boundary.
Exercise deny, approve/input/result, timeout, duplicate response, and restart.
Assert no protected effect before resolution, zero after denial, and exactly one after approval or authorized external execution.
Exercise authenticated identity, policy lookup, correlation, and audit trail. A local yes/no callback is not authorization proof.
Hooks, streaming, and skills
Record a source golden trace containing only event types and stable fields the caller consumes.
Test hook/guardrail order, mutation, short-circuit behavior, retries, text/object reconstruction, terminal detection, trailing events, cancellation, and parallel calls.
For skills, test discovery, model selection, loaded instructions, every used bundled resource or script, trust policy, and behavior after restart.
AgentOS and execution environments
Run fixtures against retained or replacement API routes, auth, session selection, event serialization, errors, and transport cancellation.
For file/shell/browser/code tools, use a disposable workspace and test ordinary effects plus traversal, symlinks, denied files, output limits, timeouts, cleanup, environment handling, and working directory.
If untrusted code is in scope, run containment tests inside the selected container, VM, or cloud sandbox. Path restrictions and command allowlists are not containment evidence.
Dependency and cutover checks
Resolve the Python project from a clean environment against supported Pydantic AI and Harness versions. Prefer
pydantic-ai-slimwith only required provider/integration extras when the surface is bounded.Run source characterization tests and focused target tests through the same public boundary. Label each as deterministic fake, recording, live service, fresh-process restart, or real sandbox evidence.
Search imports, factories, configuration, session/state readers, workflow checkpoints, event/result adapters, AgentOS routes, and deployment scripts for retained
agnodependencies.Keep compatibility adapters and rollback until all callers consume the target shapes and every required ledger row is resolved.
Remove Agno, AgentOS, database adapters, and event assumptions only when no retained path needs them.
Completion criterion
Cut over only when every ledger row is verified-equivalent, verified-adapter, an accepted intentional-change, external-owner, or not-applicable; no required row is unverified or blocked; the supported boundary passes; dependencies resolve cleanly; and rollback remains possible.
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.
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-agno-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.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download migrating-agno-to-pydantic-ai.zip