@introspection-ai/recipes 0.49.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/api/mcp.d.ts +1 -0
  2. package/dist/api/mcp.d.ts.map +1 -1
  3. package/dist/api/mcp.js +1 -0
  4. package/dist/api/mcp.js.map +1 -1
  5. package/dist/channels/tools.d.ts.map +1 -1
  6. package/dist/channels/tools.js +2 -17
  7. package/dist/channels/tools.js.map +1 -1
  8. package/dist/command-parameters.d.ts +10 -0
  9. package/dist/command-parameters.d.ts.map +1 -0
  10. package/dist/command-parameters.js +25 -0
  11. package/dist/command-parameters.js.map +1 -0
  12. package/dist/connector-tools.d.ts +1 -1
  13. package/dist/connector-tools.d.ts.map +1 -1
  14. package/dist/connector-tools.js +13 -5
  15. package/dist/connector-tools.js.map +1 -1
  16. package/dist/documents/module.d.ts.map +1 -1
  17. package/dist/documents/module.js +2 -4
  18. package/dist/documents/module.js.map +1 -1
  19. package/dist/documents/profile.d.ts +1 -1
  20. package/dist/documents/profile.js +1 -1
  21. package/dist/egress.d.ts +23 -0
  22. package/dist/egress.d.ts.map +1 -0
  23. package/dist/egress.js +36 -0
  24. package/dist/egress.js.map +1 -0
  25. package/dist/extensions.d.ts +1 -1
  26. package/dist/extensions.d.ts.map +1 -1
  27. package/dist/extensions.js +23 -2
  28. package/dist/extensions.js.map +1 -1
  29. package/dist/introspection-open.d.ts +46 -0
  30. package/dist/introspection-open.d.ts.map +1 -0
  31. package/dist/introspection-open.js +278 -0
  32. package/dist/introspection-open.js.map +1 -0
  33. package/dist/mcp/index.d.ts +37 -0
  34. package/dist/mcp/index.d.ts.map +1 -1
  35. package/dist/mcp/index.js +14 -4
  36. package/dist/mcp/index.js.map +1 -1
  37. package/dist/mcp/pi-client.d.ts +97 -0
  38. package/dist/mcp/pi-client.d.ts.map +1 -0
  39. package/dist/mcp/pi-client.js +342 -0
  40. package/dist/mcp/pi-client.js.map +1 -0
  41. package/dist/mcp/policy.d.ts +2 -0
  42. package/dist/mcp/policy.d.ts.map +1 -1
  43. package/dist/mcp/policy.js +6 -0
  44. package/dist/mcp/policy.js.map +1 -1
  45. package/dist/mcp-chunks/{chunk-3M4OCQR5.js → chunk-PO2SOBEN.js} +1 -0
  46. package/dist/mcp-daemon.js +1 -1
  47. package/dist/mcp-run-worker.js +1 -1
  48. package/dist/open.d.ts +82 -0
  49. package/dist/open.d.ts.map +1 -0
  50. package/dist/open.js +152 -0
  51. package/dist/open.js.map +1 -0
  52. package/dist/pi-extension.d.ts.map +1 -1
  53. package/dist/pi-extension.js +99 -8
  54. package/dist/pi-extension.js.map +1 -1
  55. package/dist/productivity/content.d.ts +25 -0
  56. package/dist/productivity/content.d.ts.map +1 -0
  57. package/dist/productivity/content.js +94 -0
  58. package/dist/productivity/content.js.map +1 -0
  59. package/dist/productivity/handles.d.ts +72 -0
  60. package/dist/productivity/handles.d.ts.map +1 -0
  61. package/dist/productivity/handles.js +111 -0
  62. package/dist/productivity/handles.js.map +1 -0
  63. package/dist/productivity/http.d.ts +35 -0
  64. package/dist/productivity/http.d.ts.map +1 -0
  65. package/dist/productivity/http.js +203 -0
  66. package/dist/productivity/http.js.map +1 -0
  67. package/dist/productivity/index.d.ts +11 -0
  68. package/dist/productivity/index.d.ts.map +1 -0
  69. package/dist/productivity/index.js +7 -0
  70. package/dist/productivity/index.js.map +1 -0
  71. package/dist/productivity/module.d.ts +63 -0
  72. package/dist/productivity/module.d.ts.map +1 -0
  73. package/dist/productivity/module.js +119 -0
  74. package/dist/productivity/module.js.map +1 -0
  75. package/dist/productivity/paging.d.ts +32 -0
  76. package/dist/productivity/paging.d.ts.map +1 -0
  77. package/dist/productivity/paging.js +42 -0
  78. package/dist/productivity/paging.js.map +1 -0
  79. package/dist/productivity/tools.d.ts +40 -0
  80. package/dist/productivity/tools.d.ts.map +1 -0
  81. package/dist/productivity/tools.js +969 -0
  82. package/dist/productivity/tools.js.map +1 -0
  83. package/dist/productivity/types.d.ts +538 -0
  84. package/dist/productivity/types.d.ts.map +1 -0
  85. package/dist/productivity/types.js +119 -0
  86. package/dist/productivity/types.js.map +1 -0
  87. package/dist/recipe/agent.d.ts +6 -1
  88. package/dist/recipe/agent.d.ts.map +1 -1
  89. package/dist/recipe/agent.js +48 -7
  90. package/dist/recipe/agent.js.map +1 -1
  91. package/dist/recipe/companions.d.ts +2 -1
  92. package/dist/recipe/companions.d.ts.map +1 -1
  93. package/dist/recipe/companions.js +14 -11
  94. package/dist/recipe/companions.js.map +1 -1
  95. package/dist/recipe/manifest.generated.d.ts +4 -1
  96. package/dist/recipe/manifest.generated.d.ts.map +1 -1
  97. package/dist/recipe/manifest.generated.js +5 -2
  98. package/dist/recipe/manifest.generated.js.map +1 -1
  99. package/dist/recipe/package.d.ts +12 -0
  100. package/dist/recipe/package.d.ts.map +1 -1
  101. package/dist/recipe/package.js +93 -0
  102. package/dist/recipe/package.js.map +1 -1
  103. package/dist/review.d.ts +1 -0
  104. package/dist/review.d.ts.map +1 -1
  105. package/dist/review.js +1 -0
  106. package/dist/review.js.map +1 -1
  107. package/dist/search/egress.d.ts +12 -0
  108. package/dist/search/egress.d.ts.map +1 -0
  109. package/dist/search/egress.js +24 -0
  110. package/dist/search/egress.js.map +1 -0
  111. package/dist/search/http.d.ts +16 -0
  112. package/dist/search/http.d.ts.map +1 -0
  113. package/dist/search/http.js +75 -0
  114. package/dist/search/http.js.map +1 -0
  115. package/dist/search/index.d.ts +9 -0
  116. package/dist/search/index.d.ts.map +1 -0
  117. package/dist/search/index.js +5 -0
  118. package/dist/search/index.js.map +1 -0
  119. package/dist/search/mcp.d.ts +58 -0
  120. package/dist/search/mcp.d.ts.map +1 -0
  121. package/dist/search/mcp.js +84 -0
  122. package/dist/search/mcp.js.map +1 -0
  123. package/dist/search/module.d.ts +16 -0
  124. package/dist/search/module.d.ts.map +1 -0
  125. package/dist/search/module.js +27 -0
  126. package/dist/search/module.js.map +1 -0
  127. package/dist/search/tool.d.ts +96 -0
  128. package/dist/search/tool.d.ts.map +1 -0
  129. package/dist/search/tool.js +505 -0
  130. package/dist/search/tool.js.map +1 -0
  131. package/dist/search/types.d.ts +247 -0
  132. package/dist/search/types.d.ts.map +1 -0
  133. package/dist/search/types.js +60 -0
  134. package/dist/search/types.js.map +1 -0
  135. package/dist/session.d.ts.map +1 -1
  136. package/dist/session.js +175 -15
  137. package/dist/session.js.map +1 -1
  138. package/dist/skill-progress.d.ts.map +1 -1
  139. package/dist/skill-progress.js +5 -1
  140. package/dist/skill-progress.js.map +1 -1
  141. package/dist/tool-search.d.ts +2 -2
  142. package/dist/tool-search.d.ts.map +1 -1
  143. package/dist/tool-search.js +4 -2
  144. package/dist/tool-search.js.map +1 -1
  145. package/docs/{index.md → README.md} +10 -3
  146. package/docs/{slack.md → channels/slack.md} +1 -1
  147. package/docs/{documents.md → documents/README.md} +4 -4
  148. package/docs/interactions.md +90 -31
  149. package/docs/mcp-configuration.md +77 -2
  150. package/docs/productivity/README.md +360 -0
  151. package/docs/productivity/google.md +226 -0
  152. package/docs/productivity/microsoft.md +143 -0
  153. package/docs/recipe-format.md +24 -3
  154. package/docs/search/README.md +801 -0
  155. package/package.json +19 -8
  156. package/skills/README.md +12 -0
  157. package/skills/productivity/SKILL.md +76 -0
  158. package/skills/search/SKILL.md +72 -0
  159. /package/docs/{channels.md → channels/README.md} +0 -0
  160. /package/{documents → skills/documents}/SKILL.md +0 -0
@@ -0,0 +1,801 @@
1
+ # Web search
2
+
3
+ `@introspection-ai/recipes/search` implements the
4
+ `web_search` tool and its provider contract; six providers (Tavily, Exa,
5
+ Brave, Keenable, Parallel, Perplexity) ship in the companion package
6
+ `@introspection-ai/recipe-search` ([Where things live](#where-things-live)). Tavily, Exa,
7
+ Keenable, Perplexity and Parallel call their hosted MCP servers, kept behind
8
+ `web_search` ([Declare the servers](#declare-the-servers)), through Pi's
9
+ built-in MCP client, and their REST APIs only as a fallback; Brave is REST
10
+ only. Tests run against local HTTP fakes, a fake Pi tool context, and a Recipe
11
+ session with a fake MCP server, each fake answering in the format the live
12
+ server or API returned ([Live checks](#live-checks)). Nothing registers the
13
+ tool yet: [Wiring](#wiring) says what a host does.
14
+ [Open questions](#open-questions) lists what needs a decision.
15
+
16
+ An agent searches the web with one tool, `web_search`, whatever provider
17
+ serves it. A call names the query and, when it wants to, the provider, a mode
18
+ and a few filters. Each provider maps those arguments to its own API under the
19
+ hood. The model reads compact text; the host and the trace get the structured
20
+ result, including the provider, mode and billed units of every call.
21
+
22
+ The same properties hold as for [channels](../channels/README.md),
23
+ [documents](../documents/README.md) and
24
+ [productivity](../productivity/README.md):
25
+
26
+ - **One vocabulary.** Every provider takes the same arguments with the same
27
+ meaning. A provider's own vocabulary (`search_depth`, `type`, goggles,
28
+ `source_policy`) never reaches the model or the Recipe.
29
+ - **What a provider cannot do is stated, not hidden.** Each provider exports a
30
+ capability descriptor saying, per argument, whether it serves it natively,
31
+ approximately or not at all. An argument a provider cannot serve is ignored
32
+ and the result says so in one line.
33
+ - **No credential in the Recipe.** The platform's egress holds each provider's
34
+ key and injects it on the way out ([Credentials](#credentials)).
35
+
36
+ ## The call
37
+
38
+ ```ts
39
+ web_search({
40
+ query: string;
41
+ provider?: "tavily" | "parallel" | "exa" | "keenable" | "perplexity" | "brave";
42
+ mode?: "fast" | "default" | "deep";
43
+ max_results?: number; // 1-10, default 5
44
+ freshness?: "day" | "week" | "month" | "year";
45
+ sites?: string[]; // "arxiv.org" restricts, "-pinterest.com" excludes
46
+ content?: "snippets" | "context"; // default snippets
47
+ country?: string; // ISO 3166-1 alpha-2, "US"
48
+ })
49
+ ```
50
+
51
+ | Argument | Meaning |
52
+ | --- | --- |
53
+ | `query` | What to search for. Parallel also receives it as its `objective`. |
54
+ | `provider` | Which bound provider serves this call. The schema lists only the providers bound to the runtime and leaves the argument out when exactly one is bound. Omitted with several bound, the call fails with `not_bound` and lists them. |
55
+ | `mode` | `fast`, `default` or `deep`: one scale for every provider. `default` is the provider's recommended setting. Each provider maps the three to its own setting ([Modes](#modes)); a provider with one setting maps all three to it and says so in a note. |
56
+ | `max_results` | At most 10 per call, by design: it keeps a response near 550 tokens. OpenRouter's web search allows 25; a Recipe option to raise the ceiling is possible but not built. A provider that returns fewer says so. |
57
+ | `freshness` | Pages from the last day, week, month or year. |
58
+ | `sites` | Domains, optionally with a path, to keep (`arxiv.org`) or drop (`-pinterest.com`). |
59
+ | `country` | Results for one country: an ISO 3166-1 alpha-2 code in upper case (`US`, `DE`). A code that is not an assigned country (`ZZ`, `EU`) fails with `invalid_request`. Each provider receives it in its own form ([Arguments by provider](#arguments-by-provider)). |
60
+ | `content` | `snippets`: about 300 characters per result. `context`: about 1,500 characters of query-relevant text extracted from each page, for grounding (Brave's LLM Context API, Exa's highlights, Tavily's chunks, Parallel's excerpts, Perplexity's page content, Keenable's longer snippets). |
61
+
62
+ Every call chooses its own provider and mode. A Recipe that wants a cheap
63
+ first pass and a thorough second one asks for `mode: "fast"` and then
64
+ `mode: "deep"`, or two providers, within one task. There is no Recipe
65
+ configuration: the providers offered are the providers bound to the runtime.
66
+
67
+ ### Result for the model
68
+
69
+ Compact text, not JSON:
70
+
71
+ ```text
72
+ [1] Agents that search — arxiv.org · 2026-10-02
73
+ https://arxiv.org/abs/2601.00001
74
+ Relevance-ranked text from the page, cut at the content level's length…
75
+
76
+ [2] Example post — example.com · 2026-11-01
77
+ https://www.example.com/post
78
+ An example…
79
+
80
+ (approximated: freshness — Exa filters on published date from the start of the window, so undated pages drop out.)
81
+ ```
82
+
83
+ A note line appears only when an argument was ignored or approximated. A
84
+ failure is one line: `web_search failed (too_many_requests): tavily answered
85
+ 429 … Retry after 30s.`, and the tool result's `details.error` carries the
86
+ same typed error, `{ code, message, status?, retry_after_seconds?, limit? }`:
87
+
88
+ | Code | When | What the model can do |
89
+ | --- | --- | --- |
90
+ | `not_bound` | No provider named when several are bound, or the one named is not bound | Name one of those the message lists |
91
+ | `not_configured` | No credential path for the provider, or it answered 401 or 403 | Use another provider, or say search is unavailable |
92
+ | `out_of_credit` | The provider answered 402: its account is out of credit (Parallel and Keenable document it) | Use another provider, or say search is unavailable |
93
+ | `invalid_request` | An argument fails the schema, or the provider answered 400 or 422 | Fix the argument |
94
+ | `query_too_long` | The query is longer than the provider accepts (`limit`), checked before calling it: Tavily 400 characters, Brave 400 characters and 50 words | Shorten the query |
95
+ | `max_uses_exceeded` | The task has made as many calls as the Recipe allows (`limit`) | Work with the results it has |
96
+ | `too_many_requests` | The provider answered 429; `retry_after_seconds` from `Retry-After`, in seconds or as a date | Wait, or use another provider |
97
+ | `unavailable` | The provider could not be reached or answered 5xx | Retry later or use another provider |
98
+ | `provider_error` | Anything else | Report it |
99
+
100
+ ### Search budget
101
+
102
+ A Recipe caps how many calls one task may make with `maxUses` on
103
+ `createWebSearch` or `registerWebSearchTool` (the host creates one per task
104
+ session). It is not a model argument. A call past the cap fails with
105
+ `max_uses_exceeded` and the limit, before any provider request; a call refused
106
+ earlier (unbound provider, invalid argument, query too long) does not count.
107
+ Unset, there is no cap: the default is none, because a sensible number depends
108
+ on the Recipe, and the platform's per-call pricing is where cost is governed.
109
+
110
+ This mirrors `max_uses` on OpenRouter's web-search server tool. OpenRouter
111
+ also caps `max_total_results` per request; the same cap here would be a
112
+ Recipe option beside `maxUses` (never a model argument) that lowers each
113
+ call's `max_results` to what is left and refuses once none is. It is not
114
+ built: per-result prices apply only beyond each provider's included 10, which
115
+ `max_results` never exceeds.
116
+
117
+ ### Result for the host and the trace
118
+
119
+ The tool result's `details`, and the return value for Recipe code, is a
120
+ `WebSearchResult`:
121
+
122
+ ```ts
123
+ {
124
+ results: Array<{ url, title?, snippet?, published_at?, score?, site? }>;
125
+ provider: "tavily";
126
+ mode: "deep";
127
+ setting: "advanced"; // the provider's own setting that ran, or null
128
+ transport: "mcp"; // the provider's MCP server, or "rest"
129
+ content: "context"; // what was served, after any downgrade
130
+ notes: Array<{ option, outcome: "ignored" | "approximated", detail }>;
131
+ usage: { requests: 1, units?: { name: "credits", count: 2 } };
132
+ }
133
+ ```
134
+
135
+ `setting` is what ran, which is the mode's setting unless an MCP tool cannot
136
+ run it: Exa's `web_search_exa` always runs `auto`, and its advanced tool has
137
+ no `deep`, so a call there records `auto` beside the `mode` it asked for, with
138
+ an `approximated` note. Parallel's MCP tool takes no mode and its answer does
139
+ not say which ran, so `setting` is `null` and no setting is recorded or
140
+ priced.
141
+
142
+ Each call records a `web_search` span with `search.provider`, `search.mode`,
143
+ `search.setting` (left out when `null`), `search.transport`, `search.content`, `search.results`,
144
+ `search.requests`, `search.units.name` and `search.units.count` when the
145
+ provider reports them, and `search.notes`. A call over MCP adds a child client
146
+ span, `tools/call <tool>`, with `mcp.method.name`, `gen_ai.tool.name` and
147
+ `search.mcp.server`, as the Google productivity provider (PR #457) records
148
+ its MCP calls; an `isError` result sets `error.type` to `tool_error`. A
149
+ failed call sets `error.type` to the error code. Cost
150
+ per provider and mode is therefore a query over spans. The span does not carry
151
+ the query, which can hold personal data.
152
+
153
+ A successful call also records the platform's standard usage record:
154
+ `introspection.usage.service` (`<provider>/search`), `.unit` (`credit` when
155
+ the provider reported credits, Tavily's and Keenable's over REST, else
156
+ `request`), `.quantity`, `.variant` (the `search.setting`, left out when it is
157
+ `null`), `.results` (results returned, for providers that price results beyond
158
+ an allowance), `.cost_usd` (Exa's reported dollars, over REST and over its
159
+ advanced MCP tool) and `.key_owner`
160
+ (`customer`, since a project endpoint holds the key). The platform prices it
161
+ against its vendor rate catalog, `services/<vendor>.yaml` in
162
+ introspection-cloud ([service-rates.md](https://github.com/introspection-org/introspection-cloud/blob/claude/service-rates/docs/design/service-rates.md));
163
+ `search.units.*` stays as the provider's own unit.
164
+
165
+ ### Recipe code
166
+
167
+ Recipe code calls the same function with the same arguments:
168
+
169
+ ```ts
170
+ import {
171
+ createWebSearch,
172
+ loadSearchProviders,
173
+ } from "@introspection-ai/recipes/search";
174
+
175
+ const providers = await loadSearchProviders({ recipeDir });
176
+ const search = createWebSearch({ providers, bound: ["tavily", "brave"] });
177
+ const { results } = await search({
178
+ query: "…",
179
+ provider: "tavily",
180
+ mode: "deep",
181
+ });
182
+ ```
183
+
184
+ A host that registers the tool returns the same function from
185
+ `registerWebSearchTool`, so an extension can share it. Calling the function
186
+ from Recipe code reaches providers over REST; MCP servers are reached
187
+ through the `web_search` tool.
188
+
189
+ ## Providers
190
+
191
+ Researched from each provider's official SDK source, API reference or
192
+ published skill, and checked against the live API where this session could
193
+ reach it ([Live checks](#live-checks)). Prices are list prices as last known
194
+ and must be checked before they are relied on; nothing in the tool depends on
195
+ them.
196
+
197
+ | Provider | Endpoint | Credential header | Quality knob | Content | Filters | Max results | Billing | Sources |
198
+ | --- | --- | --- | --- | --- | --- | --- | --- | --- |
199
+ | Tavily | `POST https://api.tavily.com/search` | `Authorization: Bearer` | `search_depth`: `ultra-fast`, `fast`, `basic`, `advanced` | `content` per result; `chunks_per_source` 1-3 (advanced only); `include_raw_content`; `include_answer` | `time_range`, `start_date`/`end_date`, `include_domains`/`exclude_domains`, `topic` (general, news, finance), `country`, `exact_match` | 20 | Credits: 1 per basic, fast or ultra-fast search, 2 per advanced; `include_usage` reports them | [API reference](https://docs.tavily.com/documentation/api-reference/endpoint/search), [credits](https://docs.tavily.com/documentation/api-credits), [tavily-js](https://github.com/tavily-ai/tavily-js) |
200
+ | Exa | `POST https://api.exa.ai/search` | `x-api-key` | `type`: `auto` (recommended), `lite` (beta), `fast` and `instant` (legacy), `neural`, `keyword`, `deep-lite`, `deep`, `deep-reasoning` | `contents.highlights` (query-relevant extracts), `contents.text`, `contents.summary` | `startPublishedDate`/`endPublishedDate`, `includeDomains`/`excludeDomains`, `category`, `userLocation`, `includeText`/`excludeText` | 100 | Dollars per request by type and contents; the response's `costDollars` reports them | [Search reference](https://docs.exa.ai/reference/search), [exa-js](https://github.com/exa-labs/exa-js) |
201
+ | Parallel | `POST https://api.parallel.ai/v1/search` | `x-api-key` | `mode`: `turbo`, `fast`, `basic`, `advanced` (the default when omitted) | `excerpts` per result (markdown); `advanced_settings.excerpt_settings.max_chars_per_result`, `max_chars_total` | `objective` and `search_queries` (at least one, 3-6 words each); in `advanced_settings`: `source_policy` (`include_domains`, which when set makes `exclude_domains` ignored; `exclude_domains`; `after_date`), `location` (ISO 3166-1 alpha-2, lower case), `fetch_policy`. Unknown fields answer 422 | `advanced_settings.max_results`, default 10 | Per request; the response's `usage` lists SKUs (`sku_search`, …) and counts; `402` means the account is out of credit | [Search API reference](https://docs.parallel.ai/api-reference/search-beta/search), [parallel-sdk-typescript](https://github.com/parallel-web/parallel-sdk-typescript) |
202
+ | Perplexity | `POST https://api.perplexity.ai/search` (the Search API, not Sonar's chat completions) | `Authorization: Bearer` | `search_type`: `web` (default), `fast` | `snippet` per result; `max_tokens_per_page`, `max_tokens` | `search_recency_filter` (hour to year), `search_after_date_filter`/`search_before_date_filter`, `search_domain_filter` (`-` prefix denies), `country`, `search_language_filter`, `search_mode` (web, academic, sec) | 20 | Per request | [perplexity-node](https://github.com/perplexityai/perplexity-node) (`src/generated/api.ts`), [modelcontextprotocol](https://github.com/perplexityai/modelcontextprotocol) (`src/server.ts`) |
203
+ | Keenable | `POST https://api.keenable.ai/v1/search` (keyless `/v1/search/public` with an `X-Keenable-Title` header) | `X-API-Key` | `mode`: `realtime` (fastest), `pro` (the default) | `snippet` (`snippet_max_length` 180-10,000 characters), `description`; page text through `fetch_page_content` | `site` (one domain), `published_after`/`published_before` and `acquired_after`/`acquired_before` (a date, a timestamp or an offset such as `7d`), `query_time` | 50 | Credits: 1 per `realtime` or `pro` search, in the response's `usage` (`sku`, `amount`, `credits`, `paid`); $4 per 1,000 requests (confirmed by Introspection); `402` means out of credits | [keenable.ai](https://keenable.ai), the live API and MCP server |
204
+ | Brave | `GET https://api.search.brave.com/res/v1/web/search` and `GET …/res/v1/llm/context` | `X-Subscription-Token` | none | Web Search: `description`, `extra_snippets` (up to 5). LLM Context: extracted `snippets` per URL, bounded by `maximum_number_of_tokens(_per_url)` and `maximum_number_of_snippets(_per_url)` | `freshness` (`pd`, `pw`, `pm`, `py` or a date range), Goggles (inline `$discard`, `$site=`), `country`, `search_lang`, `safesearch`, `context_threshold_mode` | Web Search 20, LLM Context 50 | Both on the Search plan; $5 of monthly credit covers about 1,000 requests | [LLM Context](https://api-dashboard.search.brave.com/app/documentation/llm-context/get-started), [brave-search-skills](https://github.com/brave/brave-search-skills) |
205
+
206
+ **Rate limits** are per plan for every provider and none was confirmed from a
207
+ reachable source. All answer `429` when exceeded; when the answer carries
208
+ `Retry-After`, the tool passes it to the model as a retry delay. Parallel's
209
+ anonymous MCP tier is rate-limited by the `session_id` each call sends: one
210
+ random id per `createWebSearch`, so per task, never the task id.
211
+
212
+ ## MCP servers
213
+
214
+ Where a provider runs a hosted MCP server, `web_search` calls the server's
215
+ search tool and falls back to the REST API only for what the tool cannot
216
+ express. MCP first is decided for Tavily, Exa, Keenable, Perplexity and
217
+ Parallel. Each server's `tools/list` and one call were run live, except
218
+ Perplexity's, which needs a key this session did not have; its row is from the
219
+ server's source ([perplexityai/modelcontextprotocol](https://github.com/perplexityai/modelcontextprotocol)
220
+ `src/server.ts`, 1.4.0).
221
+
222
+ | Provider | Server | Auth | Search tool and its arguments | Cannot express | Result | Choice |
223
+ | --- | --- | --- | --- | --- | --- | --- |
224
+ | Tavily | `https://mcp.tavily.com/mcp/` (tavily-mcp 4.1.5) | `Authorization: Bearer <key>`; also `?tavilyApiKey=` and OAuth | `tavily_search`: `query`, `search_depth` (`basic`, `advanced`, `fast`, `ultra-fast`), `topic`, `time_range`, `start_date`/`end_date`, `max_results`, `include_domains`/`exclude_domains`, `country` (a country name; boosts rather than filters), `include_raw_content`, `include_published_date`, `filter_by_published_date`, `exact_match`, images and favicon. No other property is accepted | `chunks_per_source`, so `content: "context"` in `deep`; credits | `structuredContent` and the same JSON as text: `results[]` with `url`, `title`, `content`, `score`, `id`, and `published_date` when `include_published_date` is set; `response_time`, `request_id`. No credits | MCP; REST for `context` in `deep` |
225
+ | Exa | `https://mcp.exa.ai/mcp` (exa-search-server 3.5.0) | `x-api-key` or `Authorization: Bearer`; also `?exaApiKey=` and OAuth | Default `web_search_exa`: `query`, `numResults` only (type `auto`, highlights fixed). Opt-in `web_search_advanced_exa` (`?tools=web_search_advanced_exa,web_search_exa` on the URL): `type` (`auto`, `lite`, `fast`, `instant`: no `deep`), `numResults`, `includeDomains`/`excludeDomains`, `startPublishedDate`/`endPublishedDate`, `userLocation`, `enableHighlights`, `highlightsMaxCharacters`, `textMaxCharacters`, `contextMaxCharacters`, `category`, `maxAgeHours` (cache age, not freshness), and more | Default tool: `mode` other than `default`, `freshness`, `sites`, `country`. Advanced tool: `mode: "deep"` | Default: text with `Title:`, `URL:`, `Published:`, `Author:`, `Highlights:`. Advanced: the API's JSON as text, no `structuredContent`: `results[]` (`id`, `url`, `title`, `publishedDate`, `highlights`; the whole page as `text` unless highlights or a text limit are set), `costDollars` | MCP, advanced tool first; REST for `deep`, and when only the default tool is offered and the call filters |
226
+ | Keenable | `https://api.keenable.ai/mcp` (keenable-mcp-server 0.2.1) | `X-API-Key`; answers without a key at lower limits | `search_web_pages`: `query`, `mode` (`realtime`, `pro`), `max_results` (1-50), `snippet_max_length` (180-10,000), `site`, `published_after`/`published_before`, `acquired_after`/`acquired_before`, `query_time`, `output_format` (`text`, `json`), `session_id`, `disable_cards`. Also `fetch_page_content` | `exclude_sites`, `country`, more than one site | With `output_format: "json"`, the REST response as text (`results[]` with `title`, `url`, `description`, `snippet`, `published_at` when known, `acquired_at`), without `usage`; the credits travel in the result's `_meta` (`keenable/usage`), which Pi's client drops | MCP |
227
+ | Perplexity | `https://api.perplexity.ai/mcp` | `Authorization: Bearer <key>` | `perplexity_search`: `query`, `max_results` (1-20), `max_tokens_per_page` (256-2048), `country` (ISO alpha-2), `search_recency_filter`, `search_domain_filter` (`-` prefix denies), `search_type` (`web`, `fast`) | Nothing we send | Formatted text, `structuredContent` `{ results: <the same text> }`: `N. **title**`, then indented `URL:`, snippet, `Date:`, `Last updated:` | MCP |
228
+ | Parallel | `https://search.parallel.ai/mcp`; `search-mcp.parallel.ai` answers 401 to every call | `Authorization: Bearer <key>`; anonymous at free-tier limits, rate-limited by `session_id`. A key it does not recognize answers 401, so an anonymous call sends no key header | `web_search`: `objective`, `search_queries` (3-6 words each; `site:` with a bare domain, never a path or quoted phrase), `session_id`, `model_name`. Also `web_fetch` | `mode`, `freshness`, `country`; a result count (it returns about 10) | `structuredContent` and the same JSON as text: `search_id`, `results[]` (`url`, `title`, `publish_date` or null, `excerpts[]`, about 2,400 characters each), `warnings`, `metadata` (null), `session_id`. No mode, usage or cost | MCP; REST for `fast`, `freshness` and `country` |
229
+ | Brave | **Local only**: `@brave/brave-search-mcp-server`, stdio or a self-run HTTP server ([brave-search-mcp-server](https://github.com/brave/brave-search-mcp-server)) | `BRAVE_API_KEY` in the server's environment | `brave_web_search`, `brave_llm_context`, … | n/a | n/a | REST: a local server would need the key in the sandbox, or a placeholder the egress swaps, and adds a process for the same request |
230
+
231
+ Notes:
232
+
233
+ - **Tavily's MCP result carries scores and, asked, dates.** The adapter sends
234
+ `include_published_date: true`. It reads `structuredContent`, then the
235
+ JSON text, then the older `Title:`/`URL:`/`Content:` text format. Credits
236
+ are not reported, so the usage record counts one request.
237
+ - **Exa needs its advanced tool listed.** The binding's URL names the tools
238
+ (`?tools=web_search_advanced_exa,web_search_exa`); without the advanced
239
+ tool, a call that filters goes to REST, or, with no REST endpoint, runs on
240
+ the default tool with a note for each argument it dropped. The adapter
241
+ always sets `enableHighlights` and `highlightsMaxCharacters`, so the tool
242
+ never returns whole pages.
243
+ - **Keenable's MCP tool is asked for JSON**, and a text answer fails as
244
+ `provider_error`. Over MCP its credits are not seen; Keenable bills one
245
+ credit per search either way, so the usage record's one request matches.
246
+ - **Parallel's MCP tool takes only queries.** The adapter sends the query as
247
+ the `objective` and its first six words as the keyword query, one per
248
+ included domain with `site:` (up to five), and filters the results to the
249
+ included and excluded sites itself, by Parallel's own matching rule (a
250
+ domain covers its subdomains, a path matches at segment boundaries). It
251
+ cannot set a mode, a date or a country, so those go to REST when REST is
252
+ bound, and are noted otherwise.
253
+ - **A hosted server's tool names are the server's**, so each adapter lists
254
+ the tools it may call, and `web_search` calls only a tool the bound server
255
+ offers.
256
+
257
+ ## MCP transport
258
+
259
+ Inside the tool, a provider's MCP path sits behind one small internal
260
+ interface:
261
+
262
+ ```ts
263
+ interface SearchMcpClient {
264
+ hasTool(server: string, tool: string): boolean;
265
+ callTool(
266
+ server: string,
267
+ tool: string,
268
+ args: Record<string, unknown>,
269
+ signal?: AbortSignal,
270
+ ): Promise<McpCallToolResult>; // content, structuredContent, isError
271
+ }
272
+ ```
273
+
274
+ A provider adds an optional `mcp` adapter beside its REST `search`: the hosted
275
+ URL and credential header (for docs and bindings), the tools it may call, a
276
+ `plan(request, hasTool, now)` that maps the normalized request onto one tool's
277
+ arguments, lists what that tool cannot express and, when the tool runs a
278
+ setting other than the mode's, says which (`setting`, or `null` when the
279
+ server does not report it), and a `parse(result)` that maps the tool's answer
280
+ onto the same results REST returns. The host chooses:
281
+
282
+ 1. If the provider's MCP server is bound, the call comes through the
283
+ `web_search` tool (which carries Pi's MCP client), and
284
+ the server offers one of the adapter's tools: MCP, unless the tool cannot
285
+ express an argument **and** the REST API is bound too, in which case REST.
286
+ 2. With MCP chosen and something it cannot express, each dropped argument is
287
+ an `ignored` note, and a mode it cannot run an `approximated` one naming
288
+ the setting that ran.
289
+ 3. Otherwise REST, through the egress as before. A provider bound only as an
290
+ MCP server fails with `not_bound` when its tool is missing, or when Recipe
291
+ code calls the function directly.
292
+
293
+ ### Pi's built-in MCP client
294
+
295
+ Pi ships an MCP client (`createMcpExtension`, `pi.registerMcpServer`,
296
+ Streamable HTTP and stdio). Its tools are Pi tools named
297
+ `mcpToolName(server, tool)` (`@introspection-ai/recipes/mcp`), exposed to the
298
+ model directly, through `codemode`, deferred or hidden. An extension tool
299
+ calls one with `ctx.executeTool(name, args)`, which runs it through the same
300
+ validation, hooks and permission checks as a model's call and returns the
301
+ whole MCP `CallToolResult` as the nested result's `structuredContent`. A
302
+ tool's `reachesTools` makes such a call wait for a server still connecting.
303
+
304
+ A Recipe's server runs on that client under `mcp.mode: codemode`, and in
305
+ every mode when it is kept `behind` a tool
306
+ ([MCP configuration](../mcp-configuration.md#keep-a-server-behind-a-tool)),
307
+ which is how `web_search` uses it.
308
+
309
+ The tool backs the interface with exactly that.
310
+ `hasTool` looks for `mcpToolName(server, tool)` in `ctx.tools` and, given
311
+ `toolInfos` (the extension's `pi.getAllTools`), takes it as the server's only
312
+ when Pi's namespace for the tool is the server's (`isPiMcpServerTool`), since
313
+ Pi hashes long names and may hash two that collide. `callTool` is
314
+ `ctx.executeTool(mcpToolName(server, tool), args)`, reading the
315
+ `CallToolResult` back from `structuredContent`; a call Pi refuses (an unknown
316
+ or blocked tool) has none and fails as `unavailable`. `registerWebSearchTool`
317
+ builds it from each call's context and declares `reachesTools` with the MCP
318
+ tools it may call.
319
+
320
+ ### Declare the servers
321
+
322
+ A Recipe declares each provider's server in `package.json` and keeps it behind
323
+ `web_search` in the agent file, in any `mcp.mode`:
324
+
325
+ ```yaml
326
+ tools: [web_search]
327
+ mcp:
328
+ mode: tools # or cli, or codemode
329
+ servers:
330
+ tavily:
331
+ include: [tavily_search]
332
+ behind: [web_search]
333
+ exa:
334
+ include: [web_search_advanced_exa, web_search_exa]
335
+ behind: [web_search]
336
+ keenable:
337
+ include: [search_web_pages]
338
+ behind: [web_search]
339
+ perplexity:
340
+ include: [perplexity_search]
341
+ behind: [web_search]
342
+ parallel:
343
+ include: [web_search]
344
+ behind: [web_search]
345
+ ```
346
+
347
+ The model then sees one tool, `web_search`. The servers' tools are not
348
+ declared to it, codemode does not list them, `tool_search` does not find them,
349
+ and the system prompt's list of MCP servers leaves them out. A direct call,
350
+ from the model, a codemode script or another tool, is refused; only the calls
351
+ `web_search` nests reach the server. `test/search-mcp-behind.test.ts` checks
352
+ this in every mode against a fake Tavily server.
353
+
354
+ ### Credentials for a hosted MCP server
355
+
356
+ A provider's hosted MCP server is a Recipe MCP binding like any other: a
357
+ `kind='mcp'` endpoint whose shared header carries the provider's key through a
358
+ credential reference (`Authorization: Bearer ${TAVILY_API_KEY}`,
359
+ `x-api-key: ${EXA_API_KEY}`, `X-API-Key: ${KEENABLE_API_KEY}`,
360
+ `Authorization: Bearer ${PERPLEXITY_API_KEY}` or
361
+ `${PARALLEL_API_KEY}`), injected by the egress outside the sandbox
362
+ (introspection-cloud `docs/design/endpoints.md` § MCP servers per runtime, and
363
+ `sandbox-egress-proxy-native.md`, where MCP bindings dial the edge and send no
364
+ locator). The bootstrap carries only the URL. So:
365
+
366
+ - **Header, never query string.** Tavily's `?tavilyApiKey=` and Exa's
367
+ `?exaApiKey=` put the key in the URL the sandbox sees; bind with the header.
368
+ Exa's `?tools=` is not secret and belongs in the URL.
369
+ - **OAuth is not used.** A server on Pi's client is bound with a header, and
370
+ the key is the project's, not a member's.
371
+ - **Parallel and Keenable also serve anonymous calls**, at free-tier limits.
372
+ A binding without a credential works for evaluation; Parallel answers 401 to
373
+ a key it does not recognize, so such a binding sends no key header at all.
374
+
375
+ ## Modes
376
+
377
+ Callers only ever pass `mode: "fast" | "default" | "deep"`, the same for every
378
+ provider. Each provider's adapter turns it into that provider's own request
379
+ parameter; the table shows which parameter that is, and the value each mode
380
+ sends. The model and Recipe code never see these provider names; the value
381
+ actually sent is recorded on the call's span as `search.setting`. The rows for
382
+ built providers are their descriptors' `modes` (`test/search.test.ts` checks
383
+ this table against them); the others are the proposed mapping.
384
+
385
+ For example, `web_search({ query, provider: "tavily", mode: "deep" })` sends
386
+ Tavily `search_depth: "advanced"`.
387
+
388
+ | Provider | Provider's request parameter that `mode` sets | `mode: "fast"` sends | `mode: "default"` sends | `mode: "deep"` sends |
389
+ | --- | --- | --- | --- | --- |
390
+ | `tavily` | `search_depth` | `fast` | `basic` | `advanced` |
391
+ | `exa` | `type` | `fast` | `auto` | `deep` |
392
+ | `keenable` | `mode` | `realtime` | `pro` | `pro` |
393
+ | `perplexity` | `search_type` | `fast` | `web` | `web` |
394
+ | `parallel` | `mode` | `fast` | `advanced` | `advanced` |
395
+ | `brave` | none | one level (approximated) | one level | one level (approximated) |
396
+
397
+ A `deep` that sends the same setting as `default` is approximated, and the
398
+ result says so. Over MCP, a tool that cannot run the setting runs its own
399
+ ([Result for the host](#result-for-the-host-and-the-trace)): Exa's advanced
400
+ tool runs `auto` for `deep` (REST serves `deep` when bound), its default tool
401
+ `auto` for every mode, and Parallel's tool an unreported setting.
402
+
403
+ What each costs and means:
404
+
405
+ - **Tavily.** `basic` returns one snippet per result for 1 credit; `fast` (1
406
+ credit) trades some relevance for latency; `advanced` returns up to three
407
+ relevant chunks per source and costs 2 credits. `default` follows Tavily's
408
+ own default, `basic`, so the pairing named as "tavily / advanced" is
409
+ `mode: "deep"`.
410
+ - **Exa.** `auto` lets Exa choose its retrieval and is its recommendation.
411
+ `fast` is a legacy type Exa still accepts; it suggests `lite` for new code,
412
+ but `lite` rejects some parameters, so `fast` maps to `fast` until `lite`
413
+ accepts the ones this tool sends. `deep` runs several searches and costs
414
+ more, and only REST takes it. "exa / auto" is `mode: "default"`.
415
+ - **Keenable.** `pro`, its default, gives the better results; `realtime` is
416
+ the fastest. Both cost one credit. Nothing is deeper than `pro`, so `deep`
417
+ is approximated.
418
+ - **Perplexity.** `web` is the default search; `fast` its lower-latency,
419
+ lower-cost variant. Nothing is deeper, so `deep` is approximated.
420
+ "perplexity / default" is `mode: "default"`.
421
+ - **Parallel.** The API defaults to `advanced`, so `default` is `advanced`
422
+ and "parallel / advanced" is `mode: "default"`. `fast` targets about a
423
+ second; `turbo` and `basic` are not used. Nothing in the Search API is
424
+ deeper than `advanced` (deeper research is its Task API), so `deep` is
425
+ approximated.
426
+ - **Brave.** One quality level, so `fast` and `deep` are approximated. What
427
+ "brave / llm-context" named is not a quality level but a different endpoint
428
+ returning extracted text, which is what `content: "context"` asks for.
429
+ `content` therefore selects the endpoint: `snippets` uses Web Search,
430
+ `context` uses LLM Context. Tying it to `content` rather than `mode` keeps
431
+ `mode` one scale for every provider and lets any provider serve `context`.
432
+
433
+ ## Arguments by provider
434
+
435
+ From each descriptor's `options`. `approximate` means the argument applies in
436
+ a form close to its meaning, and the note line says how.
437
+
438
+ | Provider | `freshness` | `sites` include | `sites` exclude | `context` | `country` |
439
+ | --- | --- | --- | --- | --- | --- |
440
+ | `tavily` | native (`time_range`) | native | native | approximate: chunks only in `deep` | native (`country`, the English name in lower case, `united states`; also on the MCP tool, which boosts rather than filters) |
441
+ | `exa` | approximate: published-date start, so undated pages drop out | native | native | native (`highlights`) | native (`userLocation`; on MCP only `web_search_advanced_exa` takes it, so with the default tool a call goes to REST, or is ignored with a note) |
442
+ | `brave` | native (`freshness`) | native (Goggles allowlist) | native (Goggles `$discard`) | native (LLM Context) | native (`country`) |
443
+ | `parallel` | approximate (`after_date`; REST only) | native (`include_domains`; over MCP, `site:` queries and a filter on the results) | native, alone (`combine_sites: false`; over MCP, a filter on the results) | native (`max_chars_per_result`; over MCP, excerpts cut to length) | native (`location`, lower case; REST only) |
444
+ | `perplexity` | native (`search_recency_filter`) | native (`search_domain_filter`) | native (`-domain`), alone (`combine_sites: false`) | native (`max_tokens_per_page`: 256 for snippets, 1024 for context) | native (`country`) |
445
+ | `keenable` | approximate (`published_after`: `1d`, `7d`, `1mo`, `1y`) | native for one site (`site`; `max_include_sites: 1`, the rest ignored with a note) | none | native (`snippet_max_length`) | none: ignored with a note |
446
+
447
+ **Included and excluded sites together.** Each descriptor declares
448
+ `combine_sites`. Tavily, Exa and Brave take both in one request. Parallel
449
+ ignores exclusions once an inclusion is set (its API reference says so),
450
+ Perplexity answers 400 to both (per OpenRouter's notes on the same engines),
451
+ and Keenable takes no exclusions, so they declare `false`:
452
+ a call with both sends only the included sites and adds `(ignored: exclude
453
+ sites — … cannot combine included and excluded sites …)`. Exclusions alone
454
+ are sent as usual.
455
+
456
+ A provider that restricts to fewer sites than a call lists declares
457
+ `max_include_sites` (Keenable: 1): the first are sent, and the note names the
458
+ rest. A site's domain is lower-cased and its path kept as given, since paths
459
+ are case-sensitive.
460
+
461
+ Every provider honours `max_results` up to its own maximum. What one provider
462
+ offers and the tool does not (answers, `topic`, language, safe search, Exa's
463
+ `category`, Goggles beyond sites) is listed under [Later](#later).
464
+
465
+ ### Do site filters match subdomains?
466
+
467
+ `sites: ["example.com"]` is sent as the provider's domain filter, and whether
468
+ `blog.example.com` matches is the provider's rule, not the tool's. What each
469
+ provider states:
470
+
471
+ | Provider | Subdomains of a listed domain | Source |
472
+ | --- | --- | --- |
473
+ | `tavily` | Unknown: not stated in the API reference | [Search reference](https://docs.tavily.com/documentation/api-reference/endpoint/search) |
474
+ | `exa` | A wildcard, `*.example.com`, matches every subdomain; whether a bare domain does is not stated. A path (`exa.ai/blog`) narrows to that section | [Domain and path filter changelog](https://exa.ai/docs/changelog/domain-path-filter) |
475
+ | `brave` | Unknown: Goggles' `site=` matches on the hostname, and the quickstart does not say whether a parent domain covers its subdomains | [goggles-quickstart](https://github.com/brave/goggles-quickstart) |
476
+ | `parallel` | Yes: a plain domain matches itself and its subdomains, and a path matches at segment boundaries. The MCP path filters its results by the same rule | [Search API reference](https://docs.parallel.ai/api-reference/search-beta/search) (`SourcePolicy`) |
477
+ | `perplexity` | Unknown | |
478
+ | `keenable` | Unknown | |
479
+
480
+ The tool passes a domain as given; to be sure of a subdomain, list it, and
481
+ read each result's `site`.
482
+
483
+ ## Bound providers
484
+
485
+ How a provider is bound depends on whether it has a hosted MCP server
486
+ adapter:
487
+
488
+ - **A provider with a hosted MCP server** (Tavily, Exa, Keenable,
489
+ Perplexity, Parallel) is bound when the Recipe declares its server behind `web_search`
490
+ ([Declare the servers](#declare-the-servers)) and the runtime binds it.
491
+ `mcpServers` maps provider to server id (`{ tavily: "tavily" }`). The server
492
+ is the provider's when its bound URL has the adapter's host
493
+ (`mcp.tavily.com`, `mcp.exa.ai`, `api.keenable.ai`, `api.perplexity.ai`,
494
+ `search.parallel.ai`), or, for an evaluation fake on another
495
+ host, when its id is the provider's id. A REST endpoint for its host is then
496
+ the fallback, and on its own does not bind it.
497
+ - **A REST-only provider** (Brave) is bound
498
+ when the runtime holds an endpoint for its host with a credential: a
499
+ `kind='api'` endpoint row (introspection-cloud `docs/design/endpoints.md`,
500
+ "Runtime HTTP APIs"), at project, runtime, runtime group or environment
501
+ scope. The bound set is what the egress will authenticate. It needs no
502
+ declaration in the Recipe: a search provider is interchangeable and chosen
503
+ per call.
504
+
505
+ `boundSearchProviders({ hosts, mcpServers }, providers)` applies both rules and returns
506
+ the `bound` (REST) and `mcpServers` options for the tool: `hosts` are the
507
+ egress's credentialed endpoint hosts, `mcpServers` the servers the Recipe keeps
508
+ behind `web_search` with their bound URLs. The host discovers the hosts:
509
+
510
+ - **Legacy provider lane:** the sandbox receives the credential-injected
511
+ hosts as `INTROSPECTION_ENDPOINT_HOSTS` (comma-separated), which the data
512
+ plane builds from the session's endpoint targets.
513
+ - **Proxy-native egress:** the runtime removes `INTROSPECTION_ENDPOINT_HOSTS`
514
+ when it accepts the proxy-native offer, and
515
+ `INTROSPECTION_EGRESS_PLACEHOLDERS` is keyed by variable name, not host. So
516
+ on a proxy-native runtime nothing in the sandbox lists the bound hosts
517
+ today. The proposal is that the data plane keeps a non-secret list of
518
+ credentialed endpoint hosts in the bootstrap (or keeps the variable as
519
+ information only), and that the runtime passes it to Recipes. This needs a
520
+ platform decision; it affects only Brave, and the REST fallbacks.
521
+ - **Other hosts** pass `bound` themselves, and `credentialHeaders` when they
522
+ attach credentials their own way.
523
+
524
+ A bound provider this package does not implement is not offered.
525
+
526
+ ## Credentials
527
+
528
+ A provider sends its request to its own host, and the Recipe never holds the
529
+ key. The host's egress supplies it, as for the Slack channel
530
+ (`packages/channels/slack/src/client.ts`):
531
+
532
+ | Provider | Host to bind | Header the endpoint injects |
533
+ | --- | --- | --- |
534
+ | Tavily | `api.tavily.com` | `Authorization: Bearer <key>` |
535
+ | Exa | `api.exa.ai` | `x-api-key: <key>` |
536
+ | Parallel | `api.parallel.ai` (MCP: `search.parallel.ai`, `Authorization: Bearer`) | `x-api-key: <key>` |
537
+ | Perplexity | `api.perplexity.ai` (REST and MCP) | `Authorization: Bearer <key>` |
538
+ | Keenable | `api.keenable.ai` (REST and MCP) | `X-API-Key: <key>` |
539
+ | Brave | `api.search.brave.com` | `X-Subscription-Token: <key>` |
540
+
541
+ - **Proxy-native egress** (`INTROSPECTION_EGRESS_PROXY_NATIVE=1`): the request
542
+ leaves without the header. The egress intercepts the bound host and, finding
543
+ the endpoint's header absent, injects it (introspection-cloud
544
+ `docs/design/sandbox-egress-proxy-native.md`, "Credential placeholders").
545
+ - **Legacy provider lane** (`INTROSPECTION_EGRESS_URL` and
546
+ `INTROSPECTION_TOKEN`): the session locator travels in the provider's own
547
+ header, with its prefix, and ext_proc swaps it for the key. The runtime's
548
+ managed fetch dials the egress while keeping the provider's host as the
549
+ authority.
550
+ - **Neither:** the call fails with `not_configured` before any request, rather
551
+ than reaching the provider unauthenticated.
552
+
553
+ Each endpoint is one host and one header, so binding a search provider is a
554
+ CRUD call on `/v1/endpoints`, with no chart change. Brave and Parallel are
555
+ already named there as runtime utility APIs.
556
+
557
+ ## Filtering results in codemode
558
+
559
+ Under `mcp.mode: codemode` the model can call `web_search` from a script, as
560
+ `await tools.web_search({ ... })`, and keep only what it needs before anything
561
+ enters its context: one search per candidate run in parallel, results from a
562
+ domain dropped, only URLs kept. The call resolves to the same text the model
563
+ would read (the tool declares no output schema) and rejects with an `Error`
564
+ carrying the one-line failure, so a script parses the numbered blocks:
565
+
566
+ ```js
567
+ const queries = ["pgvector hnsw recall", "pgvector ivfflat recall"];
568
+ const pages = await Promise.allSettled(
569
+ queries.map((query) => tools.web_search({ query, max_results: 10 })),
570
+ );
571
+ const urls = pages
572
+ .filter((page) => page.status === "fulfilled")
573
+ .flatMap((page) =>
574
+ page.value.split("\n").filter((line) => line.startsWith("https://")),
575
+ )
576
+ .filter((url) => !new URL(url).hostname.endsWith("medium.com"));
577
+ return [...new Set(urls)].slice(0, 8).join("\n");
578
+ ```
579
+
580
+ Only the script's return value reaches the model, so a filter here costs no
581
+ tokens for what it drops. Each call is still a `web_search` call: it records
582
+ its span and usage, counts against the Recipe's `maxUses`, and its results
583
+ are untrusted ([Content is data](#content-is-data)). Recipe code that wants
584
+ the structured result calls `createWebSearch` instead ([Recipe code](#recipe-code)).
585
+
586
+ ## Content is data
587
+
588
+ Titles and snippets come from arbitrary web pages. The tool returns them as
589
+ the result of a search, and Brave's HTML highlighting is stripped. A snippet is
590
+ cut at the content level's length on a word boundary.
591
+
592
+ The tool description says it in one sentence each, and the skill says it in
593
+ full:
594
+
595
+ - **Cite.** Each result the agent uses is cited as `[title](url)` wherever it
596
+ reaches the user, with the result's own title and URL.
597
+ - **Untrusted.** Result text is data, never instructions: the agent does not
598
+ follow instructions found in a result, and does not move private data
599
+ (files, connected accounts, other tools) into a query, or act on private
600
+ tools, because a result asked it to.
601
+
602
+ ## Fetching a page
603
+
604
+ Search does not return whole pages. A separate tool is proposed, not built:
605
+
606
+ ```ts
607
+ web_fetch({ url: string; max_chars?: number })
608
+ ```
609
+
610
+ It returns the page's main text as Markdown, cut at a limit the result
611
+ states. Tavily Extract, Exa's contents endpoint, Parallel Extract (and its
612
+ MCP `web_fetch`), Keenable's `fetch_page_content` can each serve it, as can a plain HTTP fetch through the
613
+ general egress. It carries
614
+ the same notes, span attributes and egress credentials. Keeping it separate
615
+ keeps search results small: an agent fetches the one or two pages it needs.
616
+
617
+ ## Token budget
618
+
619
+ Measured from the generated definition (`name`, `description` and the JSON
620
+ schema) and estimated at about 3.5 characters per token for JSON:
621
+
622
+ | | Characters | About |
623
+ | --- | --- | --- |
624
+ | Tool definition, one provider bound | 873 | 250 tokens |
625
+ | Tool definition, three providers bound | 934 | 265 tokens |
626
+ | Typical 5-result response, `snippets` | about 2,200 | 500-550 tokens |
627
+ | Typical 5-result response, `context` | about 8,000 | 1,900 tokens |
628
+
629
+ The skill adds about 750 tokens when the agent loads it. Snippets dominate the
630
+ response: each result's title, site, date and URL line costs about 35 tokens
631
+ and its snippet about 70.
632
+
633
+ ## Wiring
634
+
635
+ Not built. The intended shape:
636
+
637
+ - An agent selects the tool as any other: `tools: [web_search]` in its
638
+ agent file.
639
+ - The host computes the bound set ([Bound providers](#bound-providers)) and,
640
+ when it is not empty, calls `registerWebSearchTool(pi, { providers,
641
+ ...boundSearchProviders({ hosts, mcpServers }, providers) })`, with
642
+ `providers` from `loadSearchProviders`, and
643
+ offers `SEARCH_SKILL` (`skills/search/SKILL.md`), as it offers the
644
+ documents skill with `documents`. The skill joins the Recipe isolation
645
+ rule in `AGENTS.md`.
646
+ - An agent that selects `web_search` on a runtime with nothing bound fails
647
+ at selection, naming the providers it could bind.
648
+
649
+ ## Where things live
650
+
651
+ - **The host, in Recipes** (`src/search`, the `@introspection-ai/recipes/search`
652
+ subpath): the tool's schema and registration (`createWebSearch`,
653
+ `registerWebSearchTool`), argument normalization (modes, sites, country,
654
+ freshness, the budget), typed errors, the MCP path through Pi's
655
+ `ctx.executeTool`, the HTTP request and its credential lanes, spans and the
656
+ usage record, `boundSearchProviders`, `loadSearchProviders`, and the
657
+ provider contract (`SearchProviderModule`, `RecipeSearchModule`,
658
+ `SEARCH_PROVIDER_API_VERSION`).
659
+ - **The providers, in `@introspection-ai/recipe-search`** (`packages/search`):
660
+ one plain `SearchProviderModule` per provider, exported together as the
661
+ package's default `RecipeSearchModule` (`{ kind: "search", apiVersion,
662
+ providers }`) and each by name. It imports only types from Recipes; the
663
+ host injects what runs (`context.request` for HTTP, the MCP call itself).
664
+ It is a companion package: Recipes installs it alongside itself as an
665
+ `optionalDependency`, and a Recipe that lists it in `dependencies` pins
666
+ its copy.
667
+
668
+ `loadSearchProviders({ recipeDir, hostDir? })` resolves the package from the
669
+ Recipe, then beside Recipes, checks its `apiVersion` and returns the
670
+ providers. With the package not installed it returns none, and `web_search`
671
+ offers no provider: a call fails with `not_bound`.
672
+
673
+ ## Write a provider
674
+
675
+ A provider is a plain module, `SearchProviderModule`:
676
+
677
+ - `kind: "search"`, `apiVersion` (`SEARCH_PROVIDER_API_VERSION`, checked
678
+ when the tool is built), and `id`, one of `SEARCH_PROVIDER_IDS`.
679
+ - `capabilities`: `modes` (each of `fast`, `default` and `deep` with the
680
+ provider's `setting`, and `approximate` when the setting does not mean the
681
+ mode), `mode_parameter`, `max_results`, `combine_sites`,
682
+ `max_include_sites` where it takes fewer sites than a call lists, `options` (native, approximate or
683
+ none for `freshness`, `include_sites`, `exclude_sites` and `context`, with a
684
+ one-sentence `note` for each approximation), `host`, `credential` (header
685
+ and prefix) and `billing`.
686
+ - `mcp` (optional): the hosted server's `url` and `credential`, the `tools`
687
+ it may call, `plan` and `parse` ([MCP transport](#mcp-transport)).
688
+ - `search(request, context)`: `request` is normalized, with the mode's
689
+ `setting`, the content level and its `max_chars`, and only the arguments the
690
+ descriptor serves, and a `session` id stable for the task.
691
+ `context` carries `request(path, init)`, which sends one JSON request to the
692
+ provider's host with the credential its egress lane needs and throws a
693
+ typed `SearchProviderError` for a failure (429 with its delay, 401, 402,
694
+ 5xx), `now` and the abort `signal`. It returns results and the billed
695
+ `units`. An adapter's MCP `parse` may throw a plain `Error`, which the host
696
+ reports as `provider_error`.
697
+
698
+ The six providers share one package, `@introspection-ai/recipe-search`,
699
+ because each is a few HTTP or MCP calls with no SDK and no dependency of its
700
+ own. A provider that needs its own dependencies would be a companion package
701
+ of its own under the companion rule in `AGENTS.md`.
702
+
703
+ ## Test search
704
+
705
+ - **Unit:** `test/search.test.ts` loads the providers from
706
+ `packages/search` and runs each against a local HTTP
707
+ server: request shape per mode and argument, the credential header on each
708
+ egress lane, response mapping, notes, errors and spans. The MCP path runs
709
+ against a fake Pi tool context whose `executeTool` answers as Pi's client
710
+ does, with each server's real output format as the live servers returned
711
+ it (Tavily's `structuredContent` and older text, Exa's JSON and text,
712
+ Keenable's JSON, Perplexity's formatted text, Parallel's
713
+ `structuredContent`): tool name and arguments, MCP or REST per argument,
714
+ the setting that ran, notes, tool errors, refused calls and the MCP span.
715
+ No live calls and no keys.
716
+ - **Session:** `test/search-mcp-behind.test.ts` runs a Recipe session in each
717
+ `mcp.mode` with a fake Tavily MCP server behind `web_search`: the tool's
718
+ nested call reaches the server, and a direct call from the model or a
719
+ codemode script is refused.
720
+ - **Evals:** a search provider is a REST API, so it fits eval-simulate's API
721
+ fakes (introspection-cli `integrations/eval-simulate/docs/api-fakes.md`):
722
+ one fake per provider under `fakes/api/<id>/`, its manifest naming the host
723
+ above, and a scenario's world holding the pages each query finds. Parallel
724
+ and Perplexity generate their SDKs from OpenAPI documents the trim could
725
+ capture; for the others the document would be written from their
726
+ reference. Until then, a Recipe's eval can bind a fake provider module
727
+ through `providers`.
728
+ - **Evals over MCP:** the provider's MCP server is an ordinary binding, so
729
+ an eval binds an MCP fake for it, as for any MCP server.
730
+ - **Live:** `introspection dev` with a bound endpoint per provider, or a
731
+ script calling `createWebSearch` over REST through a proxy that injects
732
+ the keys ([Live checks](#live-checks)).
733
+
734
+ ## Later
735
+
736
+ Possible additions, each only once a real Recipe needs it:
737
+
738
+ - **Fallback** to another bound provider on a rate limit or outage, reported
739
+ in the notes and the span.
740
+ - **Strict** mode, refusing an argument a provider cannot serve exactly, for
741
+ evals that compare providers.
742
+ - **Recipe defaults** for `country`, `language`, `topic`, safe search and
743
+ snippet length.
744
+ - **Provider passthrough** options, such as Tavily's `chunks_per_source` or a
745
+ Brave Goggle, outside the model's schema.
746
+ - **Answers**: Tavily's `include_answer` and Perplexity's Sonar return an
747
+ answer with citations. An answer is a model's summary of results the agent
748
+ could read itself, so it belongs in the tool only if it saves real tokens
749
+ and keeps its citations.
750
+ - **Several queries in one call**, which Parallel takes natively
751
+ (`search_queries`); others would fan out and merge.
752
+ - **Pagination.**
753
+
754
+ ## Live checks
755
+
756
+ Run from a session whose egress proxy injected the Keenable, Tavily, Exa and
757
+ Brave keys, with a script around `web_search` and a minimal Streamable HTTP
758
+ MCP client (not committed). Every call below returned results in the shape the tests'
759
+ fakes use:
760
+
761
+ | Provider | Transport | Call | Came back |
762
+ | --- | --- | --- | --- |
763
+ | Keenable | MCP | `fast`, `freshness: "year"` | `realtime`, 3 dated results; no credits over MCP |
764
+ | Keenable | MCP | `context`, `sites: ["github.com"]` | `pro`, 2 github.com results |
765
+ | Keenable | REST | default | `pro`, 3 results, `usage` 1 credit |
766
+ | Tavily | MCP | `deep`, `country`, `freshness`, an exclusion | `advanced`, results with scores and dates |
767
+ | Exa | MCP | advanced tool, `freshness: "year"` | `auto`, 3 dated results with highlights, $0.007 |
768
+ | Exa | MCP | `deep` | ran `auto`, with the approximated note |
769
+ | Parallel | MCP, anonymous | `sites: ["github.com"]` | 3 github.com results; no setting reported |
770
+ | Brave | REST | `snippets` | 3 results from Web Search |
771
+ | Brave | REST | `context`, `sites: ["github.com/modelcontextprotocol"]` | 3 github.com results from LLM Context; one of two runs also returned `github.com/jancurn/modelcontextprotocol/…`, since a Goggles path pattern is not anchored to the start of the path |
772
+
773
+ Not run live: Perplexity (no key; built from its server's source), Parallel's
774
+ REST API (the account had no credit, which answered 402), and Exa's and
775
+ Tavily's REST APIs (unchanged, fake-tested).
776
+
777
+ ## Open questions
778
+
779
+ 1. **Bound hosts under proxy-native egress.** Nothing in a proxy-native
780
+ sandbox lists the bound endpoint hosts. Should the data plane keep
781
+ `INTROSPECTION_ENDPOINT_HOSTS` (or a new non-secret list) for discovery?
782
+ 2. **Answers.** Do answer-style providers (Perplexity Sonar, Tavily's
783
+ answer, Exa's answer endpoint) belong in `web_search`, in a separate
784
+ `web_answer` tool, or nowhere?
785
+ 3. **Cost limits.** A Recipe can cap calls per task (`maxUses`). Does the
786
+ platform also need a budget in money, or one that refuses only `deep` once
787
+ spent?
788
+ 4. **Tavily `default`.** It maps to Tavily's own default, `basic`, so the
789
+ named pairing "tavily / advanced" is `mode: "deep"`. Confirm, or map
790
+ `default` to `advanced`.
791
+ 5. **Exa `fast`.** Keep the legacy `fast` type, or move to `lite` and accept
792
+ that it rejects some arguments?
793
+ 6. **Credits over MCP.** Keenable reports credits in the result's `_meta`,
794
+ which Pi's client drops, and Tavily's MCP result reports none, so over MCP
795
+ both record one request. Should Pi pass `_meta` through to nested calls?
796
+ 7. **Parallel's MCP setting.** Its tool runs a mode it does not report, so
797
+ those calls carry no `setting` and no usage variant. Price them as
798
+ `advanced` (the API's default), or route every Parallel call that names a
799
+ mode to REST?
800
+ 8. **Perplexity live.** Its server's tool and output format are from source;
801
+ one keyed `tools/list` and call would confirm them.