Skip to content

feat(integrations): add native Pydantic AI support#184

Merged
shashi-stackone merged 3 commits into
mainfrom
pydantic-native
Apr 30, 2026
Merged

feat(integrations): add native Pydantic AI support#184
shashi-stackone merged 3 commits into
mainfrom
pydantic-native

Conversation

@shashi-stackone

@shashi-stackone shashi-stackone commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

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]'

Written for commit facd1c3. Summary will update on new commits. Review in cubic

Copilot AI review requested due to automatic review settings April 24, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a first-party Pydantic AI integration to the stackone-ai SDK, mirroring existing .openai() / .langchain() patterns so StackOne tools can be used as pydantic_ai.tools.Tool instances.

Changes:

  • Introduces StackOneTool.to_pydantic_ai_tool() and Tools.to_pydantic_ai() conversions.
  • Adds StackOneToolSet.pydantic_ai() for fetching full tools or meta “search_and_execute” tools as Pydantic AI tools.
  • Adds a pydantic-ai optional extra, plus tests, example usage, and README documentation.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
stackone_ai/models.py Adds to_pydantic_ai_tool() on StackOneTool and to_pydantic_ai() on Tools with lazy imports.
stackone_ai/toolset.py Adds StackOneToolSet.pydantic_ai() method parallel to .openai() / .langchain().
tests/test_integrations_pydantic_ai.py New test coverage for conversion helpers and toolset behavior (skips if dependency missing).
pyproject.toml Adds pydantic-ai optional extra (installs pydantic-ai-slim).
uv.lock Updates lockfile to include the new extra and dependency marker entries.
examples/pydantic_ai_integration.py Updates example to use the new .to_pydantic_ai() helper and improved install instructions.
README.md Documents the Pydantic AI integration and shows recommended usage.
Comments suppressed due to low confidence (1)

pyproject.toml:48

  • The optional dependency constraints are inconsistent: the new pydantic-ai extra pins pydantic-ai-slim>=1.83.0,<2.0.0, but the existing examples extra still depends on pydantic-ai>=1.83.0 with no <2.0.0 upper bound. This can lead to stackone-ai[examples] resolving to Pydantic AI v2 later and breaking the included example/tests. Consider either (a) switching examples to pydantic-ai-slim as well, or (b) adding a matching <2.0.0 upper bound to pydantic-ai in examples.
mcp = ["mcp>=1.3.0"]
pydantic-ai = ["pydantic-ai-slim>=1.83.0,<2.0.0"]
examples = [
  "crewai>=0.102.0",
  "langchain-openai>=1.1.14",
  "langgraph>=1.1.6",
  "openai>=2.32.0",
  "pydantic-ai>=1.83.0",
  "python-dotenv>=1.0.1",
]

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread stackone_ai/toolset.py Outdated
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Apr 24, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Auto-approved: Additive integration for Pydantic AI following established SDK patterns. Features lazy-loaded optional dependencies and comprehensive tests with no impact on core functionality.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Auto-approved: Adds native Pydantic AI integration following existing adapter patterns. The change is non-breaking, well-tested, and uses lazy imports for zero impact on existing users.

@shashi-stackone shashi-stackone merged commit 8216ab6 into main Apr 30, 2026
16 checks passed
@shashi-stackone shashi-stackone deleted the pydantic-native branch April 30, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants