feat(integrations): add native Pydantic AI support

Merged
SH
6mo ago
+327-27

Summary

This PR R adds native Pydantic AI support to the SDK, parallel to the existing .openai() and .langchain() integrations. Users can now convert StackOne tools to pydantic_ai.tools.Tool instances with a single method call.

Context

Pydantic AI is removing its in-tree third-party integration in v2 see #5150, and the upstream PR #5175 that would have shipped StackOne support inside pydantic_ai.ext.stackone was closed by a maintainer with the recommendation that third-party adapters should live in separate packages. This PR delivers that native integration from the SDK side.

Usage

pip install 'stackone-ai[pydantic-ai]'

New optional extra pydantic-ai-slim>=1.83.0,<2.0.0. Lazy import; zero impact if the extra isn't installed.

Usage

Filtered via fetch_tools(...):

from pydantic_ai import Agent                                                  
from stackone_ai import StackOneToolSet               

toolset = StackOneToolSet()
tools = toolset.fetch_tools(
   actions=["workday_list_workers"],                                          
   account_ids=[account_id],
).to_pydantic_ai()                                                             
                                                     
agent = Agent("openai:gpt-5.4", tools=tools)                                   

Full catalog / meta-tools via the method on StackOneToolSet:

All tools for the account

tools = toolset.pydantic_ai(account_ids=[account_id]) 
                                                                               
# Agent-driven discovery (two meta-tools: tool_search + tool_execute)          
toolset = StackOneToolSet(                                                     
    search={"method": "semantic"},                                             
    execute={"account_ids": [account_id]},            
)                                                                              
tools = toolset.pydantic_ai(mode="search_and_execute")

Non-breaking : No existing signatures changed, no existing tests touched. Shape matches the .to_openai_function() / .to_openai() / .openai() trio already in the SDK.

Docs and Examples

There is separate PR for the docs that demonstrate the usage and examples updated with latest API


Summary by cubic

Adds native Pydantic AI support so StackOne tools can be used directly with Agent, parallel to .openai() and .langchain(). Opt‑in via stackone-ai[pydantic-ai]; non‑breaking.

  • New Features

    • Convert tools to Pydantic AI with .to_pydantic_ai() on Tools and .to_pydantic_ai_tool() on individual tools.
    • StackOneToolSet.pydantic_ai(mode=None|"search_and_execute", account_ids=...) for full catalogs or meta search/execute tools.
    • Improved type hints for Pydantic conversions and clearer import error when the extra isn’t installed.
    • README and example updated; tests added for schema parity, execution, and toolset wiring.
  • Dependencies

    • New optional extra pydantic-ai installs pydantic-ai-slim>=1.83.0,<2.0.0.
    • Lazy import; no impact unless the extra is installed.
    • Install with: pip install 'stackone-ai[pydantic-ai]'