feat(integrations): add native Pydantic AI support#184
Merged
Conversation
Contributor
There was a problem hiding this comment.
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()andTools.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-aioptional 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-aiextra pinspydantic-ai-slim>=1.83.0,<2.0.0, but the existingexamplesextra still depends onpydantic-ai>=1.83.0with no<2.0.0upper bound. This can lead tostackone-ai[examples]resolving to Pydantic AI v2 later and breaking the included example/tests. Consider either (a) switchingexamplestopydantic-ai-slimas well, or (b) adding a matching<2.0.0upper bound topydantic-aiinexamples.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 topydantic_ai.tools.Toolinstances 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.stackonewas 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(...):
Full catalog / meta-tools via the method on StackOneToolSet:
All tools for the account
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 viastackone-ai[pydantic-ai]; non‑breaking.New Features
.to_pydantic_ai()onToolsand.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.Dependencies
pydantic-aiinstallspydantic-ai-slim>=1.83.0,<2.0.0.Written for commit facd1c3. Summary will update on new commits. Review in cubic