Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

feat(provider): enable native search for Codex OAuth

vastsad185601447b3
diff --git a/docs/adr/0297-provider-hosted-web-search-adapter-capability.md b/docs/adr/0297-provider-hosted-web-search-adapter-capability.md
index ac405181e..595ded26e 100644
--- a/docs/adr/0297-provider-hosted-web-search-adapter-capability.md
+++ b/docs/adr/0297-provider-hosted-web-search-adapter-capability.md
@@ -35,33 +35,33 @@ Two upstream facts forced the design:
## Decision
-1. **Capability is declared data, evaluated in one place.** The per-model
- opt-in is `ModelBinding.nativeWebSearch` (settings UI: a checkbox in the
- model's advanced sheet, disabled unless the provider's API style is
- `responses` or `anthropic_messages`). models.dev publishes no hosted-tool
- capability, so there is no catalog default; absent means off. The single
- evaluation point is `resolveNativeWebSearch` in
- `packages/shared/src/native-web-search.ts`, keyed on the resolved wire
- API — never vendor names, base URL hostnames, or model-id substrings.
+1. **Capability is declared data and gated by the resolved wire API.** The
+ per-model opt-in is `ModelBinding.nativeWebSearch` (settings UI: a checkbox
+ in the model's advanced sheet, disabled unless the provider style is
+ `responses`, `openai_codex_responses`, or `anthropic_messages`). models.dev
+ publishes no hosted-tool capability, so there is no catalog default; absent
+ means off. Runtime `resolveNativeWebSearch` keys on the final adapter API —
+ never vendor names, base URL hostnames, or model-id substrings.
-2. **Attachment and extraction live in the pi-ai adapters**, delivered by
+2. **Attachment and extraction live in pi-ai adapters**, delivered by
extending `patches/@[email protected]`:
- - `anthropic-messages.js` appends the `web_search_20250305` tool when
- `model.webSearch === true`, captures search blocks as `hostedSearch`
- content parts (raw wire block kept whole, streamed `input_json_delta`
- accumulated so the query is available live), collects `citations_delta`,
- and replays both halves of each pair in order on later turns.
- - `openai-responses(-shared).js` (and the Azure variant's own
- `buildParams`) appends the `web_search` tool, asks for
- `web_search_call.action.sources` via the opt-in `include` channel,
- creates a `hostedSearch` slot for `web_search_call` items, collects
- `url_citation` annotations, and replays the item for the same model.
- Both adapters push a `hosted_search_update` stream event per block
- transition; `patches/@[email protected]` teaches
- the agent loop to forward it as `message_update` — without that second
- patch the events die in the loop's switch and search activity renders only
- when the whole turn finishes. The patches are a stopgap; the same changes
- should be proposed upstream and dropped once released.
+ - `anthropic-messages.js` appends `web_search_20250305` when opted in,
+ captures search blocks as `hostedSearch`, collects citations, and replays
+ both halves of each pair on later turns.
+ - `openai-responses(-shared).js` and Azure's `buildParams` append `web_search`,
+ request `web_search_call.action.sources`, capture search items/citations,
+ and replay the item for the same model.
+ - `openai-codex-responses.js` uses a separate Codex request builder and
+ ChatGPT subscription endpoint. It appends the same top-level Responses
+ `web_search` tool and source include only when opted in; it reuses the
+ shared Responses stream parser and model-scoped replay projection. This
+ is the classic Codex Responses request shape; the backend is not the
+ public `/v1/responses` API.
+ All three adapter paths push `hosted_search_update` transitions. The
+ `pi-agent-core` patch forwards them as `message_update`, so activity renders
+ while a search is in flight instead of only at turn completion. These
+ patches are a stopgap; propose the changes upstream and remove them once
+ released.
3. **The flag travels the existing model-config channel.**
`ModelConfigWithBinding` copies `nativeWebSearch` into
diff --git a/docs/project/hosted-search-contract-verification.md b/docs/project/hosted-search-contract-verification.md
index 98e11ce40..d0f90bcfa 100644
--- a/docs/project/hosted-search-contract-verification.md
+++ b/docs/project/hosted-search-contract-verification.md
@@ -225,3 +225,40 @@ scripts/e2e/hosted-search-provider.mjs
scripts/e2e/hosted-search-scenarios.mjs
scripts/e2e/hosted-search-sidecar.mjs
```
+
+## OpenAI Codex OAuth hosted-search follow-up (2026-09-23)
+
+The official [OpenAI web-search guide](https://developers.openai.com/api/docs/guides/tools-web-search)
+documents `tools: [{ type: "web_search" }]` for the public Responses API, but
+does not specify the private ChatGPT Codex subscription endpoint. The pi upstream
+issue [#8556](https://github.com/earendil-works/pi/issues/8556) reports a
+successful verification of the classic Codex Responses top-level `tools` shape
+and `response.web_search_call.*` events. This implementation therefore opts in
+only for `openai-codex-responses`, keeps the feature off by default, and surfaces
+backend rejection normally. No OAuth token or live API request was used.
+
+### Task-candidate verification
+
+- Branch: `fix/openai-codex-native-search`.
+- Base: `origin/main` at `ea5890b94`; it is an ancestor of the task candidate.
+- pi-ai: `0.87.1`; patch SHA-256 and `pnpm-lock.yaml` patch hash both
+ `6cf3998c09e8bba22cd63ceebe74a33332d9fd0c9ef3d5046941cb53513973f8`.
+- `pnpm --filter @pi-desktop/shared test`: PASS, 84 files / 1,012 tests.
+- `pnpm --filter @pi-desktop/agent-runtime test`: PASS, 68 files / 1,029 tests.
+- `pnpm build:js`, `pnpm -r --if-present typecheck`, `pnpm lint`, and
+ `pnpm docs:check`: PASS.
+- `pnpm test:e2e:hosted-search`: PASS, 7/7 offline sidecar scenarios; bundle
+ SHA-256 `633fc6e9ffafca718a53a2b9949d28259b90584b332d7a9a30e5f5763c64caae`.
+- Codex adapter contract uses a synthetic JWT, captures the body at
+ `onPayload`, then aborts before fetch. It verifies opt-in body fields and
+ opt-out omission without contacting a provider.
+- `TMPDIR=$PI_SCRATCH_DIR pnpm test:e2e:provider-api-style`: PASS; the
+ production `VendorAccountDialog` checkbox starts off, can be enabled for a
+ synthetic Codex OAuth account, and saves `nativeWebSearch` in both locales.
+ Discovery is stubbed; no Host persistence or live provider is exercised.
+
+`pnpm patch-commit` needed installation metadata for the new worktree. It
+resolved packages from the cache with zero downloads, materialized the ignored
+worktree `node_modules`, and ran Electron postinstall. No live OAuth account or
+paid service was used. This is task-candidate evidence, not live Codex account
+certification.
diff --git a/docs/project/unreleased.md b/docs/project/unreleased.md
index c38675104..1425ac731 100644
--- a/docs/project/unreleased.md
+++ b/docs/project/unreleased.md
@@ -31,3 +31,6 @@
- Hovering a reasoning stop or its label highlights the corresponding label.
Only unfilled dots brighten and enlarge; filled dots and the current thumb
keep their appearance.
+- OpenAI Codex OAuth models can now opt into provider-hosted native web search.
+ The feature remains off by default and search history is replayed only for
+ the same Codex model.
diff --git a/docs/spec/03-runtime/11-provider-model-system.md b/docs/spec/03-runtime/11-provider-model-system.md
index 34829de27..038c5d179 100644
--- a/docs/spec/03-runtime/11-provider-model-system.md
+++ b/docs/spec/03-runtime/11-provider-model-system.md
@@ -227,16 +227,20 @@ PI-Desktop must not permanently restrict users to a short fixed model list.
explanatory copy is required.
10a. `nativeWebSearch` is a two-state opt-in (absent means off; there is no
catalog baseline because models.dev publishes no hosted-tool capability).
- When enabled and the model's resolved wire API is `anthropic-messages`,
- `openai-responses`, or `azure-openai-responses` (stored apiStyle
- `anthropic_messages` / `responses`), the adapter attaches the provider's
- hosted web search tool (`web_search_20250305` / `web_search`), extracts
- the search activity into `UiMessage.hostedSearch` (`rounds` for display,
- `replay` for convertMessages), and restores those raw blocks on later
- turns including after a restart (ADR 0297). The checkbox is disabled
- when the provider's API style is neither of those two. Gateways that do
- not support the tool surface the provider error; the remedy is unchecking.
- Search runs on the provider: there is no local fetch and no permission
+ When enabled and the model resolves to `anthropic-messages`,
+ `openai-responses`, `azure-openai-responses`, or
+ `openai-codex-responses` (stored apiStyle `anthropic_messages`, `responses`,
+ or `openai_codex_responses`), the adapter attaches the provider's hosted
+ search tool (`web_search_20250305` / `web_search`), extracts activity into
+ `UiMessage.hostedSearch` (`rounds` for display, `replay` for convertMessages),
+ and restores raw blocks on later turns including after restart (ADR 0297).
+ OpenAI OAuth uses the separate Codex Responses adapter and its ChatGPT
+ subscription endpoint, not the public `/v1/responses` transport; it sends
+ the hosted tool in the Codex request body's top-level `tools` list. The
+ settings checkbox remains opt-in and the runtime checks support against the
+ final resolved wire API, so stale flags cannot leak to unsupported adapters.
+ Gateways that reject the tool surface the provider error; the remedy is
+ unchecking. Search runs on the provider: there is no local fetch or permission
prompt. Compaction keeps its existing prefix/tail retention strategy. The
summary request includes search replay data from the compacted prefix; the
generated text summary is not a lossless copy of raw provider search blocks.
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index a27a48e29..379076d85 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -8011,29 +8011,37 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
- **Preconditions**: Isolated profile, English and Simplified Chinese. Seed
non-OAuth legacy rows using Codex and Pi account formats, including an OpenAI
- preset URL; use synthetic models and no real credentials.
+ preset URL; use synthetic models and no real credentials. Include a synthetic
+ OpenAI Codex OAuth account with one configured model binding.
- **Steps**: 1) Add a Custom service and inspect its format choices. 2) Edit each
legacy row and save unchanged, then explicitly select Responses and save.
3) Copy each original legacy row, inspect the current format and explanatory
hint, wait past discovery debounce, and cancel. 4) Copy again, choose Anthropic
Messages and save. 5) Check saved payloads and the unchanged source row.
+ 6) Edit the synthetic Codex OAuth account; confirm Native web search is
+ enabled but unchecked, check it, save, and inspect the model binding payload.
- **Expected**: New custom choices are the four general protocols; Codex and Pi
are available through vendor accounts, not as new API-key choices. Legacy
editing preserves format, name, URL and authentication unless explicitly
changed. A copied account format is visible but cannot be newly selected;
saving and discovery are blocked until an explicit supported choice. The
explanation is localized. Cancel performs no create; a valid copy never uses
- the source id or credentials. Named OpenCode Go and OAuth account flows remain
- unchanged.
+ the source id or credentials. For Codex OAuth, Native web search is enabled
+ for the supported Responses wire, defaults off, and saves as
+ `nativeWebSearch: true` on that model only. Named OpenCode Go and OAuth account
+ flows remain unchanged.
- **Automation**: `pnpm test:e2e:provider-api-style` renders the production React
- form in Electron/Chromium with a stubbed API boundary and checks exact create,
- update and discovery payloads. This does not verify Host storage or live OAuth.
-- **Specs linked**: `03-runtime/12-provider-config-schema.md`, ADR 0095.
+ form and `VendorAccountDialog` in Electron/Chromium with a stubbed API boundary;
+ it checks create/update/discovery payloads and the Codex model binding save.
+ This does not verify Host storage, live OAuth or live model/search calls.
+- **Specs linked**: `03-runtime/11-provider-model-system.md`,
+ `03-runtime/12-provider-config-schema.md`, ADR 0095, ADR 0297.
- **Acceptance**: B (model configuration), Security.
-- **Status**: Helper/copy regressions passed. The branch Electron/React scenario
- passed in English and Simplified Chinese: six scenario groups, four creates
- and eight updates through the stubbed API. Host persistence, live OAuth/model
- calls and visual layout were not exercised. Post-integration main E2E is NOT RUN.
+- **Status**: The Electron/React scenario passed in English and Simplified
+ Chinese: eight scenario groups, four creates and eight provider updates through
+ the stubbed API; both locales also verify the Codex OAuth search opt-in save.
+ Host persistence, live OAuth/model calls and visual layout were not exercised.
+ Post-integration main E2E is NOT RUN.
#### E2E-PROVIDER-copy-config-without-credentials: Copy configuration into an independent provider
@@ -14854,11 +14862,14 @@ or an already installed desktop application do not satisfy this test.
| Invalid saved replay container | Restore returns safe INTERNAL/context-validation, sends no provider request or persistence Host RPC, and keeps the process healthy. In-memory immutability is checked by the replay unit tests. |
| Unknown saved search phase | The same explicit rejection is observed without silently discarding the search record. |
-**Companion gates:** Responses/Azure/Anthropic adapter contracts; typed search
-phases; zero/valid/stale usage; changed/unchanged system prefix and tool ledger;
-search content growth and CJK output budgets; structured local preparation
-failures without retry/fetch, ordinary transport retry and cancellation. Dependency upgrades must run
-these gates against the locked dependency version and record the tested bundle.
+**Companion gates:** Responses/Azure/Anthropic/Codex adapter contracts; typed
+search phases; zero/valid/stale usage; changed/unchanged system prefix and tool
+ledger; search content growth and CJK output budgets; structured local
+preparation failures without retry/fetch, ordinary transport retry and
+cancellation. The Codex contract uses a synthetic JWT payload, captures the
+request before fetch, proves opt-out omits the tool, and never contacts a
+provider. Dependency upgrades must run these gates against the locked version
+and record the tested bundle.
**Evidence:** record build and test exit codes, baseline SHA, dependency versions,
artifact identity and independent review in
diff --git a/docs/zh-CN/spec/03-runtime/11-provider-model-system.md b/docs/zh-CN/spec/03-runtime/11-provider-model-system.md
index ec3fd19f6..23b52b5e7 100644
--- a/docs/zh-CN/spec/03-runtime/11-provider-model-system.md
+++ b/docs/zh-CN/spec/03-runtime/11-provider-model-system.md
@@ -201,17 +201,19 @@ PI-Desktop 不得把用户永久限制在一份简短的固定模型列表上。
10. 设置里的复选框展示的是相对于已发布基线的有效答案;把某一项设回已发布的
值,存下来的是"跟随目录",而不是一个取值相同的覆盖。因此与 models.dev
保持一致本身就是重置,不需要另外的重置控件,也不需要逐项能力的解释文案。
-10a. `nativeWebSearch` 是两态的主动开启(缺省即关闭;没有目录基线,因为
- models.dev 不发布托管工具能力)。启用且模型解析后的线路 API 是
- `anthropic-messages`、`openai-responses` 或 `azure-openai-responses`
- (存储的 apiStyle 为 `anthropic_messages` / `responses`)时,适配器会
- 附加提供商托管的联网搜索工具(`web_search_20250305` / `web_search`),
- 把搜索活动提取为 `UiMessage.hostedSearch`(`rounds` 用于展示,`replay`
- 用于 convertMessages),并在后续回合——包括重启之后——回放这些原始
- 搜索块(ADR 0297)。提供商接口风格不属于这两种时复选框禁用。不支持
- 该工具的网关会把提供商错误暴露出来;处理方式是取消勾选。搜索在提供商
- 侧执行:没有本地抓取,也没有权限询问。压缩保持既有的前缀/尾部保留策略;
- 摘要请求包含被压缩前缀中的搜索回放数据,但生成的文本摘要不是原始搜索块的无损副本。
+10a. `nativeWebSearch` 是两态主动开启(缺省即关闭;models.dev 不发布托管工具能力,
+ 因此没有目录默认值)。启用后,当模型解析到 `anthropic-messages`、
+ `openai-responses`、`azure-openai-responses` 或 `openai-codex-responses`
+ (存储的 apiStyle 为 `anthropic_messages`、`responses` 或
+ `openai_codex_responses`)时,适配器附加提供商托管搜索工具
+ (`web_search_20250305` / `web_search`),将活动写入
+ `UiMessage.hostedSearch`,并在后续回合(含重启后)回放原始数据(ADR 0297)。
+ OpenAI OAuth 使用独立的 Codex Responses 适配器和 ChatGPT 订阅端点,不是公开的
+ `/v1/responses`;搜索工具写入 Codex 请求体顶层 `tools`。设置仍需用户逐模型
+ 勾选;运行时还会按最终解析的 wire API 校验,旧配置不会把工具带给不支持的适配器。
+ 不支持工具的网关会显示提供商错误,用户可取消勾选。搜索由提供商执行,没有
+ 本地抓取或权限询问。压缩仍按既有前缀/尾部策略保留;摘要请求含被压缩前缀的
+ 搜索回放,但生成的文本摘要不是原始搜索块的无损副本。
11. `ModelInfo` 是设置界面用来对照的已发布记录,因此已存储的 binding 不得
塑造它的能力或推理字段。有效上限、推理与思考级别都通过那个确切的 binding
解析;有效的传输模态数组还会额外套用显式的附件覆盖。
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index bc2ccee26..6e4f39577 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -5229,24 +5229,28 @@ eleven-tool-round desktop paths are verified by
#### E2E-PROVIDER-custom-form-excludes-account-formats:新建自定义服务不提供账户专用格式
- **先决条件**:隔离配置,英文及简体中文;构造使用 Codex、Pi 账户格式的
- 历史非 OAuth 行,其中包含 OpenAI 预设 URL,使用合成模型,不使用真实凭据。
-- **步骤**:1) 新建自定义服务,检查接口格式选项。2) 编辑两种历史行并原样
- 保存,再明确选择 Responses 保存。3) 复制原历史行,检查当前格式及说明,
- 等待超过发现防抖时间后取消。4) 再次复制,选择 Anthropic Messages 后保存。
- 5) 检查保存请求及原行未被改变。
+ 历史非 OAuth 行,其中包含 OpenAI 预设 URL;另有一个带模型绑定的合成 OpenAI
+ Codex OAuth 账户。使用合成模型,不使用真实凭据。
+- **步骤**:1) 新建自定义服务,检查接口格式选项。2) 编辑两种历史行并原样保存,
+ 再明确选择 Responses 保存。3) 复制原历史行,检查当前格式及说明,等待超过
+ 发现防抖时间后取消。4) 再次复制,选择 Anthropic Messages 后保存。5) 检查
+ 保存请求及原行未被改变。6) 编辑合成 Codex OAuth 账户,确认原生联网搜索
+ 可用但默认未选中,勾选并保存,检查模型绑定载荷。
- **预期**:新建只提供四种通用协议;Codex 与 Pi 通过厂商账户使用,不能作为
- 新 API key 服务格式。历史行在未主动修改时保留协议、名称、URL 和认证。
- 复制时显示原账户格式但不可重新选择;必须主动选支持的格式后才能保存和
- 发现模型,并提供本地化说明。取消不创建行;有效副本不复用原行 ID 或凭据。
- 具名 OpenCode Go 与 OAuth 账户流程保持不变。
+ 新 API key 服务格式。历史行在未主动修改时保留协议、名称、URL 和认证。复制时
+ 显示原账户格式但不可重新选择;必须主动选支持的格式后才能保存和发现模型,
+ 并提供本地化说明。取消不创建行;有效副本不复用原行 ID 或凭据。对于 Codex
+ OAuth,原生联网搜索仅对支持的 Responses wire 启用、默认关闭,且只写入该模型
+ 的 `nativeWebSearch: true`。具名 OpenCode Go 与 OAuth 账户流程保持不变。
- **自动化**:`pnpm test:e2e:provider-api-style` 在 Electron/Chromium 中渲染
- 实际 React 表单,以模拟 API 边界检查创建、更新及发现请求的准确内容。
- 不验证 Host 存储或真实 OAuth。
-- **链接规格**:`03-runtime/12-provider-config-schema.md`、ADR 0095。
+ 实际 React 表单和 `VendorAccountDialog`,以模拟 API 边界检查创建、更新、发现请求
+ 及 Codex 模型绑定保存。不验证 Host 存储或真实 OAuth/模型请求。
+- **链接规格**:`03-runtime/11-provider-model-system.md`、
+ `03-runtime/12-provider-config-schema.md`、ADR 0095、ADR 0297。
- **验收**:B(模型配置)、Security。
-- **状态**:helper/复制回归已通过。分支 Electron/React 场景在英文、简体中文
- 下通过:六组场景,经模拟 API 发出四次创建、八次更新。未验证 Host 持久化、
- 真实 OAuth/模型请求和视觉布局。主线合并后 E2E 尚未运行。
+- **状态**:Electron/React 场景在英文、简体中文下均通过,共八组;模拟 API 收到
+ 四次创建、八次更新,两种语言均验证 Codex OAuth 搜索 opt-in 保存。未验证 Host
+ 持久化、真实 OAuth/模型请求和视觉布局。主线合并后 E2E 尚未运行。
#### E2E-PROVIDER-copy-config-without-credentials:复制配置为独立提供商
diff --git a/packages/agent-runtime/src/hosted-search-contract.test.ts b/packages/agent-runtime/src/hosted-search-contract.test.ts
index 485b68ac7..7c870baa9 100644
--- a/packages/agent-runtime/src/hosted-search-contract.test.ts
+++ b/packages/agent-runtime/src/hosted-search-contract.test.ts
@@ -1,3 +1,4 @@
+import { Buffer } from "node:buffer";
import { describe, expect, it } from "vitest";
import type { AssistantMessage } from "@earendil-works/pi-ai";
@@ -552,3 +553,60 @@ describe("pi-ai hosted web search: request params", () => {
});
});
+
+describe("pi-ai Codex hosted web search: request params", () => {
+ async function captureCodexParams(webSearch: boolean): Promise<AnyRecord> {
+ const { stream: streamCodex } = await import("@earendil-works/pi-ai/api/openai-codex-responses");
+ let payload: AnyRecord | undefined;
+ let fetches = 0;
+ const authPayload = Buffer.from(JSON.stringify({
+ "https://api.openai.com/auth": { chatgpt_account_id: "offline-test-account" },
+ })).toString("base64");
+ const stream = streamCodex(
+ {
+ id: "gpt-codex-test",
+ api: "openai-codex-responses",
+ provider: "openai-codex",
+ reasoning: true,
+ input: ["text"],
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
+ contextWindow: 128_000,
+ maxTokens: 8_192,
+ baseUrl: "http://127.0.0.1:43123",
+ webSearch,
+ } as never,
+ { messages: [] } as never,
+ {
+ apiKey: `e30.${authPayload}.offline-signature`,
+ transport: "sse",
+ onPayload: (body: AnyRecord) => {
+ payload = body;
+ throw new Error("stop after offline payload capture");
+ },
+ fetch: async () => {
+ fetches++;
+ throw new Error("the payload test must not make a request");
+ },
+ } as never,
+ );
+ expect((await stream.result()).stopReason).toBe("error");
+ expect(fetches).toBe(0);
+ expect(payload).toBeDefined();
+ return payload!;
+ }
+
+
+ it("attaches hosted search to Codex Responses only when enabled", async () => {
+ const enabled = await captureCodexParams(true);
+ expect(enabled.tools).toEqual([{ type: "web_search" }]);
+ expect(enabled.include).toEqual([
+ "reasoning.encrypted_content",
+ "web_search_call.action.sources",
+ ]);
+ expect(enabled.tool_choice).toBe("auto");
+
+ const disabled = await captureCodexParams(false);
+ expect(disabled.tools).toBeUndefined();
+ expect(disabled.include).toEqual(["reasoning.encrypted_content"]);
+ });
+});
diff --git a/packages/agent-runtime/src/hosted-search-estimation.test.ts b/packages/agent-runtime/src/hosted-search-estimation.test.ts
index 7e50ac700..151ec971d 100644
--- a/packages/agent-runtime/src/hosted-search-estimation.test.ts
+++ b/packages/agent-runtime/src/hosted-search-estimation.test.ts
@@ -160,6 +160,19 @@ describe("real dependency hosted-search estimation and requests", () => {
const decorated = { ...(content[0] as object), query: "ignored".repeat(1000), results: [{ url: "ignored".repeat(1000) }] };
expect(estimateMessageTokens(assistant([decorated]))).toBe(estimateMessageTokens(msg));
});
+
+ it("replays Responses search history to the Codex Responses adapter", () => {
+ const api = "openai-codex-responses";
+ const msg = assistant(search(api, 100), api);
+ const context = normalizeContext({ messages: [msg] });
+ const same = convertResponsesMessages(model(api), context, new Set(), {});
+ const other = convertResponsesMessages({ ...model(api), id: "other" }, context, new Set(), {});
+ expect(same).toHaveLength(1);
+ expect(same[0]).toMatchObject({ type: "web_search_call", id: "ws_1" });
+ expect(other).toHaveLength(0);
+ expect(estimateMessageTokens(msg, { ...model(api), id: "other" })).toBe(0);
+ expect(estimateMessageTokens(msg)).toBe(Math.ceil(JSON.stringify(same[0]).length / 4));
+ });
it("declares search content and events without fake name/arguments", () => {
const block: HostedSearchContent = { type: "hostedSearch", phase: "web_search_call", blockId: "legacy" };
const event: AssistantMessageEvent = { type: "hosted_search_update", contentIndex: 0, partial: assistant([block]) };
diff --git a/packages/agent-runtime/src/output-cap.test.ts b/packages/agent-runtime/src/output-cap.test.ts
index 1240981cf..0faaf69d8 100644
--- a/packages/agent-runtime/src/output-cap.test.ts
+++ b/packages/agent-runtime/src/output-cap.test.ts
@@ -208,6 +208,28 @@ describe("hosted search target model threading", () => {
expect(estimate).toBeGreaterThan(0);
});
+ it("charges Codex Responses search replay only to its source model", () => {
+ const codexModel = {
+ ...RESPONSES_MODEL,
+ api: "openai-codex-responses",
+ provider: "openai-codex",
+ id: "gpt-codex-test",
+ };
+ const codexContext = (model: string, size: number): OutputCapContext => ({
+ messages: [{
+ role: "assistant",
+ api: "openai-codex-responses",
+ provider: "openai-codex",
+ model,
+ content: [searchCall(size)],
+ }],
+ });
+ const same = estimateOutputCapInputTokens(codexContext("gpt-codex-test", 100), codexModel);
+ const other = estimateOutputCapInputTokens(codexContext("other-model", 100), codexModel);
+ expect(same).toBeGreaterThan(0);
+ expect(other).toBe(0);
+ });
+
it("leaves text, thinking and tool blocks unaffected by the target", () => {
const context: OutputCapContext = {
messages: [
diff --git a/packages/agent-runtime/src/provider-binding.test.ts b/packages/agent-runtime/src/provider-binding.test.ts
index 6d367e9e4..817047111 100644
--- a/packages/agent-runtime/src/provider-binding.test.ts
+++ b/packages/agent-runtime/src/provider-binding.test.ts
@@ -558,6 +558,44 @@ describe("buildProviderModel model-level wire API", () => {
});
});
+describe("buildProviderModel native web search capability", () => {
+ const catalogModel: ModelConfig = {
+ source: "generic",
+ name: "Configured web search model",
+ baseUrl: "https://chatgpt.com/backend-api",
+ reasoning: false,
+ input: ["text"],
+ contextWindow: 128_000,
+ maxTokens: 8_192,
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
+ };
+ const configuredModel = modelConfigWithBinding(catalogModel, {
+ contextWindow: 128_000,
+ maxTokens: 8_192,
+ thinkingLevels: ["off"],
+ nativeWebSearch: true,
+ });
+
+ it("forwards an opt-in only when the resolved wire supports it", () => {
+ const codex = buildProviderModel({
+ ...keyedProvider,
+ vendorKey: "openai-codex",
+ apiStyle: "openai_codex_responses",
+ modelConfig: configuredModel,
+ });
+ expect(codex.api).toBe("openai-codex-responses");
+ expect(codex.webSearch).toBe(true);
+
+ const completions = buildProviderModel({
+ ...keyedProvider,
+ apiStyle: "chat_completions",
+ modelConfig: configuredModel,
+ });
+ expect(completions.api).toBe("openai-completions");
+ expect(completions.webSearch).toBeUndefined();
+ });
+});
+
describe("GitHub Copilot transport identity", () => {
const provider: RuntimeProviderConfig = {
id: "copilot-account-row",
diff --git a/packages/agent-runtime/src/provider-binding.ts b/packages/agent-runtime/src/provider-binding.ts
index cc7b955b6..2b331cb25 100644
--- a/packages/agent-runtime/src/provider-binding.ts
+++ b/packages/agent-runtime/src/provider-binding.ts
@@ -32,6 +32,7 @@ import {
OPENCODE_GO_API_STYLE,
OPENCODE_GO_BASE_URL,
resolveApiStyle,
+ resolveNativeWebSearch,
deepseekRequestCompat,
zhipuRequestCompat,
type ThinkingLevel,
@@ -245,6 +246,13 @@ export function buildProviderModel(
api: binding.api,
provider: provider.id,
baseUrl,
+ webSearch:
+ resolveNativeWebSearch({
+ wireApi: binding.api,
+ modelWebSearch: catalogModel.webSearch,
+ }) === "on"
+ ? true
+ : undefined,
...(compat ? { compat } : {}),
...(Object.keys(modelHeaders).length > 0 ? { headers: modelHeaders } : {}),
} as Model<Api>;
diff --git a/packages/shared/src/native-web-search.test.ts b/packages/shared/src/native-web-search.test.ts
index a3db453ad..4a22b9c7a 100644
--- a/packages/shared/src/native-web-search.test.ts
+++ b/packages/shared/src/native-web-search.test.ts
@@ -12,64 +12,39 @@ import {
describe("resolveNativeWebSearch", () => {
it("turns on only for wires that define a hosted search tool", () => {
- expect(
- resolveNativeWebSearch({ wireApi: "anthropic-messages", modelWebSearch: true }),
- ).toBe("on");
- expect(
- resolveNativeWebSearch({ wireApi: "openai-responses", modelWebSearch: true }),
- ).toBe("on");
- expect(
- resolveNativeWebSearch({ wireApi: "azure-openai-responses", modelWebSearch: true }),
- ).toBe("on");
+ expect(resolveNativeWebSearch({ wireApi: "anthropic-messages", modelWebSearch: true })).toBe("on");
+ expect(resolveNativeWebSearch({ wireApi: "openai-responses", modelWebSearch: true })).toBe("on");
+ expect(resolveNativeWebSearch({ wireApi: "azure-openai-responses", modelWebSearch: true })).toBe("on");
+ expect(resolveNativeWebSearch({ wireApi: "openai-codex-responses", modelWebSearch: true })).toBe("on");
});
it("stays off for wires without a hosted search tool", () => {
- for (const wire of [
- "openai-completions",
- "openai-codex-responses",
- "google-generative-ai",
- "pi-messages",
- "",
- ]) {
+ for (const wire of ["openai-completions", "google-generative-ai", "pi-messages", ""]) {
expect(resolveNativeWebSearch({ wireApi: wire, modelWebSearch: true })).toBe("off");
}
});
it("requires the explicit binding opt-in; absence is off", () => {
expect(resolveNativeWebSearch({ wireApi: "openai-responses" })).toBe("off");
- expect(
- resolveNativeWebSearch({ wireApi: "openai-responses", modelWebSearch: false }),
- ).toBe("off");
- expect(
- resolveNativeWebSearch({ wireApi: "openai-responses", modelWebSearch: undefined }),
- ).toBe("off");
+ expect(resolveNativeWebSearch({ wireApi: "openai-responses", modelWebSearch: false })).toBe("off");
+ expect(resolveNativeWebSearch({ wireApi: "openai-responses", modelWebSearch: undefined })).toBe("off");
});
it("normalizes wire spelling before matching", () => {
- expect(
- resolveNativeWebSearch({ wireApi: " Anthropic-Messages ", modelWebSearch: true }),
- ).toBe("on");
+ expect(resolveNativeWebSearch({ wireApi: " Anthropic-Messages ", modelWebSearch: true })).toBe("on");
});
it("never infers support from unrelated inputs", () => {
- // A gateway on a chat-completions wire stays off no matter what the
- // binding says: the wire cannot carry the tool.
- expect(
- resolveNativeWebSearch({ wireApi: "openai-completions", modelWebSearch: true }),
- ).toBe("off");
+ expect(resolveNativeWebSearch({ wireApi: "openai-completions", modelWebSearch: true })).toBe("off");
});
});
describe("nativeWebSearchToolFor", () => {
it("maps each supported wire to its vendor tool shape", () => {
- expect(nativeWebSearchToolFor("anthropic-messages")).toEqual({
- type: "web_search_20250305",
- name: "web_search",
- });
+ expect(nativeWebSearchToolFor("anthropic-messages")).toEqual({ type: "web_search_20250305", name: "web_search" });
expect(nativeWebSearchToolFor("openai-responses")).toEqual({ type: "web_search" });
- expect(nativeWebSearchToolFor("azure-openai-responses")).toEqual({
- type: "web_search",
- });
+ expect(nativeWebSearchToolFor("azure-openai-responses")).toEqual({ type: "web_search" });
+ expect(nativeWebSearchToolFor("openai-codex-responses")).toEqual({ type: "web_search" });
});
it("returns undefined for wires without a tool shape", () => {
@@ -474,12 +449,13 @@ describe("nativeWebSearchSupportedOn", () => {
expect(nativeWebSearchSupportedOn("openai-responses")).toBe(true);
expect(nativeWebSearchSupportedOn("azure-openai-responses")).toBe(true);
expect(nativeWebSearchSupportedOn("anthropic-messages")).toBe(true);
+ expect(nativeWebSearchSupportedOn("openai_codex_responses")).toBe(true);
+ expect(nativeWebSearchSupportedOn("openai-codex-responses")).toBe(true);
});
it("rejects wires without a hosted search tool", () => {
expect(nativeWebSearchSupportedOn("chat_completions")).toBe(false);
expect(nativeWebSearchSupportedOn("openai-completions")).toBe(false);
- expect(nativeWebSearchSupportedOn("openai_codex_responses")).toBe(false);
expect(nativeWebSearchSupportedOn(undefined)).toBe(false);
expect(nativeWebSearchSupportedOn("")).toBe(false);
});
diff --git a/packages/shared/src/native-web-search.ts b/packages/shared/src/native-web-search.ts
index a94b34482..53ea07a47 100644
--- a/packages/shared/src/native-web-search.ts
+++ b/packages/shared/src/native-web-search.ts
@@ -2,8 +2,9 @@
* Evaluation helpers for the provider-hosted web search tool.
*
* - `nativeWebSearchSupportedOn` gates the settings checkbox. It accepts
- * stored apiStyle (`responses`, `anthropic_messages`) and resolved wire
- * APIs (`openai-responses`, `anthropic-messages`, `azure-openai-responses`).
+ * stored apiStyle (`responses`, `openai_codex_responses`, `anthropic_messages`)
+ * and resolved wire APIs (`openai-responses`, `openai-codex-responses`,
+ * `azure-openai-responses`, `anthropic-messages`).
* - `resolveNativeWebSearch` is the runtime decision: capable wire AND the
* binding opt-in. Adapters then key on `model.webSearch`, which
* `modelConfigWithBinding` copies from that opt-in.
@@ -15,11 +16,11 @@
* wire named here or it does not; guessing breeds silent behavior drift.
*/
-/** Wire APIs whose request format defines a provider-hosted search tool. */
export const NATIVE_WEB_SEARCH_WIRE_APIS = new Set([
"anthropic-messages",
"openai-responses",
"azure-openai-responses",
+ "openai-codex-responses",
]);
/** Tool definition attached to an anthropic-messages request. */
@@ -28,7 +29,7 @@ export const ANTHROPIC_WEB_SEARCH_TOOL = {
name: "web_search",
} as const;
-/** Tool definition attached to an openai-responses request. */
+/** Tool definition attached to OpenAI Responses-compatible requests. */
export const OPENAI_RESPONSES_WEB_SEARCH_TOOL = {
type: "web_search",
} as const;
@@ -53,13 +54,17 @@ export function nativeWebSearchToolFor(
| undefined {
const wire = wireApi.trim().toLowerCase();
if (wire === "anthropic-messages") return { ...ANTHROPIC_WEB_SEARCH_TOOL };
- if (wire === "openai-responses" || wire === "azure-openai-responses") {
+ if (
+ wire === "openai-responses" ||
+ wire === "azure-openai-responses" ||
+ wire === "openai-codex-responses"
+ ) {
return { ...OPENAI_RESPONSES_WEB_SEARCH_TOOL };
}
return undefined;
}
-const NATIVE_WEB_SEARCH_API_STYLES = new Set(["responses", "anthropic_messages"]);
+const NATIVE_WEB_SEARCH_API_STYLES = new Set(["responses", "anthropic_messages", "openai_codex_responses"]);
/**
* Whether a stored apiStyle or a resolved wire API can carry the hosted
diff --git a/patches/@[email protected] b/patches/@[email protected]
index 308dc7f30..02559264e 100644
--- a/patches/@[email protected]
+++ b/patches/@[email protected]
@@ -1,5 +1,5 @@
diff --git a/dist/api/anthropic-messages.js b/dist/api/anthropic-messages.js
-index d462f30..3d3dab1 100644
+index 5dd85f19db51b73dcd0c5c4cd8c28ad99e09ee6f..b7a8cfcac811512c1007c88f7e9d51e10c564a96 100644
--- a/dist/api/anthropic-messages.js
+++ b/dist/api/anthropic-messages.js
@@ -1,3 +1,6 @@
@@ -238,7 +238,7 @@ index d462f30..3d3dab1 100644
if (blocks.length === 0)
continue;
diff --git a/dist/api/azure-openai-responses.js b/dist/api/azure-openai-responses.js
-index ec1e206..572dce7 100644
+index ec1e2069102ed3165b2d702b9fc4105d5cf8f4e1..572dce7f2c1775a48bea869fcc0df7d09ef5644b 100644
--- a/dist/api/azure-openai-responses.js
+++ b/dist/api/azure-openai-responses.js
@@ -1,3 +1,5 @@
@@ -343,7 +343,7 @@ index ec1e206..572dce7 100644
if (options?.samplingParams) {
Object.assign(params, options.samplingParams);
diff --git a/dist/api/mistral-conversations.js b/dist/api/mistral-conversations.js
-index 3106c5d..8b209bb 100644
+index 3106c5d470dc3610c05d8ee153026df20f86f66e..8b209bb46809c394ffebfd11d5dfd2731c204310 100644
--- a/dist/api/mistral-conversations.js
+++ b/dist/api/mistral-conversations.js
@@ -645,6 +645,9 @@ function toChatMessages(messages, supportsImages) {
@@ -356,11 +356,28 @@ index 3106c5d..8b209bb 100644
toolCalls.push({
id: block.id,
type: "function",
+diff --git a/dist/api/openai-codex-responses.js b/dist/api/openai-codex-responses.js
+index dfdb6ec3651febbba6b8788f16118ecbf4b38fa8..9a3ad78a58359e8669d8a42a3f9264942044c5fd 100644
+--- a/dist/api/openai-codex-responses.js
++++ b/dist/api/openai-codex-responses.js
+@@ -411,6 +411,12 @@ function buildRequestBody(model, context, options, cacheSessionId, grammarToolIn
+ supportsOpenAIGrammarTools,
+ });
+ }
++ // Hosted web search (PI-Desktop): attach the server-side Responses tool only when opted in.
++ if (model.webSearch === true) {
++ body.tools = [...(body.tools ?? []), { type: "web_search" }];
++ body.include = [...new Set([...body.include, "web_search_call.action.sources"])];
++ }
++
+ if (options?.reasoningEffort !== undefined) {
+ const effort = options.reasoningEffort === "none"
+ ? model.thinkingLevelMap?.off === undefined
diff --git a/dist/api/openai-completions.js b/dist/api/openai-completions.js
-index 80720d0..68d3a57 100644
+index fc8e89382b75f259eb4f041b522840b0d603c033..ff54f13831eb17711b95c1984ad1b31c2d866ef8 100644
--- a/dist/api/openai-completions.js
+++ b/dist/api/openai-completions.js
-@@ -1039,21 +1039,27 @@ export function convertMessages(model, context, compat, options) {
+@@ -1041,21 +1041,27 @@ export function convertMessages(model, context, compat, options) {
if (preservedReasoningDetails) {
assistantMsg.reasoning_details = preservedReasoningDetails;
}
@@ -394,7 +411,7 @@ index 80720d0..68d3a57 100644
}
params.push(assistantMsg);
}
-@@ -1121,6 +1127,41 @@ export function convertMessages(model, context, compat, options) {
+@@ -1123,6 +1129,41 @@ export function convertMessages(model, context, compat, options) {
}
lastRole = msg.role;
}
@@ -436,7 +453,7 @@ index 80720d0..68d3a57 100644
return params;
}
function convertTools(tools, compat) {
-@@ -1265,6 +1306,9 @@ function detectCompat(model) {
+@@ -1267,6 +1308,9 @@ function detectCompat(model) {
requiresAssistantAfterToolResult: false,
requiresThinkingAsText: false,
requiresReasoningContentOnAssistantMessages: isDeepSeek,
@@ -446,7 +463,7 @@ index 80720d0..68d3a57 100644
thinkingFormat: isDeepSeek
? "deepseek"
: isZai
-@@ -1318,6 +1362,8 @@ function getCompat(model) {
+@@ -1320,6 +1364,8 @@ function getCompat(model) {
requiresThinkingAsText: model.compat.requiresThinkingAsText ?? detected.requiresThinkingAsText,
requiresReasoningContentOnAssistantMessages: model.compat.requiresReasoningContentOnAssistantMessages ??
detected.requiresReasoningContentOnAssistantMessages,
@@ -455,15 +472,8 @@ index 80720d0..68d3a57 100644
thinkingFormat: model.compat.thinkingFormat ?? detected.thinkingFormat,
openRouterRouting: model.compat.openRouterRouting ?? {},
vercelGatewayRouting: model.compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,
-@@ -1337,4 +1383,4 @@ function getCompat(model) {
- vllmPriority: model.compat.vllmPriority,
- };
- }
--//# sourceMappingURL=openai-completions.js.map
-\ No newline at end of file
-+//# sourceMappingURL=openai-completions.js.map
diff --git a/dist/api/openai-responses-shared.js b/dist/api/openai-responses-shared.js
-index 53597d2..763f99a 100644
+index 53597d2c3becdd2c03d4fd265c213a36b403f26b..763f99a6e7d726ff9fc1ed59a45f6c8173ad108a 100644
--- a/dist/api/openai-responses-shared.js
+++ b/dist/api/openai-responses-shared.js
@@ -1,3 +1,4 @@
@@ -638,7 +648,7 @@ index 53597d2..763f99a 100644
else if (event.type === "error") {
throw new Error(`Error Code ${event.code}: ${event.message}` || "Unknown error");
diff --git a/dist/api/openai-responses.js b/dist/api/openai-responses.js
-index 1396c8d..39d201f 100644
+index 1396c8d57ffb0e300382281a026d878e6a96b43a..39d201fc29deaa3cf19a8aaafe57ff15bc29cdf4 100644
--- a/dist/api/openai-responses.js
+++ b/dist/api/openai-responses.js
@@ -1,3 +1,5 @@
@@ -740,7 +750,7 @@ index 1396c8d..39d201f 100644
if (options?.samplingParams) {
Object.assign(params, options.samplingParams);
diff --git a/dist/api/simple-options.js b/dist/api/simple-options.js
-index 216a45f..23528b8 100644
+index 216a45feebc02acef047d1ff133729fb0751b76c..23528b801d65e33d22eb1d63ea49945d24a5e658 100644
--- a/dist/api/simple-options.js
+++ b/dist/api/simple-options.js
@@ -4,7 +4,7 @@ const MIN_MAX_TOKENS = 1;
@@ -753,7 +763,7 @@ index 216a45f..23528b8 100644
}
export function buildBaseOptions(model, context, options, apiKey) {
diff --git a/dist/auth/oauth/anthropic.js b/dist/auth/oauth/anthropic.js
-index 8692e90..0291387 100644
+index 8692e906caa2609396bdccae98d4d593e024ecf6..029138715f58dbb2e5825f9a2d0c182ed7e81f2a 100644
--- a/dist/auth/oauth/anthropic.js
+++ b/dist/auth/oauth/anthropic.js
@@ -140,21 +140,90 @@ async function startCallbackServer(expectedState) {
@@ -897,7 +907,7 @@ index 8692e90..0291387 100644
return {
type: "oauth",
diff --git a/dist/index.d.ts b/dist/index.d.ts
-index 5e8403d..50f728e 100644
+index 5e8403dd62895d30eb7d8e3f95b87d6535221839..50f728e4427e1cadb9aded7e35f3e44611eefc85 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -34,4 +34,7 @@ export * from "./utils/transcript.ts";
@@ -910,7 +920,7 @@ index 5e8403d..50f728e 100644
//# sourceMappingURL=index.d.ts.map
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
-index cf46c04..0fe0023 100644
+index cf46c043b854412d56c5d65230a509165229806e..0fe002385c3d9906709be1cce6867d0c30a3a151 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -21,4 +21,6 @@ export * from "./utils/transcript.js";
@@ -922,7 +932,7 @@ index cf46c04..0fe0023 100644
//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/dist/types.d.ts b/dist/types.d.ts
-index 5915ca6..f5d4114 100644
+index 5915ca64b161bc7bcebdb14d2ad1a2c18cde942e..f5d4114e94a27d72b33ba83cc45f1d09274c271c 100644
--- a/dist/types.d.ts
+++ b/dist/types.d.ts
@@ -267,6 +267,30 @@ export interface ToolCall {
@@ -1007,15 +1017,8 @@ index 5915ca6..f5d4114 100644
/**
* Maps pi thinking levels to provider/model-specific values.
* Missing keys use provider defaults. null marks a level as unsupported.
-@@ -833,4 +871,4 @@ export interface ImagesModel<TApi extends ImagesApi> extends Omit<Model<Api>, "a
- provider: ImagesProviderId;
- output: ("text" | "image")[];
- }
--//# sourceMappingURL=types.d.ts.map
-\ No newline at end of file
-+//# sourceMappingURL=types.d.ts.map
diff --git a/dist/utils/assistant-message-frame.d.ts b/dist/utils/assistant-message-frame.d.ts
-index 0820719..0584f68 100644
+index 08207197acab532d0f5f596363700a2d15a687d8..0584f6898e1d842c4414869b9080505b63c3a7b7 100644
--- a/dist/utils/assistant-message-frame.d.ts
+++ b/dist/utils/assistant-message-frame.d.ts
@@ -1,4 +1,4 @@
@@ -1037,7 +1040,7 @@ index 0820719..0584f68 100644
/**
* Encodes one assistant stream. `partial` remains a shared live accumulator;
diff --git a/dist/utils/assistant-message-frame.js b/dist/utils/assistant-message-frame.js
-index c0e0019..a86f593 100644
+index c0e00197b2bdd4c815106daa036d844c07aca800..a86f5939accd25110d7a4d1e0d268646691d321d 100644
--- a/dist/utils/assistant-message-frame.js
+++ b/dist/utils/assistant-message-frame.js
@@ -1,15 +1,30 @@
@@ -1192,7 +1195,7 @@ index c0e0019..a86f593 100644
if (frame.content.type !== "text") {
throw new Error(`text_start frame contains ${frame.content.type} content`);
diff --git a/dist/utils/estimate.d.ts b/dist/utils/estimate.d.ts
-index 6dcca6e..5ccaaf2 100644
+index 6dcca6eff16b95b83e047a6e27b65d9d7694bf2c..5ccaaf2358a0afeea3ce354e5799255ae8508f3d 100644
--- a/dist/utils/estimate.d.ts
+++ b/dist/utils/estimate.d.ts
@@ -1,4 +1,4 @@
@@ -1213,7 +1216,7 @@ index 6dcca6e..5ccaaf2 100644
//# sourceMappingURL=estimate.d.ts.map
\ No newline at end of file
diff --git a/dist/utils/estimate.js b/dist/utils/estimate.js
-index d04ff22..28564cc 100644
+index d04ff22cbe8d7357404b938e228b8e3a2dbdcb1d..28564cc73798163f7590290123b7476573d5bee5 100644
--- a/dist/utils/estimate.js
+++ b/dist/utils/estimate.js
@@ -1,95 +1,114 @@
@@ -1388,7 +1391,7 @@ index d04ff22..28564cc 100644
\ No newline at end of file
diff --git a/dist/utils/hosted-search.d.ts b/dist/utils/hosted-search.d.ts
new file mode 100644
-index 0000000..a76ae52
+index 0000000000000000000000000000000000000000..a76ae5269313931b8476e1f153e76792875ad54c
--- /dev/null
+++ b/dist/utils/hosted-search.d.ts
@@ -0,0 +1,10 @@
@@ -1404,7 +1407,7 @@ index 0000000..a76ae52
+export declare function validateHostedSearchMessages(messages: readonly Message[]): void;
diff --git a/dist/utils/hosted-search.js b/dist/utils/hosted-search.js
new file mode 100644
-index 0000000..b177a26
+index 0000000000000000000000000000000000000000..b98cb8d128310273014e4490e9c26144f45b56af
--- /dev/null
+++ b/dist/utils/hosted-search.js
@@ -0,0 +1,97 @@
@@ -1470,7 +1473,7 @@ index 0000000..b177a26
+ // Without a target, estimate conservatively; with one, preserve the adapter's model boundary.
+ const api = options?.api ?? (block.phase === "web_search_call" ? "openai-responses" : "anthropic-messages");
+ if (block.phase === "web_search_call") {
-+ if ((api !== "openai-responses" && api !== "azure-openai-responses") || options?.isSameModel === false)
++ if ((api !== "openai-responses" && api !== "azure-openai-responses" && api !== "openai-codex-responses") || options?.isSameModel === false)
+ return undefined;
+ return { ...(block.wire ?? { type: "web_search_call", id: block.blockId, status: "completed" }) };
+ }
@@ -1507,7 +1510,7 @@ index 0000000..b177a26
+}
diff --git a/dist/utils/local-request-error.d.ts b/dist/utils/local-request-error.d.ts
new file mode 100644
-index 0000000..a72f65b
+index 0000000000000000000000000000000000000000..a72f65b33c64b89f118a59bd286e62624711fd90
--- /dev/null
+++ b/dist/utils/local-request-error.d.ts
@@ -0,0 +1,15 @@
@@ -1528,7 +1531,7 @@ index 0000000..a72f65b
+export declare function prepareLocalRequest<T>(phase: LocalRequestErrorPhase, prepare: () => T): T;
diff --git a/dist/utils/local-request-error.js b/dist/utils/local-request-error.js
new file mode 100644
-index 0000000..4d276dd
+index 0000000000000000000000000000000000000000..4d276ddc8caee98dfeeeeaa9bcd234ad63dc414b
--- /dev/null
+++ b/dist/utils/local-request-error.js
@@ -0,0 +1,38 @@
@@ -1572,7 +1575,7 @@ index 0000000..4d276dd
+}
diff --git a/dist/utils/local-request-stream.d.ts b/dist/utils/local-request-stream.d.ts
new file mode 100644
-index 0000000..879b78c
+index 0000000000000000000000000000000000000000..879b78cbecb0cc2c4322049ed2c7d61f77be9375
--- /dev/null
+++ b/dist/utils/local-request-stream.d.ts
@@ -0,0 +1,3 @@
@@ -1581,7 +1584,7 @@ index 0000000..879b78c
+export declare function withLocalRequestErrors(model: Model<Api>, options: { signal?: AbortSignal } | undefined, prepare: () => AssistantMessageEventStream): AssistantMessageEventStream;
diff --git a/dist/utils/local-request-stream.js b/dist/utils/local-request-stream.js
new file mode 100644
-index 0000000..5c63b88
+index 0000000000000000000000000000000000000000..5c63b882ae4cb618e964c5d2ce8d3c18e0fe4688
--- /dev/null
+++ b/dist/utils/local-request-stream.js
@@ -0,0 +1,24 @@
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8f910383a..7d2e89e24 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -20,7 +20,7 @@ patchedDependencies:
hash: fd68dba636417b7920f03503bb8148d4f218bf3469babffa9d7c7863f956f344
path: patches/@[email protected]
'@earendil-works/[email protected]':
- hash: 04fc9262ce616ddb28a253b99ba59fa562e8d8a4c347fa2ea84f710d85d42971
+ hash: 6cf3998c09e8bba22cd63ceebe74a33332d9fd0c9ef3d5046941cb53513973f8
path: patches/@[email protected]
'@earendil-works/[email protected]':
hash: f343e44e55203618be186df28a5ae64e8d84992452b456169afc57b2eed5310e
@@ -45,7 +45,7 @@ importers:
devDependencies:
'@earendil-works/pi-ai':
specifier: 0.87.1
- version: 0.87.1(patch_hash=04fc9262ce616ddb28a253b99ba59fa562e8d8a4c347fa2ea84f710d85d42971)([email protected])([email protected])
+ version: 0.87.1(patch_hash=6cf3998c09e8bba22cd63ceebe74a33332d9fd0c9ef3d5046941cb53513973f8)([email protected])([email protected])
'@pi-desktop/agent-host':
specifier: workspace:*
version: link:../../packages/agent-host
@@ -234,7 +234,7 @@ importers:
version: 0.87.1(patch_hash=fd68dba636417b7920f03503bb8148d4f218bf3469babffa9d7c7863f956f344)([email protected])([email protected])
'@earendil-works/pi-ai':
specifier: 0.87.1
- version: 0.87.1(patch_hash=04fc9262ce616ddb28a253b99ba59fa562e8d8a4c347fa2ea84f710d85d42971)([email protected])([email protected])
+ version: 0.87.1(patch_hash=6cf3998c09e8bba22cd63ceebe74a33332d9fd0c9ef3d5046941cb53513973f8)([email protected])([email protected])
'@earendil-works/pi-coding-agent':
specifier: 0.87.1
version: 0.87.1(patch_hash=f343e44e55203618be186df28a5ae64e8d84992452b456169afc57b2eed5310e)([email protected])([email protected])
@@ -4823,7 +4823,7 @@ snapshots:
'@earendil-works/[email protected](patch_hash=fd68dba636417b7920f03503bb8148d4f218bf3469babffa9d7c7863f956f344)([email protected])([email protected])':
dependencies:
'@earendil-works/chord': 0.87.1
- '@earendil-works/pi-ai': 0.87.1(patch_hash=04fc9262ce616ddb28a253b99ba59fa562e8d8a4c347fa2ea84f710d85d42971)([email protected])([email protected])
+ '@earendil-works/pi-ai': 0.87.1(patch_hash=6cf3998c09e8bba22cd63ceebe74a33332d9fd0c9ef3d5046941cb53513973f8)([email protected])([email protected])
'@earendil-works/pi-telemetry': 0.87.1
diff: 8.0.4
ignore: 7.0.8
@@ -4838,7 +4838,7 @@ snapshots:
- ws
- zod
- '@earendil-works/[email protected](patch_hash=04fc9262ce616ddb28a253b99ba59fa562e8d8a4c347fa2ea84f710d85d42971)([email protected])([email protected])':
+ '@earendil-works/[email protected](patch_hash=6cf3998c09e8bba22cd63ceebe74a33332d9fd0c9ef3d5046941cb53513973f8)([email protected])([email protected])':
dependencies:
'@anthropic-ai/sdk': 0.124.0([email protected])
'@aws-sdk/client-bedrock-runtime': 3.1127.0
@@ -4863,7 +4863,7 @@ snapshots:
dependencies:
'@earendil-works/chord': 0.87.1
'@earendil-works/pi-agent-core': 0.87.1(patch_hash=fd68dba636417b7920f03503bb8148d4f218bf3469babffa9d7c7863f956f344)([email protected])([email protected])
- '@earendil-works/pi-ai': 0.87.1(patch_hash=04fc9262ce616ddb28a253b99ba59fa562e8d8a4c347fa2ea84f710d85d42971)([email protected])([email protected])
+ '@earendil-works/pi-ai': 0.87.1(patch_hash=6cf3998c09e8bba22cd63ceebe74a33332d9fd0c9ef3d5046941cb53513973f8)([email protected])([email protected])
'@earendil-works/pi-tui': 0.87.1
'@silvia-odwyer/photon-node': 0.3.4
chalk: 6.0.0
diff --git a/scripts/e2e/provider-api-style.tsx b/scripts/e2e/provider-api-style.tsx
index 0aedce10b..b6054e70c 100644
--- a/scripts/e2e/provider-api-style.tsx
+++ b/scripts/e2e/provider-api-style.tsx
@@ -5,6 +5,7 @@ import { I18nextProvider } from "react-i18next";
import { catalogs } from "@pi-desktop/i18n";
import type { ProviderPublic, ProviderCreateInput, ProviderUpdateInput } from "@pi-desktop/shared";
import { ProviderSetupDialog, type ProviderSetupDialogProps } from "../../apps/desktop/src/components/settings/ProviderSetupDialog";
+import { VendorAccountDialog, type VendorAccountForm } from "../../apps/desktop/src/components/settings/VendorAccountDialog";
import { API_STYLE_LABEL_KEYS, CUSTOM_PROVIDER_API_STYLES } from "../../apps/desktop/src/components/settings/provider-api-style";
import { copyProviderConfiguration } from "../../apps/desktop/src/components/settings/provider-copy";
import { api } from "../../apps/desktop/src/lib/api";
@@ -221,6 +222,22 @@ globalThis.providerApiStyleProbe = async () => {
assert(JSON.stringify(original) === before, "edit/copy mutated source object");
results.push(`${locale}:${style}:edit-change-copy-cancel`);
}
+ const codexAccount = { ...fixture("openai_codex_responses"), id: "codex-account", name: "OpenAI OAuth", vendorKey: "openai-codex", type: "native", protocol: "openai", authKind: "oauth" } satisfies ProviderPublic;
+ let savedCodexAccount: VendorAccountForm | undefined;
+ flushSync(() => root.render(<I18nextProvider i18n={i18n}><VendorAccountDialog provider={codexAccount} initialName={codexAccount.name} onClose={() => { closes++; }} onSave={(form) => { savedCodexAccount = structuredClone(form); }} saving={false} /></I18nextProvider>));
+ await pause(650);
+ const findWebSearch = () => [...document.querySelectorAll<HTMLInputElement>("input[type=checkbox]")].find((input) => input.closest("label")?.textContent?.trim() === i18n.t("settings.nativeWebSearch"));
+ const searchCheckbox = findWebSearch();
+ assert(searchCheckbox, `${locale}: Codex web search checkbox missing`);
+ assert(!searchCheckbox!.disabled, `${locale}: Codex web search checkbox stayed disabled`);
+ assert(!searchCheckbox!.checked, `${locale}: native search must default off`);
+ click(searchCheckbox);
+ await frame();
+ assert(findWebSearch()?.checked, `${locale}: Codex web search opt-in did not update`);
+ click(control("settings.save"));
+ await pause();
+ assert(savedCodexAccount?.models[0]?.nativeWebSearch === true, `${locale}: Codex web search opt-in was not saved`);
+ results.push(`${locale}:codex-native-search-opt-in`);
}
return { ok: true, scenarios: results, creates: creates.length, updates: updates.length,
apiBoundary: "stubbed", hostPersistence: "not exercised", liveModel: "not exercised" };