• 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-vercel-ai-sdk-and-eve-to-pydantic-ai

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

TypeScript版のVercel AI SDKまたはEveアプリケーションをPythonに移行する際に、Pydantic AIを使用し、必要な場合のみPydantic AI Harness(補助ツール)を使用します。 **次のような場合に使用:** - ソースコードが `ai`、`@ai-sdk/*`、または `eve` をインポートしている - `generateText`、`streamText`、`ToolLoopAgent`、`useChat` に依存している - Eve agentsやtools、skills、subagents、approvals、sessions、channels、schedules、sandboxesを使用している

原文を表示

Migrate TypeScript Vercel AI SDK or Eve applications to Python with Pydantic AI and, only when needed, Pydantic AI Harness. Use when source code imports `ai`, `@ai-sdk/*`, or `eve`, or relies on `generateText`, `streamText`, `ToolLoopAgent`, `useChat`, Eve agents, tools, skills, subagents, approvals, sessions, channels, schedules, or sandboxes.

ユースケース
  • TypeScript版Vercel AI SDKをPythonに移行するとき
  • EveアプリケーションをPythonに移行するとき
  • generateTextやstreamTextに依存しているコード
  • Eve agents、tools、skillsを使用している場合
  • approvals、sessions、channels等を使用している場合
本文(日本語訳)

Vercel AI SDK と Eve から Pydantic AI への移行

アプリケーションの実際の動作を保つこと。ソースコードのAPIではなく、目に見える挙動を優先します。Vercel AI SDK Core、AI SDK UI、Eve はそれぞれ異なる役割を持っているため、各ソースの動作がどれに属するかを確認してから、移行先を選びます。

移行先を選ぶ前に、ソースを追跡する

  1. リポジトリの説明、依存パッケージ、ロックファイル、テスト、実行時の起点を読みます。workspace:* 依存関係を具体的なパッケージバージョンに解決し、インストールされているAI SDK、Eve、Pydantic AI、Harness のバージョンを記録します。

  2. 実際のリクエストを公開された起点からたどります。メッセージ、モデル呼び出し、ツール、承認、ストリーム、永続化、副作用を経由して、呼び出し元が受け取る結果に至るまでの流れを確認します。焦点を絞ったベースラインやテストを作成してください。

  3. 観察された各機能を分類します:

    • AI SDK Core: モデル呼び出し、ステップループ、ツール実行、構造化出力、プロバイダルーティング
    • AI SDK UI: UIMessage、useChat、トランスポート(通信方式)、クライアント側ツール、ストリームチャンク、再接続動作
    • Eve: ファイルシステムで定義されたエージェント、耐久性のあるセッション、スキル、サブエージェント、状態、接続、チャネル、スケジュール、サンドボックス
    • アプリケーション/プラットフォーム: 認証、認可、ストレージ、キュー、デプロイメント、認証情報、プロダクトUI、Vercel ホスティングサービス
  4. 各機能、その所有者、意味の違い、実行可能な証拠を記録します。使用されていない機能は移行の対象ではありません。

研究と概念マッピング でソースから検出された機能を確認してください。実装前に 検証とカットオーバー をお読みください。

最小限の移行先を選ぶ

  • Core: pydantic_ai.Agent をエージェントループ、型付き依存関係、ツール、出力、メッセージ、ストリーミング、MCP クライアント、承認、使用量制限、計測、耐久性のあるランタイム統合に使用します。

  • Graph: 明確に型付けされたノード、分岐、結合が有用な場合のみ pydantic_graph を使用します。単純な固定的な制御フローは通常の非同期Python で実装してください。

  • Harness: 再利用可能なポリシー(エージェントスキル、モデルが指示するサブエージェント、計画、メモリノートブック、コーディングツール、安全ガードレール、ステップ永続化など)が観察された場合のみ pydantic-ai-harness を追加します。Harness の機能はコアエージェントループを通じて組み合わされます。Harness は Eve 互換のランタイムではありません。

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

  • アプリケーション: UI、HTTP 通信方式、認証、永続化、再接続状態、スケジューラー、デプロイメント、テナントポリシー、ホスティングサービスは保持します。リクエストされたスライスに置き換えが含まれていない限り、変更しません。

  • ギャップ: 対応する公開インターフェースが保つことができない動作については、その名前を付け、影響を説明し、制限されたアダプターでテストしてください。違いを隠すだけのためにAI SDK や Eve のオブジェクトモデルを再現してはいけません。

通常のAI SDK 移行は、既存の呼び出し元の背後に再利用可能な Agent を一つ配置することです。@ai-sdk/workflow は通常のエージェントループではなく、耐久性のあるランタイム移行として扱ってください。TypeScript または React クライアントがAI SDK UI を使用している場合は、それを保持したまま、VercelAIAdapter で正確にインストールされたバージョンのプロトコルで提供してください。UI を不要に移行してはいけません。ソースがプロセス内の TypeScript 呼び出しのみの場合は、同じスライス内の最も近い呼び出し元を移行するか、アプリケーションが所有する新しいサービス境界を明示的に合意してください。

通常のEve 移行は、コアエージェントと、観察された動作と一致する Harness 機能のみです。Eve の耐久性のあるセッションドライバー、プロダクトエンドポイント、スケジュール、チャネル、認証、ホスティングサービスは、各々に証拠のある置き換えができるまで、アプリケーションで保持してください。

高リスクなチェックポイントを適用する

  • generateText() と streamText() はデフォルトで単一ステップ、ToolLoopAgent はより長いループがデフォルト、WorkflowAgent は設定されない限り最大ステップ数がありません。観察された停止条件、使用量制限、prepareStep によるモデル・ツール・指示・メッセージ・ランタイムコンテキストの変更を保持してください。デフォルト値をそのままコピーしてはいけません。

  • ローカル実行、プロバイダー実行、ブラウザ/クライアント側、MCP ツールを区別してください。実行と認証情報の場所、入出力スキーマ、エラー復旧、キャンセル伝播、副作用の冪等性(繰り返し実行しても安全な性質)を保持してください。

  • AI SDK の非同期生成器ツールは、最終出力の前に中間結果を公開できます。通常のPydantic AI ツールは一度のみ戻ります。消費された中間UI 状態は、明示的なカスタムイベントまたは意図的な変更の記録で再現してください。

  • 完全な構造化出力は検証されます。部分的にストリーミングされた出力は不完全な場合があり、ツールと構造化出力を組み合わせるには別のステップが必要になることもあります。呼び出し元から見えるタイミングと障害の形を確認してください。

  • UIMessage はクライアント側で制御されるアプリケーション状態です。信頼できるプロバイダー履歴や依存関係コンテキストではありません。入力メッセージを検証し、ID とサービスをサーバー側に保持し、許可されたコンテンツのみをモデルメッセージに変換してください。

  • インストールされたAI SDK のワイヤプロトコルと一致させてください。現在のドキュメントではSSE ベースのUI メッセージワイヤ形式を「データストリームプロトコル」と呼んでいますが、古い実装では同じ名前の行プレフィックス付きフレームを使用できます。リクエストボディ、ヘッダー、フレーム、チャンク順序、ツール状態、エラー/中止動作、再接続エンドポイントは相互に置き換え不可です。インストールされたSDK バージョン用に VercelAIAdapter を設定し、境界の詳細なテストを行ってください。

  • AI SDK の承認は一般的に2段階のリクエスト会話です。Eve は耐久的にセッションを保留できます。Pydantic AI は後続の実行中に遅延呼び出しをインラインで解決できます。完全な保留中リクエストを永続化し、決定を検証済みの引数と呼び出しIDに結合し、承認者を認証し、保護された効果が正確に1回実行されることを証明してください。

  • Pydantic AI のメッセージ履歴は、未解決のツール呼び出しを超えて続行できません。Eve が承認待ちの間に関連のないターンを受け入れる場合は、保留中の分岐をアプリケーション状態で別に保持してください。関連のないプロンプトを不完全な履歴に追加しないでください。

  • Eve のセッション、ターン、ステップ、リプレイユニット、イベントカーソル、バックグラウンドサブエージェント、NDJSON セッションストリームは1つの耐久性のあるプロトコルです。コアメッセージ履歴とHarness の StepPersistence は自動的にそれを再現しません。アプリケーション所有のセッションアダプターを保持するか、再起動とリプレイテストが約束された動作を証明するまで、その違いをマークしてください。

  • Eve の defineState データは会話履歴とは別であり、耐久メモリは独自のライフサイクルと共有ルールを持っています。各ストアを独立して、セッション、ユーザー、テナント分離をテストしてください。

  • Eve スキルはサポートファイルを具現化できます。Harness の Skills は SKILL.md 指示のみを読み込みます。必要なリファレンス、アセット、スクリプトは FileSystem またはアプリケーションツール経由で提供し、明示的にテストしてください。

  • Eve のサブエージェントは、バックグラウンド結果のバッチ処理と個別ストリームを伴う耐久的な子セッションである場合があります。Harness の SubAgents は分離されたエージェントを実行して、その結果をツール経由で返します。これを、より狭いライフサイクルが観察された契約を保つ場合にのみ使用してください。そうでない場合は、アプリケーションでオーケストレーションを保持してください。

  • ファイルシステムまたはシェルポリシーはサンドボックス隔離ではありません。信頼できない実行がスコープに含まれる場合は、実際のコンテナ、VM、またはサポートされているクラウドサンドボックスで、Eve のサンドボックス、認証情報ブローカリング、ネットワーク境界を保持してください。

  • Eve チャネル、スケジュール、接続/OAuth、デフォルトHTTP API、Workflow SDK 永続化バックエンド、Vercel Agent Runs、デプロイメント統合はアプリケーション、またはプラットフォームの関心事です。Core または Harness に帰属させるのではなく、意図的に置き換え、テストしてください。

  • プロバイダールーティング、ゲートウェイの許可リスト/フォールバック、プロバイダーオプション、リトライセマンティクス、テレメトリ相関、評価データセットは、追跡されたパスがそれらを使用する場合にのみ保持してください。

1つのバーティカルスライスを実装して証明する

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

  2. コアのみで開始します。観察された契約が pydantic_graph、Harness、Pydantic Evals、または耐久性のあるランタイムを必要とした後にのみ追加してください。

  3. その境界で、入力、出力、エラー、メッセージ履歴、イベント順序、ツール引数/結果、ステップ数、状態、副作用をテストしてください。決定論的なモデルと偽のアプリケーションサービスをオフラインで使用してください。プロバイダー動作が契約の場合のみ、焦点を絞った記録またはライブテストを追加してください。

  4. 承認、再接続、耐久セッション、バックグラウンド作業、外部効果については、中断と新規プロセス再起動、安定した相関、認可、リプレイ、キャンセル、冪等性をテストしてください。

  5. 保持されたUI、トランスポート、エージェント、プラットフォームパスがそれらを必要としなくなった後にのみ、ai、@ai-sdk/*、または eve を削除します。

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

完了

検証とカットオーバー の完了基準を適用します。偽のシステム、記録、ライブプロバイダー、実際のサンドボックスからの証拠を正確にラベル付けしてください。

原文(English)を表示

Migrate Vercel AI SDK and Eve to Pydantic AI

Preserve the application's observable behavior, not the source APIs. Vercel AI SDK Core, AI SDK UI, and Eve have different responsibilities: identify which one owns each source behavior before choosing a target.

Trace the source before choosing a target

  1. Read repository instructions, dependencies, lockfiles, tests, and the runtime entrypoint. Resolve workspace:* dependencies to concrete package versions and record the installed AI SDK, Eve, Pydantic AI, and Harness versions.
  2. Trace one real request from its public entrypoint through messages, model calls, tools, approvals, streams, persistence, side effects, and the result the caller consumes. Establish a focused baseline or characterization test.
  3. Classify every observed contract:
    • AI SDK Core: model calls, step loops, tool execution, structured output, and provider routing;
    • AI SDK UI: UIMessage, useChat, transports, client tools, stream chunks, and reconnect behavior;
    • Eve: filesystem-defined agents, durable sessions, skills, subagents, state, connections, channels, schedules, and sandboxes;
    • Application/platform: authentication, authorization, storage, queues, deployment, credentials, product UI, and hosted Vercel services.
  4. Record each contract, its owner, semantic difference, and executable proof. An unused feature is not migration scope.

Read Research and concept mapping for the detected source features. Read Verification and cutover before implementation.

Choose the smallest target

  • Core: use pydantic_ai.Agent for the agent loop, typed dependencies, tools, outputs, messages, streaming, MCP clients, approvals, usage limits, instrumentation, 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 Agent Skills, model-directed subagents, planning, memory notebooks, coding tools, guardrails, or step persistence. Harness capabilities compose through the core agent loop; Harness is not an Eve-compatible runtime.
  • Evals: add the separate pydantic-evals package for observed datasets, cases, and evaluators.
  • Application: retain UI, HTTP transports, auth, persistence, reconnect state, schedulers, deployment, tenant policy, and hosted services unless the requested slice includes replacing them.
  • Gap: name behavior that no supported public seam preserves, explain its impact, and test a bounded adapter. Do not recreate the AI SDK or Eve object model merely to hide a difference.

The normal AI SDK migration is one reusable Agent behind the existing caller. Treat @ai-sdk/workflow as a durable-runtime migration, not an ordinary agent loop. When a TypeScript or React client uses AI SDK UI, keep it and serve its exact installed-version protocol with VercelAIAdapter; do not migrate the UI unnecessarily. When the source is only an in-process TypeScript call, migrate its nearest caller in the same slice or explicitly agree on a new application-owned service boundary.

The normal Eve migration is a core agent plus only the Harness capabilities that match observed behavior. Keep Eve's durable session driver, product endpoints, schedules, channels, authentication, and hosted services in the application until each has a proved replacement.

Apply high-risk gates

  • generateText() and streamText() are single-step by default, ToolLoopAgent defaults to a longer loop, and WorkflowAgent has no maximum step count unless configured. Preserve the observed stop conditions, usage limits, and prepareStep changes to models, tools, instructions, messages, or runtime context; do not copy defaults blindly.
  • Distinguish local, provider-executed, browser/client, and MCP tools. Preserve where execution and credentials live, input/result schemas, error recovery, cancellation propagation, and side-effect idempotency.
  • An AI SDK async-generator tool can expose preliminary results before its final output. An ordinary Pydantic AI tool returns once; reproduce consumed intermediate UI states with explicit custom events or record an intentional change.
  • Complete structured output is validated; partially streamed output may be incomplete, and combining tools with structured output may require another step. Test the caller-visible timing and failure shape.
  • UIMessage is client-controlled application state, not trusted provider history or dependency context. Validate incoming messages, keep identity and services server-side, and convert only the permitted content to model messages.
  • Match the installed AI SDK wire contract. The current docs call the SSE-based UI-message wire format the Data Stream Protocol, while older implementations can use line-prefixed frames under a similar name. Request bodies, headers, frames, chunk ordering, tool states, error/abort behavior, and reconnect endpoints are not interchangeable. Configure VercelAIAdapter for the installed SDK version and golden-test the boundary.
  • AI SDK approval is commonly a two-request conversation; Eve can durably park a session; Pydantic AI can resolve a deferred call inline or in a later run. Persist the complete pending request, bind a decision to validated arguments and call identity, authenticate the approver, and prove the protected effect runs exactly once.
  • Pydantic AI message history cannot continue past unresolved tool calls. If Eve accepts an unrelated turn while approval remains pending, keep the pending branch separate in application state; do not append an unrelated prompt to that incomplete history.
  • Eve sessions, turns, steps, replay units, event cursors, background subagents, and NDJSON session streams are one durable protocol. Core message history and Harness StepPersistence do not automatically reproduce it. Retain an application-owned session adapter or mark the difference until restart and replay tests prove the promised behavior.
  • Eve defineState data is separate from conversation history, and durable memory has its own lifetime and sharing rules. Map each store independently and test session, user, and tenant isolation.
  • Eve skills can materialize supporting files. Harness Skills loads SKILL.md instructions only; provide required references, assets, or scripts through FileSystem or application tools and test them explicitly.
  • Eve subagents may be durable child sessions with background result batching and separate streams. Harness SubAgents runs an isolated agent and returns its result through a tool. Use it only when that narrower lifecycle preserves the observed contract; otherwise retain orchestration in the application.
  • A filesystem or shell policy is not sandbox isolation. Preserve Eve's sandbox, credential-brokering, and network boundaries with a real container, VM, or supported cloud sandbox when untrusted execution is in scope.
  • Eve channels, schedules, connections/OAuth, its default HTTP API, Workflow SDK persistence backends, Vercel Agent Runs, and deployment integrations are application or platform concerns. Replace and test them deliberately rather than attributing them to Core or Harness.
  • Preserve provider routing, gateway allow-lists/fallbacks, provider options, retry semantics, telemetry correlation, and evaluation datasets only when the traced path uses them.

Implement and prove one vertical slice

  1. Preserve the supported caller boundary and replace only the agent-owned internals.
  2. Start core-only. Add pydantic_graph, Harness, Pydantic Evals, or a durable runtime only after an observed contract requires it.
  3. Test inputs, outputs, errors, message history, event order, tool arguments/results, step counts, state, and side effects at that boundary. Use deterministic models and fake application services offline; add a focused recording or live test only when provider behavior is the contract.
  4. For approvals, reconnects, durable sessions, background work, or external effects, test interruption and fresh-process restart, stable correlation, authorization, replay, cancellation, and idempotency.
  5. Remove ai, @ai-sdk/*, or eve only after no retained UI, transport, agent, or platform 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 real sandboxes accurately.

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