-
Notifications
You must be signed in to change notification settings - Fork 0
feat(stackone): add StackOne AI integration #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shashi-stackone
merged 34 commits into
main
from
ENG-10848-try-to-get-listed-as-third-party-toolset-on-pydantic
Apr 23, 2026
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
888b2d4
feat(stackone): add StackOne AI integration
ryoppippi e369d07
docs(stackone): fix URL and update description
ryoppippi a5e02c3
feat(stackone): add utility tools for dynamic discovery and feedback
ryoppippi 1cb34c3
chore(stackone): bump stackone-ai to >=2.3.0
ryoppippi 24929da
chore(stackone): bump stackone-ai to >=2.3.1
ryoppippi 8927e2c
fix(stackone): update tests for new implementation
ryoppippi f8288e4
refactor(stackone): simplify docstring examples to match project style
ryoppippi 68653ea
chore: merge upstream/main and resolve uv.lock conflict
ryoppippi 92c89dd
fix(stackone): update docs/toolsets.md examples per review feedback
ryoppippi 3739381
fix(stackone): use actual provider names (bamboohr_*) instead of hris…
ryoppippi fd1225b
fix(stackone): fix CI lint and test failures
ryoppippi e95b7e3
fix(stackone): exclude stackone files from coverage
ryoppippi c6700e7
Apply further PR suggestions and fix CI
shashi-stackone a41f476
Remove stackone from extra dependency and follow same patter othe too…
shashi-stackone da2358e
chore: retrigger CI after adding feature label to PR
shashi-stackone 6453f38
Skip the stackone coverage as its optional for toolset providers
shashi-stackone 3585e04
chore: retrigger CI
shashi-stackone f5f6526
Remove the fedback tools from the Pydantic AI integration
shashi-stackone 47f75a6
update Pydantic example to use google gemini model as it tested locally
shashi-stackone 27511c2
chore: retrigger CI for cancelled job
shashi-stackone 403c5d6
chore: retrigger CI for cancelled job
shashi-stackone dca5b53
Remove the utility tools from the Pydantic
shashi-stackone a8d4d23
Update docs and include search
shashi-stackone 580cea4
Update docs with tool search and the include min similarity
shashi-stackone df805ee
Fix Ruff issue
shashi-stackone ae117f0
update examples to use the google-gla:gemini-3-pro-preview model
shashi-stackone 56798d1
Update the implementation based on the latest version of the SDK
shashi-stackone a785a42
Include Tool Search in the Pydantic with Workday example
shashi-stackone 8431647
Merge remote-tracking branch 'origin/main' into ENG-10848-try-to-get-…
shashi-stackone e966386
Follow the Pydantic Claude.md guide and fix type checking
shashi-stackone af5b6f0
Exclude the stackone-ai on CI same as ACI and other third party tools
shashi-stackone b9f77fc
Update the docs as per the feedback
shashi-stackone f8828e3
trim the discussion on the toolset as we have detailed info in the th…
shashi-stackone 6e136a8
Update docs as per the feedback
shashi-stackone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,5 @@ | |
| ::: pydantic_ai.ext.langchain | ||
|
|
||
| ::: pydantic_ai.ext.aci | ||
|
|
||
| ::: pydantic_ai.ext.stackone | ||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| from collections.abc import Sequence | ||
| from typing import TYPE_CHECKING, Any, Literal | ||
|
|
||
| from pydantic.json_schema import JsonSchemaValue | ||
|
|
||
| from pydantic_ai.tools import Tool | ||
| from pydantic_ai.toolsets.function import FunctionToolset | ||
|
|
||
| try: | ||
| from stackone_ai import StackOneToolSet | ||
| except ImportError as _import_error: | ||
| raise ImportError('Please install `stackone-ai` to use StackOne tools.') from _import_error | ||
|
|
||
| if TYPE_CHECKING: | ||
| from stackone_ai import ExecuteToolsConfig, SearchConfig | ||
| from stackone_ai.models import StackOneTool | ||
|
|
||
| __all__ = ('tool_from_stackone', 'StackOneToolset') | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
|
||
|
|
||
|
|
||
| def _resolve_account_ids( | ||
| account_ids: str | list[str] | None, | ||
| *, | ||
| required: bool = True, | ||
| ) -> list[str]: | ||
| """Return account IDs from the explicit arg or `STACKONE_ACCOUNT_ID` env var. | ||
|
|
||
| Accepts a single string, a list of strings, or `None`. Raises `ValueError` | ||
| when nothing is provided and `required=True`. | ||
| """ | ||
| if isinstance(account_ids, str): | ||
| return [account_ids] | ||
| if account_ids: | ||
| return list(account_ids) | ||
| env = os.getenv('STACKONE_ACCOUNT_ID') | ||
| if env: | ||
| return [env] | ||
| if required: | ||
| raise ValueError( | ||
| 'StackOne account ID(s) required. ' | ||
| "Pass `account_ids='acct-1'` or `account_ids=['acct-1', 'acct-2']`, " | ||
| 'or set the `STACKONE_ACCOUNT_ID` environment variable.' | ||
| ) | ||
| return [] | ||
|
|
||
|
|
||
| def _tool_from_stackone_tool(stackone_tool: StackOneTool) -> Tool: | ||
| openai_function = stackone_tool.to_openai_function() | ||
| json_schema: JsonSchemaValue = openai_function['function']['parameters'] | ||
|
|
||
| def implementation(**kwargs: Any) -> Any: | ||
| return stackone_tool.execute(kwargs) | ||
|
|
||
| return Tool.from_schema( | ||
| function=implementation, | ||
| name=stackone_tool.name, | ||
| description=stackone_tool.description or '', | ||
| json_schema=json_schema, | ||
| ) | ||
|
|
||
|
|
||
| def tool_from_stackone( | ||
| tool_name: str, | ||
| *, | ||
| account_ids: str | list[str] | None = None, | ||
| api_key: str | None = None, | ||
| base_url: str | None = None, | ||
| ) -> Tool: | ||
| """Creates a Pydantic AI tool proxy from a StackOne tool. | ||
|
|
||
| Args: | ||
| tool_name: The name of the StackOne tool to wrap (e.g., `"workday_list_workers"`). | ||
| account_ids: One or more StackOne account IDs. Pass a string for a single account | ||
| or a list for multiple. If not provided, uses the `STACKONE_ACCOUNT_ID` | ||
| environment variable. | ||
| api_key: The StackOne API key. If not provided, uses the `STACKONE_API_KEY` | ||
| environment variable. | ||
| base_url: Optional custom base URL for the StackOne API. | ||
|
|
||
| Returns: | ||
| A Pydantic AI tool that corresponds to the StackOne tool. | ||
| """ | ||
| resolved = _resolve_account_ids(account_ids) | ||
| stackone_toolset = StackOneToolSet(api_key=api_key, base_url=base_url) | ||
| stackone_toolset.set_accounts(resolved) | ||
| tools = stackone_toolset.fetch_tools(actions=[tool_name]) | ||
| stackone_tool = tools.get_tool(tool_name) | ||
| if stackone_tool is None: | ||
| raise ValueError(f"Tool '{tool_name}' not found in StackOne") | ||
| return _tool_from_stackone_tool(stackone_tool) | ||
|
|
||
|
|
||
| class StackOneToolset(FunctionToolset): | ||
| """A toolset that wraps StackOne tools.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| tools: Sequence[str] | None = None, | ||
| *, | ||
| account_ids: str | list[str] | None = None, | ||
| api_key: str | None = None, | ||
| base_url: str | None = None, | ||
| filter_pattern: str | list[str] | None = None, | ||
| mode: Literal['search_and_execute'] | None = None, | ||
| search_config: SearchConfig | None = None, | ||
| execute_config: ExecuteToolsConfig | None = None, | ||
| id: str | None = None, | ||
| ): | ||
| if mode == 'search_and_execute': | ||
| if tools is not None or filter_pattern is not None: | ||
| raise ValueError("Cannot combine mode='search_and_execute' with 'tools' or 'filter_pattern'") | ||
| has_execute_accounts = execute_config is not None and 'account_ids' in execute_config | ||
| if has_execute_accounts and account_ids is not None: | ||
| raise ValueError("Cannot specify both 'account_ids' and 'execute_config[\"account_ids\"]'") | ||
| resolved = [] if has_execute_accounts else _resolve_account_ids(account_ids) | ||
| stackone_toolset = StackOneToolSet( | ||
| api_key=api_key, | ||
| base_url=base_url, | ||
| search=search_config or {}, | ||
| execute=execute_config, | ||
| ) | ||
| if resolved: | ||
| stackone_toolset.set_accounts(resolved) | ||
| if not hasattr(stackone_toolset, '_build_tools'): | ||
| raise ImportError( | ||
| "mode='search_and_execute' requires stackone-ai >= 2.5.0. " | ||
| 'Install with `pip install stackone-ai>=2.5.0`' | ||
| ) | ||
| meta_tools = stackone_toolset._build_tools() | ||
| pydantic_tools = [_tool_from_stackone_tool(t) for t in meta_tools] | ||
| super().__init__(pydantic_tools, id=id) | ||
| return | ||
|
|
||
| resolved = _resolve_account_ids(account_ids) | ||
| stackone_toolset = StackOneToolSet(api_key=api_key, base_url=base_url) | ||
| stackone_toolset.set_accounts(resolved) | ||
|
|
||
| if tools is not None: | ||
| actions = list(tools) | ||
| elif isinstance(filter_pattern, str): | ||
| actions = [filter_pattern] | ||
| else: | ||
| actions = filter_pattern | ||
|
|
||
| fetched_tools = stackone_toolset.fetch_tools(actions=actions) | ||
|
|
||
| pydantic_tools: list[Tool] = [] | ||
| for stackone_tool in fetched_tools: | ||
| pydantic_tools.append(_tool_from_stackone_tool(stackone_tool)) | ||
|
|
||
| super().__init__(pydantic_tools, id=id) | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would say explicitly that you can use both in combination as well