Pydantic AI、エージェント連携ゲートウェイ「StackOne」を新機能として追加
本文の状態
日本語全文を表示中
詳細モードで約11分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
Pydantic Blog
Pydantic AI がエージェント統合ゲートウェイである StackOne を公式機能として採用し、開発者が単一の設定で数百の SaaS ツールへの安全な接続と操作を可能にする機能をリリースした。
Continue in AI NEW LAB
このニュースを、実務の判断につなげる
AI NEW LABで、試したことや先に確認したい条件を共有できます。まずはログインなしで読めます。
AI NEW LABで論点を見るAI深層分析を開く2026年8月14日 05:55
AI深層分析
キーポイント
StackOne の Pydantic AI ハーネス統合
Pydantic AI Harness に StackOne が公式機能として追加され、エージェントに「capability」として組み込むことで SaaS ツールとの連携が可能になる。
SaaS 統合の課題解決とアーキテクチャ
個別のエンドポイントごとの手動実装や、コンテキストウィンドウを圧迫する全機能リスト化という従来の課題に対し、ゲートウェイ型のアプローチで数千のアクションをシリアル化せずに提供できる。
アカウントスコープとセキュリティ
StackOne インスタンスは特定のユーザーアカウントにスコープされ、各エンドユーザーが認証したシステム(Workday や Salesforce など)へのアクセスを個別に管理する仕組みとなっている。
実装のための事前設定要件
利用には StackOne でのコネクタ設定とアカウントリンク、API キーの発行が必要であり、初回テストでは読み取り専用アクションのみを有効化することが推奨される。
検索実行と個別モードの設計
search_execute モードはアクション数が多くてもコンテキストコストを抑え、individual モードは少数のアクションで正確な選択が必要な場合に適している。
重要な引用
StackOne handles both. It is one gateway in front of hundreds of SaaS systems, with thousands of executable actions behind it.
A capability is a self-contained battery: tools, hooks, instructions, and settings bundled together.
Each StackOne instance is scoped to a StackOne linked account.
StackOne controls which actions are enabled for the linked account, and that configuration is the real boundary.
編集コメントを表示
編集コメント
Pydantic AI のエコシステムに StackOne が加わることで、エージェント開発における SaaS 接続の標準化がさらに進む。開発者は個別の API 実装に時間を割くことなく、ビジネスロジックの実装に集中できる環境が整ったと言える。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
AI エージェント向けの統合ゲートウェイ「StackOne」が、Pydantic AI Harness の機能として追加されました。エージェントの能力リストに StackOne(account_id=...) を追加するだけで、連携されたアカウント上のアクションを処理できるようになります。対象となるのは Workday、BambooHR、Salesforce、Zendesk など、StackOne コネクタカタログに登録されているあらゆるサービスです。
本稿では、この新機能が解決する課題と仕組み、そしてエージェントが記録システムへの書き込みを開始する前に必要な設定について解説します。
SaaS ツールにおける AI 統合の課題
自社のデータに関する質問に答えるためには、そのデータを保持しているシステムへアクセスできる必要があります。実際には主に 2 つの方法がありますが、それぞれにコストがかかります。
1 つ目は、各エンドポイントごとにツールを手書きで実装する方法です。例えば list_employees のラッパーをここに作成し、create_ticket のラッパーをそこに用意します。それぞれのツールには独自のアプローチによる認証処理やページネーションの癖があり、ベンダーが仕様を変更するたびにスキーマとの同期も必要になります。3 つや 4 つのプロバイダにわたってこれを行うと、統合コード自体がエージェントの規模を超えてしまいます。
2 つ目は、一見すると合理的な近道ですが、これも裏目に出ます。必要なアクションをすべてツールリストに追加してしまうと、モデルが決して呼び出さないスキーマのためにコンテキストウィンドウを浪費することになります。さらに、ツールリストが長くなるほど選択精度は低下します。
StackOne は両方の機能を扱います。これは数百の SaaS システムに接続するゲートウェイであり、その背後には数千もの実行可能なアクションが用意されています。また、検索と実行(Search & Execute)機能もゲートウェイ上で動作するため、このような大規模なカタログをプロンプトにシリアライズする必要はありません。Pydantic AI Harness における「キャパビリティ」は、エージェントがこのシステムへアクセスするための入り口であり、実装には単一行で済みます。
キャパビティとは何か
Pydantic AI Harness は、Pydantic AI の公式キャパビリティライブラリです。キャパビリティとは、ツール、フック、指示、設定がパッケージ化された自己完結型の機能ブロックであり、capabilities=[...] 配列を通じてエージェントに追加され、ライブラリ内の他のキャパビリティと組み合わせて使用できます。StackOne は、コード実行、メモリ管理、プランニング、ガードレールなどのキャパビリティの一つです。
エージェントは必要な数のアカウントを跨いで動作可能です。各 StackOne インスタンスは、特定の StackOne 連携アカウントにスコープが限定されます。これは、エンドユーザーが Workday や Salesforce、Zendesk といった基盤システムに対して認証された接続を行うことを意味します。
始め方
StackOne の機能を利用するには、stackone エクストラと、使用するモデルプロバイダーを指定してハネスを導入してください。また、spec エクストラは後述する YAML ベースのエージェント例に必要であり、logfire エクストラは各スニペット内のトレーシング呼び出しに対応しています。
uv add "pydantic-ai-harness[stackone]" "pydantic-ai-slim[openai,spec,logfire]"
StackOne を利用する前に、まず StackOne 上でコネクタを設定し、アカウントをリンクします。その後、ダッシュボードからリンクされたアカウント ID をコピーし、アクションを実行できる API キーを作成してください。最初のテストでは、必要な読み取り専用アクションのみを有効にしておくことをお勧めします。
export STACKONE_API_KEY='your-stackone-api-key'
export STACKONE_ACCOUNT_ID='your-linked-account-id'
export OPENAI_API_KEY='your-openai-api-key'StackOne は自動的に STACKONE_API_KEY を読み取ります。一方、アカウント ID はソースコードに含めないよう、以下の例では明示的に読み込んでいます。
import os
import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOne
logfire.configure()
logfire.instrument_pydantic_ai()
agent = Agent(
'openai:gpt-5',
capabilities=[
StackOne(account_id=os.environ['STACKONE_ACCOUNT_ID']),
],
)
result = agent.run_sync('List the first 5 employees')
print(result.output)これがセットアップのすべてです。デフォルトでは、モデルは 2 つのツールを受け取ります。1 つはリクエストに一致するアクションを検索するためのもの、もう 1 つはその検索結果から ID を特定して実行するためのものです。
アクションを公開する 2 つの方法
「検索→実行」というペア設計が興味深いポイントです。どちらのモードを選ぶかを決める前に、両方の仕組みを理解しておく価値があります。
- モード:モデルが受け取るもの / こんな時に使う
- search_execute:2 つのツール:アクションを検索し、ID を指定して実行する / アカウントで有効なアクションが多い場合。デフォルト設定です。
- individual:各有効なアクションごとに 1 つずつツールとスキーマが用意される / アクションを正確に選択したい場合や、ツールごとの挙動を制御したい場合に適しています。
search_execute モードでは、カタログをプロンプトにシリアライズするのではなくランタイムでクエリを実行するため、アカウントで有効化されているアクションの数に関わらず、コンテキストコストは一定に保たれます。検索ツールから返されるのはアクション ID であり、モデルが推測して生成すべきものではありません。
一方、individual モードでは選択されたスキーマをすべてモデルに送信します。これは対象となるアクションのセットが小さく、どのアクションが利用可能かを正確に把握したい場合に適しています。このモードでは actions パラメータでフィルタリングを行い、大文字小文字を区別しない fnmatch パターンを使用して、完全なツール名({connector}_{action}_{entity})に一致させることができます。
from pydantic_ai_harness.stackone import StackOne
StackOne(account_id='your-linked-account-id', actions=['*_list_*']) # All matching list tools
StackOne(account_id='your-linked-account-id', actions=['workday_get_worker']) # One exact tool
actions を指定すると、自動的に individual モードが選択されます。これに明示的に tool_mode='search_execute' を組み合わせるとエラーが発生します。これは、このモードでは検索と実行のツールのみが登録されるためです。
明確にしておくべき点があります:actions はアクセス制御ではなく、コンテキスト管理のための機能です。StackOne がリンクされたアカウントでどのアクションを有効にするかを決定し、これが実際の境界線となります。パターンリストはモデルが見る範囲を形作るための手段として扱い、権限の管理は StackOne ダッシュボードで行うべきです。
エージェントが必要になるまでツールをコンテキストから完全に除外したい場合は、ロードを遅延させることができます。
from pydantic_ai_harness.stackone import StackOne
StackOne(account_id='your-linked-account-id', defer_loading=True)
この機能はデフォルトで id='stackone' を使用するため、必要な時にロードできます。1 つのエージェントが複数の連携アカウントを管理する場合は、各インスタンスに固有の ID を付与してください。
書き込みを行う前に
エージェントが読み取りだけでなく書き込みも行うようになったら、2 つの設定が重要になります。
プロバイダーのアクションは大量のエクスポートデータを返す可能性があります。従業員リスト全体をそのまま取得すると、コンテキストウィンドウを圧迫してしまいます。ToolOutputLimits は、エージェント全体の過剰な戻り値を制限するもので、StackOne と他の機能と同様に組み合わせ可能です。
import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOne
from pydantic_ai_harness.tool_output_limits import ToolOutputLimits
logfire.configure()
logfire.instrument_pydantic_ai()
agent = Agent(
'openai:gpt-5',
capabilities=[
StackOne(account_id='your-linked-account-id'),
ToolOutputLimits(),
],
)承認機能はデフォルトでは有効になっていません。レコードシステムを変更する操作については、常に手動での承認をデフォルトとして設定すべきです。Pydantic AI のツール承認機能と組み合わせて、パブリックな StackOneToolset を使用します。
import os
import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOneToolset
logfire.configure()
logfire.instrument_pydantic_ai()
stackone_tools = StackOneToolset(
account_id=os.environ['STACKONE_ACCOUNT_ID'],
actions=['workday_create_employee'],
).approval_required()
agent = Agent('openai:gpt-5', toolsets=[stackone_tools])これにより、アプリケーションの承認を待機するリクエストが返され、モデルと書き込み処理の間に人間が介入できるようになります。StackOneToolset はより低レベルのエントリーポイントであり、能力のデフォルト設定ではなく、Agent(toolsets=[...]) や他のツールセットラッパーが必要となる場合に使用します。
YAML で定義する
この機能は Pydantic AI のエージェント仕様形式と連携するため、設定をコードの外に保存できます。キーはファイル内に記述せず、STACKONE_API_KEY 環境変数を使用してください:
# agent.yaml
model: openai:gpt-5
capabilities:
- StackOne:
account_id: 'your-linked-account-id'
actions: ['*_list_*']import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOne
logfire.configure()
logfire.instrument_pydantic_ai()
agent = Agent.from_file('agent.yaml', custom_capability_types=[StackOne])custom_capability_types を渡すことで、仕様ローダーが StackOne のインスタンス化方法を理解します。
この組み合わせが有効な理由
Pydantic AI は、型定義されたツール定義、検証済みの出力、そして Pydantic Logfire によるトレーシングなど、エージェントをデバッグ可能にする要素を提供します。一方、StackOne は接続インターフェースを担当するため、各ベンダーごとの HTTP 処理にビジネスロジックが埋もれるのを防ぎます。
この組み合わせの真価は、失敗したケースにおいて最も発揮されます。エージェントが誤ったアクションを選択した場合や、プロバイダーが先週とは異なる形式のペイロードを返した場合でも、トレーシングにより、検索されたアクション ID、実行内容、そして返却されたデータを確認できます。
本番環境へのデプロイ前に、いくつか注意すべき点があります。
Harness は 0.x ベースのバージョン管理を採用しているため、リリースごとに API が変更される可能性があります。実用的な場合は、破壊的変更に対して非推奨警告を併せて提供しています。
カスタム base_url や URL を値として持つクライアントには、必ず HTTPS を使用してください。
URL の値については、ツールセットが search_execute パスにおいて tool-mode クエリパラメータが存在しない場合に自動的に付加します。ただし、設定されたモードと URL に指定された tool-mode が競合する場合はエラーを返します。これは署名付き URL を書き換えると無効化されるためです。署名付き URL で search_execute を利用する場合は、署名前に tool-mode=search_execute を含めてください。
プレビルド済みクライアントはそのまま使用されるため、トランスポート、認証、アカウント選択、ツールモードの設定はユーザー自身で行う必要があります。
#Try it
StackOne でアカウントをリンクし、2 つの環境変数をエクスポートして、エージェントの機能に StackOne(account_id=...) を追加してください。その後、以下の手順を実行します。
StackOne の機能ドキュメントには、StackOne および StackOneToolset に関する完全な API リファレンスが記載されています。
Harness の概要ページでは、メモリ、プランニング、ガードレールなど、これと組み合わせて使用できる他の機能の一覧を確認できます。
すべての例で logfire.configure() が呼び出されます。これは Pydantic Logfire であり、各実行をツール検索、アクション呼び出し、リトライ、トークンコストなどのトレースに変換します。このトレースは SQL で照会可能で、Logfire の MCP サーバーを使用してデバッグすることもできます。
Pydantic AI の統合ドキュメントでは、アプリケーションの他の部分の設定方法についても解説しています。
エージェントが自律的に行動を選択する段階では、Pydantic Evals が役立ちます。これにより、あるワークフローを改善するためのプロンプト変更が、別のワークフローを静かに壊してしまうリスクを防げます。
これらはすべて、Pydantic Stack を構成する要素です。
原文を表示
StackOne, the integration gateway for AI agents, is now a capability in Pydantic AI Harness. Add StackOne(account_id=...) to an agent's capabilities list and it can work with the actions on a linked account: Workday, BambooHR, Salesforce, Zendesk, and the rest of the StackOne connector catalog.
This post covers the problem this new capability solves, how it works, and what to configure before an agent starts writing to a system of record.
#The AI integration problem with SaaS tools
An agent that answers questions about your company's data needs to reach the systems that hold it. In practice, there are two usual ways to do that, and each has a cost.
The first is to hand-write a tool per endpoint: a list_employees wrapper here, a create_ticket wrapper there, each with its own auth handling, its own pagination quirks, and its own schema to keep in sync when the vendor changes something. Do that across three or four providers and the integration code outgrows the agent.
The second is the obvious shortcut, and it backfires too: dump every action you might need into the tool list and you spend your context window on schemas the model will never call, while tool selection gets worse as the list grows.
StackOne handles both. It is one gateway in front of hundreds of SaaS systems, with thousands of executable actions behind it, and Search & Execute running on the gateway so a catalog that size never has to be serialized into a prompt. The capability in Pydantic AI Harness is the front door to it from an agent, and it is one line.
#What a capability is
Pydantic AI Harness is the official capability library for Pydantic AI. A capability is a self-contained battery: tools, hooks, instructions, and settings bundled together, added to an agent through the capabilities=[...] array, and composable with the other capabilities in the library. StackOne is one of those, alongside code execution, memory, planning, and guardrails.
An agent can work across as many accounts as it needs. Each StackOne instance is scoped to a StackOne linked account, meaning one end user's authenticated connection to one underlying system, whether that is their Workday, their Salesforce, or their Zendesk.
#Getting started
Install the harness with the stackone extra, plus the model provider you want. The spec extra covers the YAML agent example further down and logfire covers the tracing calls in every snippet:
uv add "pydantic-ai-harness[stackone]" "pydantic-ai-slim[openai,spec,logfire]"
Before the first run you need to configure a connector in StackOne, link an account, copy the linked account ID from the dashboard, and create an API key that can execute actions. For a first test, enable only the read actions you need.
export STACKONE_API_KEY='your-stackone-api-key'
export STACKONE_ACCOUNT_ID='your-linked-account-id'
export OPENAI_API_KEY='your-openai-api-key'
StackOne reads STACKONE_API_KEY on its own. The account ID is read explicitly in the example below so it stays out of the source:
import os
import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOne
logfire.configure()
logfire.instrument_pydantic_ai()
agent = Agent(
'openai:gpt-5',
capabilities=[
StackOne(account_id=os.environ['STACKONE_ACCOUNT_ID']),
],
)
result = agent.run_sync('List the first 5 employees')
print(result.output)
That is the whole setup. The model receives two tools by default: one to search for an action matching the request, one to execute the action it found by ID.
#Two ways to expose actions
The search-then-execute pair is the interesting design decision, so it is worth understanding both modes before you pick one.
Mode
What the model receives
Use it when
search_execute
Two tools: search for an action, then execute it by ID
The account has many enabled actions. This is the default.
individual
One tool and schema per enabled action
You need exact action selection or per-tool behavior.
search_execute keeps the context cost flat no matter how many actions the account has enabled, because the catalog is queried at runtime instead of being serialized into the prompt. Action IDs come back from the search tool and should not be guessed.
individual mode sends every selected schema to the model, which is what you want when the set is small and you care about exactly which actions are reachable. Filter it with actions, using fnmatch patterns that ignore case and match the full {connector}_{action}_{entity} tool name:
from pydantic_ai_harness.stackone import StackOne
StackOne(account_id='your-linked-account-id', actions=['*_list_*']) # All matching list tools
StackOne(account_id='your-linked-account-id', actions=['workday_get_worker']) # One exact tool
Passing actions selects individual mode for you. Combining it with an explicit tool_mode='search_execute' raises an error, because that mode only ever registers the search and execute tools.
One thing to be clear about: actions is a context-management tool, not an access control. StackOne controls which actions are enabled for the linked account, and that configuration is the real boundary. Treat the pattern list as a way to shape what the model sees, and the StackOne dashboard as the place where permissions live.
If you want the tools kept out of context entirely until the agent needs them, defer the load:
from pydantic_ai_harness.stackone import StackOne
StackOne(account_id='your-linked-account-id', defer_loading=True)
The capability uses id='stackone' by default so it can be loaded on demand. Give each instance a distinct id when one agent manages more than one linked account.
#Before you let it write
Two settings matter as soon as the agent does more than read.
Provider actions can return large exports, and a full employee list will happily eat a context window. ToolOutputLimits bounds oversized returns agent-wide, and composes with StackOne like any other capability:
import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOne
from pydantic_ai_harness.tool_output_limits import ToolOutputLimits
logfire.configure()
logfire.instrument_pydantic_ai()
agent = Agent(
'openai:gpt-5',
capabilities=[
StackOne(account_id='your-linked-account-id'),
ToolOutputLimits(),
],
)
Approval is not enabled automatically, and it should be your default for anything that mutates a system of record. Use the public StackOneToolset with Pydantic AI's tool approval:
import os
import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOneToolset
logfire.configure()
logfire.instrument_pydantic_ai()
stackone_tools = StackOneToolset(
account_id=os.environ['STACKONE_ACCOUNT_ID'],
actions=['workday_create_employee'],
).approval_required()
agent = Agent('openai:gpt-5', toolsets=[stackone_tools])
That returns deferred approval requests for your application to resolve, so a human sits between the model and the write. StackOneToolset is the lower-level entry point in general: reach for it when you need Agent(toolsets=[...]) or another toolset wrapper rather than the capability's defaults.
#Defining it in YAML
The capability works with Pydantic AI's agent spec format, so the configuration can live outside the code. Keep the key in STACKONE_API_KEY rather than in the file:
agent.yaml
model: openai:gpt-5
capabilities:
- StackOne:
account_id: 'your-linked-account-id'
actions: ['*_list_*']
import logfire
from pydantic_ai import Agent
from pydantic_ai_harness.stackone import StackOne
logfire.configure()
logfire.instrument_pydantic_ai()
agent = Agent.from_file('agent.yaml', custom_capability_types=[StackOne])
Pass custom_capability_types so the spec loader knows how to instantiate StackOne.
#Why this pairing works
Pydantic AI brings the parts that make an agent debuggable: typed tool definitions, validated outputs, and tracing through Pydantic Logfire. StackOne brings the connector surface, so the agent's business logic is not buried in HTTP plumbing per vendor.
The combination matters most in the failure cases. When an agent picks the wrong action, or a provider returns a payload shaped differently than last week, a trace shows you which action ID was searched, what was executed, and what came back.
A few caveats worth reading before you ship:
Harness uses 0.x versioning, so the API may change between releases. Breaking changes ship with a deprecation warning where that is practical.
Custom base_url and URL-valued client values must use HTTPS.
For URL values, the toolset appends the tool-mode query parameter when it is absent for the search_execute path. It raises an error when a URL's tool-mode conflicts with the configured mode, because rewriting it would invalidate a signed URL. If you use search_execute with a signed URL, include tool-mode=search_execute before signing.
Prebuilt clients are used as-is, so configure their transport, auth, account selection, and tool mode yourself.
#Try it
Link an account in StackOne, export the two environment variables, and add StackOne(account_id=...) to an agent's capabilities. Then:
The StackOne capability docs carry the full API reference for StackOne and StackOneToolset.
The Harness overview lists the other capabilities you can compose with it, including memory, planning, and guardrails.
All examples call logfire.configure(). That is Pydantic Logfire, and it turns each run into a trace you can open: tool searches, action calls, retries, and token costs, queryable with SQL. Try Logfire's MCP Server for debugging.
The Pydantic AI integration docs cover the setup for other parts of your application.
Pydantic Evals is what you want once the agent is choosing between actions on its own, so a prompt change that improves one workflow does not quietly break another.
Together, these are pieces of the Pydantic Stack.
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み