• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialdevelopment

migrating-agno-to-pydantic-ai

プラグイン
pydantic-ai
ソース
GitHub で見る ↗
説明

Python版Agnoアプリケーションを、Pydantic AIに移行します。必要に応じてPydantic AI Harness(Pydantic AIの実行環境統合ツール)も使用します。 次のような場合に使用: - ソースコードが`agno`をインポートしている - Agnoエージェント(自動で判断・行動するAI)、チーム機能、ワークフロー(作業の流れ)、セッション(やり取りの記録)、メモリ(過去の学習)、知識ベース、ツール、フック(処理の割り込み)、ガードレール(安全上の制限)、承認機能、スキル(特定の能力)、ストリーミング(リアルタイム通信)、またはAgentOS(Agnoの基盤環境)に依存している

原文を表示

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.

ユースケース
  • AgnoをインポートしているPythonコードを移行するとき
  • Agnoエージェント機能をPydantic AIで実装するとき
  • Agnoチーム機能やワークフローを移行するとき
  • AgnoのセッションやメモリをPydantic AIで再構築するとき
  • Agnoの知識ベース・ツール・ガードレールを移行するとき
本文(日本語訳)

Agno から Pydantic AI への移行

Agno のオブジェクトモデルではなく、外部から見える動作を保持します。最小限の完全な呼び出しパスを移行し、アプリケーション基盤はそのまま保ちます。

対象を選ぶ前にソースをたどる

  1. リポジトリの説明、依存関係、テスト、実行時エントリーポイントを読みます。インストール済みの Agno、Pydantic AI、Harness のバージョンを記録します。

  2. 実際のリクエストを Agent.run() / arun()、Team.run() / arun()、Workflow、または AgentOS エンドポイントから、指示、モデル呼び出し、ツール呼び出し、フック、セッション読み込み、メモリまたはナレッジ取得、イベント、結果、状態、副作用を通じて最後まで追跡します。焦点を絞ったベースラインテストまたは特性テストを確立します。

  3. 以下のソース契約(仕様)を分離します:

    • 信頼できる依存関係、モデルが選択したツール入力、セッション状態、ワークフロー状態
    • 会話履歴、セッション要約、ユーザーメモリ、ナレッジ取得、ワークフローチェックポイント、モデルが作成した計画
    • 最終コンテンツ、構造化出力、トークン使用量の差分、実行イベント、一時停止、終了状態
    • 確認、ユーザー入力、外部ツール実行、認証付き認可、プロセス隔離
    • チーム間委譲、決定論的ワークフロー制御、AgentOS 転送、キュー、デプロイメント
  4. 観察された各契約、その所有者、意味的な違い、実行可能な証拠を記録します。未使用の Agno 機能は移行スコープに含まれません。

「Research and concept mapping」で検出された機能を読みます。実装前に「Verification and cutover」を読みます。

最小の対象を選ぶ

  • Core(コア): エージェントループ、型付き依存関係、ツール、出力、正規化されたメッセージ、汎用フック、ストリーミング、MCP クライアント、承認、使用量制限、計測、リアルタイム、耐久性のあるランタイム連携には pydantic_ai.Agent を使用します。

  • Graph(グラフ): 明示的な型付きノード、分岐、結合が有用な場合のみ pydantic_graph を使用します。単純で固定的な制御フローは通常の非同期 Python を使用します。

  • Harness(ハーネス): メモリノート、計画、モデル指向の部分エージェント、エージェントスキル、コーディングツール、ガードレール(制限事項)、モデル非依存の圧縮、ステップの永続性など、観察された再利用可能なポリシーがある場合のみ pydantic-ai-harness を追加します。Harness の機能はコアエージェントループを通じて構成されます。Harness は第二のランタイムではありません。

  • Evals(評価): 観察されたデータセットと評価器がある場合、別の pydantic-evals パッケージを追加します。

  • Application(アプリケーション): 認証、データベース、ベクトル検索、キュー、AgentOS/API ルート、ストレージスキーマ、デプロイメント、プロダクト状態、UI 転送は保持します(要求されたスライスに含まれていない限り)。

  • Gap(ギャップ): サポートされている公開インターフェイスで保持できない動作に名前を付け、その影響を説明し、限定的なアダプタをテストします。Agno のレジストリ、データベース抽象化、イベント分類法、AgentOS を単なる違いを隠すために再構築しないでください。

通常の移行は、再利用可能な Agent 1 つ、アプリケーションサービスが型付き依存関係を通じて提供される構成です。型付きツールと出力、シリアル化された result.all_messages() をアプリケーション保有のストレージに保存して後続のターンで使用します。既存の HTTP、ジョブ、UI 境界を小さなアダプタとその現在のフィールド名で保持します。

高リスク判定を適用する

  • Agno の dependencies、user_id、session_id、認証済みアイデンティティは、信頼できるランタイムコンテキストであり、モデル引数ではありません。型付き依存関係に配置し、ストレージまたは副作用の認可はアプリケーションコードで行います。

  • Agno セッションは異なる所有者を組み合わせています。チャット履歴をシリアル化された Pydantic AI メッセージにマップします。変更可能なプロダクト/セッション状態はアプリケーションストアに保ちます。要約、ユーザーメモリ、ナレッジ取得、ワークフローチェックポイント、Harness Memory は別の契約として扱います。レコード変換、リードスルーアダプタ、または新規開始を選択してテストします。

  • Team の実際の委譲モードと呼び出し側に見えるメンバーイベントを検査します。Harness SubAgents はモデル指向で隔離されたタスク委譲の場合のみ使用します。ルーティング、ブロードキャスト、決定論的な展開、共有コンテキスト協業、集約、再試行はアプリケーションまたはグラフコードに保ちます(パリティが証明されていない限り)。

  • Agno Workflow のステップ、条件、ルーター、ループ、並列結合を決定論的に保ちます。エージェントプロンプトに移動しないでください。グラフ状態だけは永続化されたチェックポイントではありません。

  • Agno の確認、ユーザー入力、外部実行のための一時停止はペイロード(データ形式)と所有者が異なります。コアの遅延ツールはペンディング中のモデルツール呼び出しを保持できます。アプリケーションは引き続きアイデンティティ、認可、UI、監査、永続性、関連付け、べき等性(同じ操作の繰り返しが安全)を所有します。ソース一時停止がもう 1 つ存在する場合、再開時を証明します。

  • 前処理/後処理フック、ツールフック、ガードレールを発火ポイント、変更、短絡動作、順序、再試行、ストリーミング可視性、永続性でマップします。フック名が似ていても、ライフサイクルのパリティは証明されません。

  • ストリーミングのコンシューマー意図をマップします。Pydantic AI 出力ストリーミング、実行イベントストリーミング、機能イベント、UI アダプタ、グラフ反復は異なるサーフェスです。いずれも Agno の実行イベント分類法またはレジュームカーソルを保証しません。

  • Agno Skills は指示、参照、スクリプトを公開できます。Harness Skills はオンデマンドで SKILL.md 指示を読み込みますが、バンドルされたリソースは読み込まず、スクリプトを実行しません。観察された信頼できる動作に対してのみ、明示的な FileSystem、Shell、またはアプリケーションツールを追加してください。

  • AgentOS ルート、認証、セッション API、テレメトリ、制御プレーン、データベース選択、デプロイメントはプロダクト基盤です。エージェントポートを AgentOS ポートとして扱うのではなく、各々を意図的に保持または置き換えてください。

  • ツール許可リスト、パスチェック、ガードレールはポリシーであり、OS 隔離ではありません。信頼できない実行がスコープ内にある場合、コンテナ、VM、クラウドサンドボックスを使用します。

1 つの垂直スライスを実装して検証する

  1. サポートされている呼び出し側境界を保持し、エージェント所有の内部だけを置き換えます。

  2. コアのみから始めます。pydantic_graph、Harness、Evals、または耐久性のあるランタイムはソース契約が必要になった後でのみ追加します。

  3. その境界で入力、型付き出力、エラー、イベント順序、ツール引数/結果、フック判定、ターン間の状態、副作用をテストします。決定論的モデルと偽のアプリケーションサービスをオフラインで使用します。プロバイダーの動作が契約である場合のみ、焦点を絞った記録済みまたはライブテストを追加します。

  4. 永続性、一時停止、並行ワークフロー、外部副作用の場合、Agno が約束した正確な境界で中断と再開、系統、認可、障害集約、べき等性をテストします。

  5. 保持されたパスがどれも必要としない場合のみ、agno、AgentOS セットアップ、Agno ストレージまたはイベントアダプタを削除します。

実装する前に、重大な意味的変更について説明します:ソース動作、対象動作、呼び出し側への影響、推奨される選択肢、残存リスクを述べてください。

完了

「Verification and cutover」の完了基準を適用します。偽物、記録、ライブプロバイダー、運用テストからの証拠に正確にラベルを付けます。

原文(English)を表示

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.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。