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://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/RESEARCH-AND-MAPPING.md
Research and concept mapping
Use this reference conditionally after tracing the source path. It is a decision guide, not a requirement to reproduce the entire Agno platform.
Primary documentation
Inspect installed versions before migrating because Agno, Pydantic AI, and Harness continue to evolve.
Agno: agents, teams, workflows, sessions, memory, and human-in-the-loop.
Pydantic AI: agents, message history, hooks, graphs, and deferred tools.
Pydantic AI Harness: overview, memory, guardrails, skills, subagents, and step persistence.
Ownership map
| Observed Agno behavior | Target owner and likely seam | Focused proof |
|---|---|---|
Agent.run() / arun() and RunOutput.content, messages, metrics, or references | Core: Agent.run() / run_sync(), AgentRunResult; Application: response adapter | Assert caller-visible output, required trajectory fields, usage, errors, and side effects. |
stream=True, stream_events=True, background streaming, or resumed event streams | Core: run_stream(), run_stream_events(), event_stream_handler, or iter(); Application: event/cursor adapter | Assert reconstruction, order, stable fields, terminal detection, cancellation, reconnect/resume behavior, and no duplicate output. |
| Instructions, model, retries, reasoning, and call options | Core: instructions, model/provider settings, retries, and UsageLimits; Application: configuration mapping | Construct every configured branch and assert limits/defaults actually consumed by the slice. |
dependencies, RunContext, user_id, session_id, and metadata interpolation | Core: typed deps_type, RunContext.deps, dynamic instructions/tool preparation; Application: authenticated context construction | Inspect tool schemas and prove identity, credentials, stores, and services cannot be model-selected. |
Functions, Function, Toolkit, MCP tools, and tool-choice restrictions | Core: typed tools, Tool, function toolsets, MCPToolset, preparation capabilities | Assert names, schemas, return shape, error/retry behavior, timeout, concurrency, and effects. |
output_schema, output_model, parser, or second structuring model | Core: Pydantic output type and explicit NativeOutput, ToolOutput, PromptedOutput, or TextOutput where transport matters | Assert valid output, invalid-output retries/errors, and preserve any second-model pass explicitly. |
| Pre-hooks, post-hooks, and tool hooks | Core: Hooks, custom capability hooks, output validators, or toolset wrappers; Harness: ToolGuardrail when a tool-hook policy matches; Application: public error/event adapter | Golden-test firing point, input mutation, short-circuit, order, retries, exceptions, persistence, and streaming visibility. |
| Input/output guardrails | Harness: matching InputGuardrail or OutputGuardrail; Core: output validators or custom capability when lifecycle differs | Exercise allow, block, replace/redact, retry, parallel execution, and caller-visible error/event shape. |
| Database-backed session messages and summaries | Core: normalized messages; Application: existing store, ownership, retention, summary policy, and record migration | Continue in a fresh process, test incomplete tool calls and store errors, and reject cross-user/session access. |
session_state, agentic state tools, or state interpolation | Application/Graph: typed state store; Core: dependencies provide trusted access, tools expose only intended mutations | Assert merge/overwrite policy, concurrent writes, namespace, prompt injection, and restart independently of messages. |
| User memories and learning | Harness: Memory only when a model-owned namespaced notebook fits; otherwise Application: retain the memory/learning service | Assert write trigger, schema, retrieval/injection, update/delete policy, tenant scope, bounds, and fresh-process continuation. |
| Knowledge bases, readers, embedders, vector DBs, filters, and references | Application: existing retrieval service behind dependencies or a tool; Core: tool call and result | Assert ingestion separately from query ranking, filters, citation shape, tenancy, failure behavior, and freshness. |
| Session summary, history window, compression | Core/Harness: history processing or an observed matching compaction strategy; Application: persisted summary contract | Assert exactly what context survives, when summary runs, failure fallback, cost, and continuation. Do not equate generic compaction with memory. |
Team delegation to members | Harness: SubAgents for isolated model-directed tasks; Core: agent-as-tool or programmatic delegation; Application/Graph: other collaboration modes | Assert member selection, input/history isolation, shared context, result handback, aggregation, events, budgets, cancellation, and recursion. |
| Team coordinate/route/broadcast/tasks modes | Application/Graph unless a focused Harness composition proves the observed semantics | Assert routing, fan-out concurrency, merge order, leader/member retries, partial failure, and public result/event shape. |
| Fixed sequential workflow | Application: plain typed async functions; Graph: pydantic_graph when graph inspection adds value | Assert step inputs/outputs, order, error propagation, and terminal status. |
| Conditions, routers, loops, parallel steps, and custom workflow functions | Application/Graph: explicit Python control flow and typed graph state | Assert chosen route, loop stop, join shape, source ordering, concurrency limit, cancellation, and partial failure. |
| Workflow session state, pause/resume, checkpoints, and persisted steps | Application or durable engine: workflow state and progress; Core durable integration: agent operations inside that workflow | Kill and restart at each promised boundary; validate resume payload, step identity, lineage, and idempotent effects. Graph state alone is not persistence. |
| Tool confirmation | Core: requires_approval, ApprovalRequired, or ApprovalRequiredToolset; inline HandleDeferredToolCalls or later DeferredToolResults; Application: policy, UI, audit, persistence | Exercise deny/approve and prove zero effects before or after denial and exactly one after approval. |
| User-input pauses | Application: collect and validate conversational input; resume with explicit message or application state | Assert prompt/request shape, timeout/cancel, correlation, duplicate input, restart, and how input enters model context. |
| External tool execution | Application: execute the pending validated request; Core: deferred result resumes the agent | Persist the complete request, authorize executor, assert result/error mapping and exactly-once effect policy. |
| Agno Skills | Harness: Skills for SKILL.md instructions; FileSystem, Shell, or Application tools for observed resources/scripts | Assert configured discovery, on-demand selection, every required reference/resource, trust, and script permissions separately. |
| AgentOS API, auth, sessions, control plane, registry, config, telemetry, and deployment | Application/infrastructure | Exercise retained routes/jobs including auth, tenancy, wire shape, scaling, and failures. |
| AgentOS interfaces such as AG-UI, A2A, Slack, or WhatsApp | Core UI adapters where protocol fits; Application: transport and auth | Run protocol fixtures or end-to-end tests; do not infer parity from having another UI adapter. |
| Evals, cases/suites, judges, and metrics | Evals (pydantic_evals): cases, datasets, evaluators; Application: scheduling and score storage | Add the separate dependency, compare essential metrics on the same cases, and separately prove live sampling/persistence. |
| OpenTelemetry and Agno tracing | Core: instrumentation/OpenTelemetry; optional Logfire; Application: existing backend and adapters | Assert trace correlation, content/privacy policy, required spans, retention, dashboards, and alerts before switching. |
| File, shell, browser, code execution, or broad Agno toolkit catalog | Harness: matching focused capabilities such as Coder, FileSystem, Shell, browser capabilities, or ModalSandbox; Application: retained integrations | Assert only tools the slice uses, plus workspace effects, timeouts, output limits, credentials, and real containment when required. |
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 or Pydantic.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download migrating-agno-to-pydantic-ai.zip