Generated banner for Migrating Agno To Pydantic AI
Generated logo for Migrating Agno To Pydantic AI

Migrating Agno To Pydantic AI

PydanticOfficialPublished by Pydantic

  • Skill
  • Workflow
  • Software development
  • MIT
  • No issues found

From the author

Migrate Python Agno applications to Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports `agno` or relies on Agno agents, teams, workflows, sessions, memory, knowledge, tools, hooks, guardrails, approvals, skills, streaming, or AgentOS.
— the description by Pydantic

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

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/pydantic/migrating-agno-to-pydantic-ai/download
  2. Unzip 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

  1. Read repository instructions, dependencies, tests, and the runtime entrypoint. Record the installed Agno, Pydantic AI, and Harness versions.

  2. Trace one real request from Agent.run() / arun(), Team.run() / arun(), a Workflow, 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.

  3. 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.

  4. 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.Agent for 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_graph only when explicit typed nodes, branches, and joins remain useful; use plain async Python for simple fixed control flow.

  • Harness: add pydantic-ai-harness only 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-evals package 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 Memory as 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 Harness SubAgents only 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 Workflow steps, 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 Skills loads SKILL.md instructions on demand but does not load bundled resources or execute scripts; add explicit FileSystem, 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

  1. Preserve the supported caller boundary and replace only agent-owned internals.

  2. Start core-only. Add pydantic_graph, Harness, Evals, or a durable runtime only after a source contract requires it.

  3. 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.

  4. For persistence, pauses, concurrent workflows, or external effects, test interruption and restart, lineage, authorization, failure aggregation, and idempotency at the exact boundary Agno promised.

  5. 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

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.

Ownership map

Observed Agno behaviorTarget owner and likely seamFocused proof
Agent.run() / arun() and RunOutput.content, messages, metrics, or referencesCore: Agent.run() / run_sync(), AgentRunResult; Application: response adapterAssert caller-visible output, required trajectory fields, usage, errors, and side effects.
stream=True, stream_events=True, background streaming, or resumed event streamsCore: run_stream(), run_stream_events(), event_stream_handler, or iter(); Application: event/cursor adapterAssert reconstruction, order, stable fields, terminal detection, cancellation, reconnect/resume behavior, and no duplicate output.
Instructions, model, retries, reasoning, and call optionsCore: instructions, model/provider settings, retries, and UsageLimits; Application: configuration mappingConstruct every configured branch and assert limits/defaults actually consumed by the slice.
dependencies, RunContext, user_id, session_id, and metadata interpolationCore: typed deps_type, RunContext.deps, dynamic instructions/tool preparation; Application: authenticated context constructionInspect tool schemas and prove identity, credentials, stores, and services cannot be model-selected.
Functions, Function, Toolkit, MCP tools, and tool-choice restrictionsCore: typed tools, Tool, function toolsets, MCPToolset, preparation capabilitiesAssert names, schemas, return shape, error/retry behavior, timeout, concurrency, and effects.
output_schema, output_model, parser, or second structuring modelCore: Pydantic output type and explicit NativeOutput, ToolOutput, PromptedOutput, or TextOutput where transport mattersAssert valid output, invalid-output retries/errors, and preserve any second-model pass explicitly.
Pre-hooks, post-hooks, and tool hooksCore: Hooks, custom capability hooks, output validators, or toolset wrappers; Harness: ToolGuardrail when a tool-hook policy matches; Application: public error/event adapterGolden-test firing point, input mutation, short-circuit, order, retries, exceptions, persistence, and streaming visibility.
Input/output guardrailsHarness: matching InputGuardrail or OutputGuardrail; Core: output validators or custom capability when lifecycle differsExercise allow, block, replace/redact, retry, parallel execution, and caller-visible error/event shape.
Database-backed session messages and summariesCore: normalized messages; Application: existing store, ownership, retention, summary policy, and record migrationContinue in a fresh process, test incomplete tool calls and store errors, and reject cross-user/session access.
session_state, agentic state tools, or state interpolationApplication/Graph: typed state store; Core: dependencies provide trusted access, tools expose only intended mutationsAssert merge/overwrite policy, concurrent writes, namespace, prompt injection, and restart independently of messages.
User memories and learningHarness: Memory only when a model-owned namespaced notebook fits; otherwise Application: retain the memory/learning serviceAssert write trigger, schema, retrieval/injection, update/delete policy, tenant scope, bounds, and fresh-process continuation.
Knowledge bases, readers, embedders, vector DBs, filters, and referencesApplication: existing retrieval service behind dependencies or a tool; Core: tool call and resultAssert ingestion separately from query ranking, filters, citation shape, tenancy, failure behavior, and freshness.
Session summary, history window, compressionCore/Harness: history processing or an observed matching compaction strategy; Application: persisted summary contractAssert exactly what context survives, when summary runs, failure fallback, cost, and continuation. Do not equate generic compaction with memory.
Team delegation to membersHarness: SubAgents for isolated model-directed tasks; Core: agent-as-tool or programmatic delegation; Application/Graph: other collaboration modesAssert member selection, input/history isolation, shared context, result handback, aggregation, events, budgets, cancellation, and recursion.
Team coordinate/route/broadcast/tasks modesApplication/Graph unless a focused Harness composition proves the observed semanticsAssert routing, fan-out concurrency, merge order, leader/member retries, partial failure, and public result/event shape.
Fixed sequential workflowApplication: plain typed async functions; Graph: pydantic_graph when graph inspection adds valueAssert step inputs/outputs, order, error propagation, and terminal status.
Conditions, routers, loops, parallel steps, and custom workflow functionsApplication/Graph: explicit Python control flow and typed graph stateAssert chosen route, loop stop, join shape, source ordering, concurrency limit, cancellation, and partial failure.
Workflow session state, pause/resume, checkpoints, and persisted stepsApplication or durable engine: workflow state and progress; Core durable integration: agent operations inside that workflowKill and restart at each promised boundary; validate resume payload, step identity, lineage, and idempotent effects. Graph state alone is not persistence.
Tool confirmationCore: requires_approval, ApprovalRequired, or ApprovalRequiredToolset; inline HandleDeferredToolCalls or later DeferredToolResults; Application: policy, UI, audit, persistenceExercise deny/approve and prove zero effects before or after denial and exactly one after approval.
User-input pausesApplication: collect and validate conversational input; resume with explicit message or application stateAssert prompt/request shape, timeout/cancel, correlation, duplicate input, restart, and how input enters model context.
External tool executionApplication: execute the pending validated request; Core: deferred result resumes the agentPersist the complete request, authorize executor, assert result/error mapping and exactly-once effect policy.
Agno SkillsHarness: Skills for SKILL.md instructions; FileSystem, Shell, or Application tools for observed resources/scriptsAssert configured discovery, on-demand selection, every required reference/resource, trust, and script permissions separately.
AgentOS API, auth, sessions, control plane, registry, config, telemetry, and deploymentApplication/infrastructureExercise retained routes/jobs including auth, tenancy, wire shape, scaling, and failures.
AgentOS interfaces such as AG-UI, A2A, Slack, or WhatsAppCore UI adapters where protocol fits; Application: transport and authRun protocol fixtures or end-to-end tests; do not infer parity from having another UI adapter.
Evals, cases/suites, judges, and metricsEvals (pydantic_evals): cases, datasets, evaluators; Application: scheduling and score storageAdd the separate dependency, compare essential metrics on the same cases, and separately prove live sampling/persistence.
OpenTelemetry and Agno tracingCore: instrumentation/OpenTelemetry; optional Logfire; Application: existing backend and adaptersAssert trace correlation, content/privacy policy, required spans, retention, dashboards, and alerts before switching.
File, shell, browser, code execution, or broad Agno toolkit catalogHarness: matching focused capabilities such as Coder, FileSystem, Shell, browser capabilities, or ModalSandbox; Application: retained integrationsAssert 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