Skip to content

Commit 92abaf6

Browse files
committed
docs: add a 2.x to 3.0 migration guide
Covers every breaking change since 2.10.1 with before/after code: the removals in #199 (client-side search, SearchConfig and the semantic client, stackone_ai.integrations, the feedback tool, the mcp extra, Python 3.10) and those in this branch (MCP-only execution, the result shape, download links, ExecuteConfig, the header rule, get_tool() duplicates, the served required list and the served feedback tool). Linked from the README and shipped in the sdist.
1 parent 8d279b8 commit 92abaf6

3 files changed

Lines changed: 330 additions & 1 deletion

File tree

‎MIGRATION.md‎

Lines changed: 326 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,326 @@
1+
# Migrating from 2.x to 3.0
2+
3+
3.0 is a thin client over StackOne's MCP endpoint. Every tool call goes over MCP
4+
`tools/call`, and the only other request the SDK makes is `GET /accounts`, to find
5+
your linked accounts. Search runs on the server. Anything MCP does not support has
6+
been removed rather than kept on a second transport.
7+
8+
Work through the sections that apply to you. Each one gives the 2.x code and its 3.0
9+
replacement.
10+
11+
- [Installation](#installation)
12+
- [Imports](#imports)
13+
- [Search and execute](#search-and-execute)
14+
- [Results](#results)
15+
- [Tool arguments and headers](#tool-arguments-and-headers)
16+
- [Accounts](#accounts)
17+
- [Feedback](#feedback)
18+
- [Schemas given to a model](#schemas-given-to-a-model)
19+
- [Hand-built tools and `ExecuteConfig`](#hand-built-tools-and-executeconfig)
20+
- [LangGraph helpers](#langgraph-helpers)
21+
22+
## Installation
23+
24+
- **Python 3.11 or later** is required. 3.10 is no longer supported.
25+
- **`mcp` is a core dependency.** The `stackone-ai[mcp]` extra no longer exists.
26+
- **`langchain-core` is now optional.** `to_langchain()` and `toolset.langchain()`
27+
need the `langchain` extra and raise an `ImportError` that says so without it.
28+
- `bm25s` and `numpy` are no longer dependencies, because search now runs on the server.
29+
30+
```bash
31+
# 2.x
32+
uv add 'stackone-ai[mcp]'
33+
34+
# 3.0: add the extras for the frameworks you use
35+
uv add stackone-ai
36+
uv add 'stackone-ai[langchain]' # LangChain and LangGraph
37+
uv add 'stackone-ai[pydantic-ai]' # Pydantic AI
38+
```
39+
40+
## Imports
41+
42+
`stackone_ai.models` is split into `stackone_ai.tools` and `stackone_ai.types`. Anything
43+
public can also be imported from the package root.
44+
45+
```python
46+
# 2.x
47+
from stackone_ai.models import ExecuteConfig, StackOneTool, ToolParameters, Tools
48+
from stackone_ai.toolset import ToolsetConfigError
49+
50+
# 3.0
51+
from stackone_ai import ExecuteConfig, StackOneTool, ToolParameters, Tools, ToolsetConfigError
52+
```
53+
54+
`ToolsetError`, `ToolsetConfigError` and `ToolsetLoadError` now subclass `StackOneError`,
55+
so `except StackOneError` catches everything the SDK raises. Existing
56+
`except ToolsetError` clauses behave as before.
57+
58+
These names have been removed and have no direct replacement:
59+
60+
| Removed | Use instead |
61+
|---|---|
62+
| `SearchConfig`, `SearchMode`, `SearchTool`, `SemanticSearchClient`, `SemanticSearchResult`, `SemanticSearchResponse`, `SemanticSearchError` | `toolset.search()`. See [Search and execute](#search-and-execute) |
63+
| `stackone_ai.feedback`, `create_feedback_tool` | `toolset.submit_feedback()`. See [Feedback](#feedback) |
64+
| `stackone_ai.integrations` | LangGraph's own APIs. See [LangGraph helpers](#langgraph-helpers) |
65+
| `ToolDefinition` | `StackOneTool` fields: `name`, `description`, `parameters` |
66+
| `ParameterLocation`, `validate_method` | Nothing. `ExecuteConfig` no longer has a method or parameter locations |
67+
| `StackOneTool.connector`, `Tools.get_connectors()` | `tool.name.split("_")[0]` |
68+
69+
Some names were public on `main` for a while before 3.0 but never in a release:
70+
`StackOneRpcTool`, `MCP_PARAM_STYLE`, `is_json_content_type` and
71+
`filename_from_content_disposition`. They are gone as well.
72+
73+
## Search and execute
74+
75+
Client-side search is gone: the BM25/TF-IDF index, the semantic search client, the
76+
`search=` constructor argument, and the `tool_search`/`tool_execute` meta tools. The
77+
server's `*_search_actions` tool now does the search, and `toolset.execute()` runs an
78+
action by id through the server's `*_execute_action` tool.
79+
80+
```python
81+
# 2.x
82+
toolset = StackOneToolSet(search={"method": "auto"})
83+
tools = toolset.search_tools("list employees", top_k=5)
84+
result = tools[0].execute({"query_page_size": 25})
85+
86+
names = toolset.search_action_names("time off requests", top_k=5)
87+
88+
# 3.0
89+
toolset = StackOneToolSet()
90+
hits = toolset.search("list employees", top_k=5) # a list of action dicts, best first
91+
hit = hits[0]
92+
result = toolset.execute(
93+
hit["action_id"],
94+
{"query": {"page_size": 25}}, # the nested form in hit["input_schema"]
95+
session_id=hit.get("session_id"),
96+
)
97+
```
98+
99+
`toolset.execute()` has a new signature. It used to take a meta tool name, such as
100+
`"tool_execute"`, with arguments as a JSON string or a dict. It now takes
101+
`(action_id, arguments=None, *, account_ids=None, session_id=None)`, and `arguments`
102+
must be a dict. It raises instead of returning `{"error": ...}`: `ToolsetLoadError` when
103+
no linked connector matches the action, and `ToolsetConfigError` for bad arguments.
104+
105+
To give a model the search and execute tools, set the tool mode on the toolset.
106+
`openai()`, `langchain()` and `pydantic_ai()` no longer take `mode=`.
107+
108+
```python
109+
# 2.x
110+
toolset = StackOneToolSet(search={"method": "auto"})
111+
openai_tools = toolset.openai(mode="search_and_execute")
112+
# ...for each tool call the model makes:
113+
toolset.execute(call.function.name, call.function.arguments)
114+
115+
# 3.0: two tools per connector, served by the server
116+
toolset = StackOneToolSet(tool_mode="search_execute")
117+
tools = toolset.fetch_tools()
118+
openai_tools = tools.to_openai()
119+
# ...then run the model's tool calls and get the messages to send back:
120+
messages.extend(tools.execute_openai_tool_calls(message.tool_calls))
121+
```
122+
123+
`get_search_tool()` and `semantic_client` are removed. Call `toolset.search()` instead.
124+
125+
## Results
126+
127+
**Every tool returns the server's result as the server wrote it.** For an action,
128+
that is `{"isError": False, "result": ..., "defenderMetadata"?, "policyMetadata"?}`.
129+
Search results are bare JSON. This applies to `tool.execute()`, `tool.call()` and
130+
`toolset.execute()`.
131+
132+
```python
133+
tool = toolset.fetch_tools(account_ids=[account_id]).get_tool("hibob_list_employees")
134+
135+
# 2.x
136+
employees = tool.execute({})["data"]
137+
138+
# 3.0
139+
employees = tool.execute({})["result"]["data"]
140+
```
141+
142+
A result with `isError` set raises `StackOneAPIError`, which carries the status from the
143+
payload in `status_code` and the body in `response_body`.
144+
145+
**File actions return a download link, not bytes.** The SDK does not follow the link.
146+
When no link can be issued, the call raises `StackOneAPIError` with `status_code` 501.
147+
148+
```python
149+
# 2.x
150+
result = download.execute({"id": "file-id"})
151+
with open(result["file_name"] or "download.bin", "wb") as f:
152+
f.write(result["content"])
153+
154+
# 3.0
155+
from pathlib import Path
156+
157+
import httpx
158+
159+
link = download.execute({"id": "file-id"})["result"]
160+
# {"download_url": ..., "expires_at": ..., "file": {"name", "content_type", "content_length"}}
161+
name = Path(link["file"]["name"] or "download.bin").name # chosen by the provider: keep only the basename
162+
Path(name).write_bytes(httpx.get(link["download_url"]).content)
163+
```
164+
165+
## Tool arguments and headers
166+
167+
**Arguments are sent exactly as given**, as `tools/call` arguments. The SDK no longer
168+
splits flat `path_`/`query_`/`body_` keys into a request envelope, because the server
169+
maps them itself.
170+
171+
**`fetch_tools()` tools have the server's own argument shape.** In 2.x the SDK asked
172+
the server for the flat, prefixed style (`?param-style=flat_prefixed`). That request is
173+
gone, so the argument names are whatever the server serves. Read them from
174+
`tool.parameters.properties` rather than hard-coding them:
175+
176+
```python
177+
# 2.x
178+
tool.execute({"body_variables": {"first": 25}})
179+
180+
# 3.0: use the keys the schema names, for example
181+
print(tool.parameters.properties)
182+
tool.execute({"body": {"variables": {"first": 25}}})
183+
```
184+
185+
**Header arguments are allowlisted.** A header argument is an entry of a `headers`
186+
object argument, or a top-level `headers_<name>` argument. Each one is forwarded only
187+
if the tool's schema declares it in the same form: under `headers.properties`, or as a
188+
`headers_<name>` property. An open `headers` object, with no `properties`, declares every
189+
name. `Authorization`, `x-account-id` and `User-Agent` are never forwarded, even when
190+
declared, because the SDK sets them itself. Anything dropped is logged as a warning.
191+
192+
`*_execute_action` serves an open `headers` object, so `toolset.execute()` passes your
193+
own headers on to the action, with the exception of those three:
194+
195+
```python
196+
toolset.execute("linear_list_comments", {"headers": {"x-request-id": "abc"}})
197+
```
198+
199+
## Accounts
200+
201+
**With no account id, the SDK discovers your accounts.** In 2.x, calling
202+
`fetch_tools()` with no account listed tools without an `x-account-id`. In 3.0 it asks
203+
`GET /accounts` and lists the catalog of every active account. If you have many
204+
accounts, pass `account_id=`, `account_ids=` or call `set_accounts()` so the SDK does
205+
not fetch every catalog.
206+
207+
**`get_tool()` returns the first of any duplicates.** When two accounts serve the same
208+
tool name, `Tools.get_tool()` now returns the first one listed, where 2.x returned the
209+
last. Listings are merged in sorted account order, and a warning names the clashing
210+
tools. Pass `account_ids` to choose the account yourself.
211+
212+
## Feedback
213+
214+
The client-side `tool_feedback` tool, `create_feedback_tool()` and the implicit
215+
`feedback_*` execution options have been removed. `execute()` and `call()` no longer
216+
take `options=`.
217+
218+
```python
219+
# 2.x
220+
feedback_tool = toolset.fetch_tools(actions=["tool_*"]).get_tool("tool_feedback")
221+
feedback_tool.call(feedback="Worked well", account_id="acc_123", tool_names=["workday_list_workers"])
222+
tool.execute({"id": "1"}, options={"feedback_session_id": "chat-42"})
223+
224+
# 3.0
225+
hit = toolset.search("list workers")[0]
226+
toolset.execute(hit["action_id"], session_id=hit.get("session_id"))
227+
toolset.submit_feedback(
228+
"positive",
229+
[hit["action_id"]],
230+
feedback="Worked well",
231+
session_id=hit.get("session_id"),
232+
)
233+
```
234+
235+
When feedback is enabled for your project, the server also serves a
236+
`stackone_submit_feedback` tool. **`fetch_tools()`, `openai()`, `langchain()` and
237+
`pydantic_ai()` include it**, once, however many accounts are linked. If you don't want
238+
a model to call it, filter it out:
239+
240+
```python
241+
from stackone_ai import Tools
242+
243+
tools = Tools([t for t in toolset.fetch_tools() if t.name != "stackone_submit_feedback"])
244+
```
245+
246+
`submit_feedback()` raises `ToolsetLoadError` when feedback is not enabled.
247+
248+
## Schemas given to a model
249+
250+
**`to_openai_function()` passes the served schema through.** 2.x kept only `type`,
251+
`description`, `enum` and a shallow copy of `items`/`properties`. Now `format`,
252+
`pattern`, `default`, bounds, `oneOf`/`anyOf` and nested `required` reach the model as
253+
the server served them. `to_langchain()` and `to_pydantic_ai_tool()` hand over the
254+
same schema.
255+
256+
**`required` is the served list.** 2.x derived `required` from each property's
257+
internal `nullable` marker, which made every property of a hand-built tool with no
258+
markers required. 3.0 emits the schema's own `required` list, in the order the server
259+
sent it, and leaves it out when that list is missing or empty. Give a hand-built tool
260+
its `required` list directly:
261+
262+
```python
263+
# 2.x: required, because "nullable" is absent
264+
ToolParameters(type="object", properties={"id": {"type": "string"}})
265+
266+
# 3.0
267+
ToolParameters(type="object", properties={"id": {"type": "string"}}, required=["id"])
268+
```
269+
270+
## Hand-built tools and `ExecuteConfig`
271+
272+
**`StackOneTool` no longer makes HTTP requests.** Its `execute()` raises `StackOneError`
273+
on the base class, so a hand-built tool must override it. Tools from `fetch_tools()` are
274+
`StackOneMcpTool` instances, which execute over MCP. `_api_key` is now optional on the
275+
base class.
276+
277+
```python
278+
# 2.x
279+
tool = StackOneTool(
280+
description="Get an employee",
281+
parameters=ToolParameters(type="object", properties={"id": {"type": "string"}}),
282+
_execute_config=ExecuteConfig(
283+
name="get_employee", method="GET", url="https://api.example.com/employees/{id}",
284+
parameter_locations={"id": ParameterLocation.PATH},
285+
),
286+
_api_key="...",
287+
)
288+
289+
# 3.0
290+
class GetEmployee(StackOneTool):
291+
def execute(self, arguments=None):
292+
args = json.loads(arguments) if isinstance(arguments, str) else dict(arguments or {})
293+
return httpx.get(f"https://api.example.com/employees/{args['id']}").json()
294+
295+
tool = GetEmployee(
296+
description="Get an employee",
297+
parameters=ToolParameters(type="object", properties={"id": {"type": "string"}}, required=["id"]),
298+
_execute_config=ExecuteConfig(name="get_employee"),
299+
)
300+
```
301+
302+
**`ExecuteConfig` keeps only `name`, `headers` and `timeout`**, and rejects any other
303+
field. Passing `method`, `url`, `body_type` or `parameter_locations` raises a pydantic
304+
`ValidationError` rather than being silently ignored.
305+
306+
**`StackOneMcpTool(headers=...)` adds headers; it does not replace them.** The SDK
307+
always sets `Authorization`, `x-account-id` and `User-Agent` itself, after your headers,
308+
and drops any case variant of those names you pass. `headers` is optional.
309+
310+
## LangGraph helpers
311+
312+
`stackone_ai.integrations` has been removed. Pass the LangChain tools to LangGraph
313+
directly:
314+
315+
```python
316+
# 2.x
317+
from stackone_ai.integrations import to_tool_node
318+
node = to_tool_node(tools)
319+
320+
# 3.0
321+
from langgraph.prebuilt import ToolNode
322+
node = ToolNode(tools.to_langchain())
323+
```
324+
325+
See [examples/langgraph_integration.py](examples/langgraph_integration.py) for a
326+
complete agent.

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
StackOne AI provides a unified interface for accessing various SaaS tools through AI-friendly APIs.
1111

12+
> **Upgrading from 2.x?** 3.0 has breaking changes. See the
13+
> [migration guide](https://github.com/StackOneHQ/stackone-ai-python/blob/main/MIGRATION.md).
14+
1215
## Features
1316

1417
- **Search and execute**: find an action in natural language and run it, so a

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ packages = ["stackone_ai"]
3333
# The sdist carried the whole dev tree — uv.lock, pnpm-lock.yaml, CLAUDE.md, .github/
3434
# and the TypeScript mocks. A consumer building from source needs none of it.
3535
[tool.hatch.build.targets.sdist]
36-
include = ["stackone_ai", "README.md", "LICENSE", "CHANGELOG.md", "pyproject.toml"]
36+
include = ["stackone_ai", "README.md", "LICENSE", "CHANGELOG.md", "MIGRATION.md", "pyproject.toml"]
3737

3838
# Per-framework adapters. Each is imported lazily inside the method that needs
3939
# it, so installing the SDK does not drag in a framework you do not use.

0 commit comments

Comments
 (0)