|
12 | 12 | This is the primary method used when integrating with OpenAI, LangChain, or CrewAI. |
13 | 13 | The internal flow is: |
14 | 14 |
|
15 | | -:: |
16 | | -
|
17 | | - User query (e.g. "create an employee") |
18 | | - │ |
19 | | - ▼ |
20 | | - ┌─────────────────────────────────────────────────────┐ |
21 | | - │ Step 1: Fetch ALL tools from linked accounts via MCP │ |
22 | | - │ (uses account_ids to scope the request) │ |
23 | | - └────────────────────────┬────────────────────────────┘ |
24 | | - │ |
25 | | - ▼ |
26 | | - ┌─────────────────────────────────────────────────────┐ |
27 | | - │ Step 2: Extract available connectors from the │ |
28 | | - │ fetched tools (e.g. {bamboohr, hibob}) │ |
29 | | - └────────────────────────┬────────────────────────────┘ |
30 | | - │ |
31 | | - ▼ |
32 | | - ┌─────────────────────────────────────────────────────┐ |
33 | | - │ Step 3: Query the semantic search API (/actions/ │ |
34 | | - │ search) with the natural language query │ |
35 | | - └────────────────────────┬────────────────────────────┘ |
36 | | - │ |
37 | | - ▼ |
38 | | - ┌─────────────────────────────────────────────────────┐ |
39 | | - │ Step 4: Filter results — keep only connectors the │ |
40 | | - │ user has access to + apply min_score cutoff │ |
41 | | - │ │ |
42 | | - │ If not enough results, make per-connector │ |
43 | | - │ fallback queries for missing connectors │ |
44 | | - └────────────────────────┬────────────────────────────┘ |
45 | | - │ |
46 | | - ▼ |
47 | | - ┌─────────────────────────────────────────────────────┐ |
48 | | - │ Step 5: Deduplicate by normalized action name │ |
49 | | - │ (strips API version suffixes, keeps highest │ |
50 | | - │ scoring version of each action) │ |
51 | | - └────────────────────────┬────────────────────────────┘ |
52 | | - │ |
53 | | - ▼ |
54 | | - ┌─────────────────────────────────────────────────────┐ |
55 | | - │ Step 6: Match semantic results back to the fetched │ |
56 | | - │ tool definitions from Step 1 │ |
57 | | - │ Return Tools sorted by relevance score │ |
58 | | - └─────────────────────────────────────────────────────┘ |
59 | | -
|
60 | | -Key point: tools are fetched first, semantic search runs second, and only |
61 | | -tools that exist in the user's linked accounts AND match the semantic query |
62 | | -are returned. This prevents suggesting tools the user cannot execute. |
| 15 | +1. Fetch ALL tools from linked accounts via MCP (uses account_ids to scope the request) |
| 16 | +2. Extract available connectors from the fetched tools (e.g. {bamboohr, hibob}) |
| 17 | +3. Search EACH connector in parallel via the semantic search API (/actions/search) |
| 18 | +4. Collect results, sort by relevance score, apply top_k if specified |
| 19 | +5. Match semantic results back to the fetched tool definitions |
| 20 | +6. Return Tools sorted by relevance score |
| 21 | +
|
| 22 | +Key point: only the user's own connectors are searched — no wasted results |
| 23 | +from connectors the user doesn't have. Tools are fetched first, semantic |
| 24 | +search runs second, and only tools that exist in the user's linked |
| 25 | +accounts AND match the semantic query are returned. This prevents |
| 26 | +suggesting tools the user cannot execute. |
63 | 27 |
|
64 | 28 | If the semantic API is unavailable, the SDK falls back to a local |
65 | 29 | BM25 + TF-IDF hybrid search over the fetched tools (unless |
|
74 | 38 | definitions. This is useful for previewing results before committing |
75 | 39 | to a full fetch. |
76 | 40 |
|
77 | | -When ``account_ids`` are provided, tools are fetched only to determine |
78 | | -available connectors — results are then filtered to those connectors. |
79 | | -Without ``account_ids``, results come from the full StackOne catalog. |
| 41 | +When ``account_ids`` are provided, each connector is searched in |
| 42 | +parallel (same as ``search_tools``). Without ``account_ids``, results |
| 43 | +come from the full StackOne catalog. |
80 | 44 |
|
81 | 45 |
|
82 | 46 | 3. ``utility_tools(semantic_client=...)`` — Agent-loop search + execute |
|
0 commit comments