Skip to content

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

fix(runtime): explicitly disable unsupported Responses strict mode

jeffry88ef8ee9d9f5a0
diff --git a/docs/spec/03-runtime/11-provider-model-system.md b/docs/spec/03-runtime/11-provider-model-system.md
index 51ec593d9..0c47e037b 100644
--- a/docs/spec/03-runtime/11-provider-model-system.md
+++ b/docs/spec/03-runtime/11-provider-model-system.md
@@ -757,6 +757,17 @@ the TCP connection open cannot hold the turn after the final event. Pi-ai
1.0.0 includes this upstream fix. The 1.0.0 hosted-search patch does not need to
reapply the old 0.99.1 terminal-event hunk.
+### 16.2 Responses function tool strictness
+
+When the effective Responses adapter compatibility disables strict tool sampling,
+pi-ai sends `strict: false` on function declarations to override the endpoint's
+default. This applies to current `tools` and replayed declarations in
+`additional_tools` and `tool_search_output`. Function schemas retain their
+constraints, including `uniqueItems` for scheduled task weekdays, and local tool
+validation still rejects duplicate weekdays. With strict sampling support enabled,
+the adapter continues to honor constrained sampling and its existing default,
+including Codex's `strict: null`. Custom grammar tools keep their wire shape.
+
## 17. Multi-provider product rules
1. Multiple providers of the same `vendorKey` are allowed and independent (for
diff --git a/docs/spec/06-delivery/e2e/providers-and-models.md b/docs/spec/06-delivery/e2e/providers-and-models.md
index 95eab7eee..4a003db14 100644
--- a/docs/spec/06-delivery/e2e/providers-and-models.md
+++ b/docs/spec/06-delivery/e2e/providers-and-models.md
@@ -714,6 +714,21 @@ with only Host API controlled. Running-turn configuration remains queued.
- **Status**: Unit-covered (stream processor terminates on the terminal
event via the pi-ai patch); live-proxy scenario Draft
+## E2E-PROVIDER-responses-explicit-nonstrict
+
+- Complete a turn, then switch the same conversation to a custom Responses
+ model using default compatibility. Ask to update an existing weekly task
+ for two distinct weekdays. Activate `ScheduledTaskUpdate` via `ToolSearch`.
+- Verify the new request replays the prior turn. The activated function
+ declaration carries explicit `strict: false` and retains the weekday
+ uniqueness constraint. The runtime sends one update to the Host, replays
+ the result to the provider, and returns the assistant confirmation.
+- Run `node scripts/e2e-responses-tool-strictness.mjs <built sidecar.js>`
+ against the production sidecar bundle with a loopback provider and a fixture
+ Host. The runtime regression also covers current and replayed declarations,
+ strict-capable adapters, and local rejection of duplicate weekdays.
+- Spec: [Responses function tool strictness](../../03-runtime/11-provider-model-system.md#162-responses-function-tool-strictness).
+
## E2E-005E: DeepSeek thinking replay includes reasoning_content on aggregator endpoints
- **Preconditions**: An OpenAI-compatible provider whose base URL is not
diff --git a/packages/agent-runtime/src/responses-tool-strictness.test.ts b/packages/agent-runtime/src/responses-tool-strictness.test.ts
new file mode 100644
index 000000000..0d5bfc0b4
--- /dev/null
+++ b/packages/agent-runtime/src/responses-tool-strictness.test.ts
@@ -0,0 +1,158 @@
+import { zstdDecompressSync } from "node:zlib";
+import { type Context, type Message, type Tool, validateToolArguments } from "@earendil-works/pi-ai";
+import { Type } from "typebox";
+import { describe, expect, it } from "vitest";
+import { genericModelConfig } from "./model-capabilities.js";
+import { buildProviderModel, createProviderModels, type RuntimeProviderConfig } from "./provider-binding.js";
+import { scheduledToolDescriptions, scheduledToolParameters } from "./scheduled-tools.js";
+
+const provider: RuntimeProviderConfig = {
+ id: "custom-fixture", name: "Custom fixture", modelId: "responses-fixture",
+ apiStyle: "responses", baseUrl: "https://fixture.invalid/v1", apiKey: "fixture",
+ supportsReasoning: false, supportedThinkingLevels: ["off"],
+};
+const scheduledTools = ["ScheduledTaskCreate", "ScheduledTaskUpdate"].map((name) => ({
+ name,
+ description: scheduledToolDescriptions[name],
+ parameters: Type.Object(scheduledToolParameters[name]),
+}));
+const userMessage = { role: "user", content: "Schedule this for Monday and Wednesday.", timestamp: 1 } as const;
+
+type WireTool = { type: string; name: string; strict?: boolean | null; parameters?: object };
+type Payload = { tools?: WireTool[]; input: Array<{ type?: string; tools?: WireTool[] }> };
+
+async function request(
+ config: RuntimeProviderConfig,
+ context: Context,
+ entry: "stream" | "streamSimple" = "streamSimple",
+): Promise<Payload> {
+ const model = buildProviderModel(config);
+ const models = createProviderModels(config, model);
+ let payload: Payload | undefined;
+ const result = await models[entry](model, context, {
+ transport: "sse",
+ maxRetries: 0,
+ fetch: async (url, init) => {
+ const request = new Request(url, init);
+ expect(new URL(request.url).hostname).toBe("fixture.invalid");
+ const json = request.headers.get("content-encoding") === "zstd"
+ ? zstdDecompressSync(new Uint8Array(await request.arrayBuffer())).toString("utf8")
+ : await request.text();
+ payload = JSON.parse(json);
+ const event = { type: "response.completed", response: { id: "fixture", status: "completed", output: [] } };
+ return new Response(`event: ${event.type}\ndata: ${JSON.stringify(event)}\n\n`, {
+ headers: { "content-type": "text/event-stream" },
+ });
+ },
+ }).result();
+ expect(result.stopReason, result.errorMessage).toBe("stop");
+ if (!payload) throw new Error("No Responses request reached the fixture");
+ return payload;
+}
+
+function withCompat(compat: NonNullable<RuntimeProviderConfig["modelConfig"]>["compat"]): RuntimeProviderConfig {
+ const baseUrl = provider.baseUrl ?? "";
+ return {
+ ...provider,
+ modelConfig: {
+ ...genericModelConfig(provider.modelId, baseUrl),
+ source: "pi",
+ transcriptBinding: { modelId: provider.modelId, api: "openai-responses", baseUrl },
+ compat,
+ },
+ };
+}
+
+function expectScheduledTools(tools: WireTool[] | undefined, strict: false | null, deferLoading = false) {
+ expect(tools).toEqual(scheduledTools.map(({ parameters, ...tool }) => ({
+ ...tool,
+ type: "function",
+ strict,
+ parameters: JSON.parse(JSON.stringify(parameters)),
+ ...(deferLoading ? { defer_loading: true } : {}),
+ })));
+}
+
+describe("Responses function tool strictness", () => {
+ it.each([
+ ["default compatibility", provider, "streamSimple"],
+ ["explicit supportsStrictMode=false", withCompat({ supportsStrictMode: false }), "stream"],
+ ] as const)("serializes current scheduled tools with strict=false for %s", async (_name, config, entry) => {
+ const payload = await request(config, { messages: [userMessage], tools: scheduledTools }, entry);
+ expectScheduledTools(payload.tools, false);
+ });
+
+ it.each([
+ ["additional_tools", { supportsMidConvoSystemMessages: true, supportsAdditionalTools: true }],
+ ["tool_search_output", { supportsMidConvoSystemMessages: true, supportsToolSearch: true }],
+ ] as const)("serializes replayed scheduled tools in %s after a model switch", async (type, compat) => {
+ const messages: Message[] = [
+ { ...userMessage, content: "Help with my recurring tasks." },
+ {
+ role: "assistant", api: "openai-completions", provider: "previous-provider", model: "previous-model",
+ content: [{ type: "text", text: "Which days?" }], stopReason: "stop", timestamp: 2,
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0,
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },
+ },
+ { role: "system", content: "Scheduled tools are available.", timestamp: 3, toolsAdded: scheduledTools },
+ { ...userMessage, timestamp: 4 },
+ ];
+ const payload = await request(withCompat({ ...compat, supportsStrictMode: false }), { messages });
+ expect(payload.tools).toBeUndefined();
+ const index = payload.input.findIndex((item) => item.type === type);
+ expect(index).toBeGreaterThan(1);
+ expectScheduledTools(payload.input[index]?.tools, false, type === "tool_search_output");
+ });
+
+ it("preserves strict sampling for prefer and require on supporting providers", async () => {
+ const parameters = Type.Object({ text: Type.String() });
+ const tools: Tool[] = (["prefer", "require"] as const).map((strict) => ({
+ name: strict, description: strict, parameters, constrainedSampling: { type: "json_schema", strict },
+ }));
+ const payload = await request(withCompat({ supportsStrictMode: true }), { messages: [userMessage], tools });
+ expect(payload.tools).toEqual(tools.map(({ name }) => ({
+ type: "function", name, description: name, strict: true,
+ parameters: { ...parameters, additionalProperties: false },
+ })));
+ expect(parameters).not.toHaveProperty("additionalProperties");
+ });
+
+ it("preserves Codex's explicit strict=null", async () => {
+ const claim = btoa(JSON.stringify({ "https://api.openai.com/auth": { chatgpt_account_id: "fixture" } }));
+ const payload = await request({
+ ...provider, apiStyle: "openai_codex_responses", apiKey: `fixture.${claim}.fixture`,
+ }, { messages: [userMessage], tools: scheduledTools });
+ expectScheduledTools(payload.tools, null);
+ });
+
+ it("preserves custom grammar tools", async () => {
+ const tool: Tool = {
+ name: "grammar", description: "Grammar fixture", parameters: Type.Object({ input: Type.String() }),
+ constrainedSampling: { type: "grammar", variants: { openai_regex: "yes|no" } },
+ };
+ const payload = await request(withCompat({ supportsStrictMode: false, supportsOpenAIGrammarTools: true }), {
+ messages: [userMessage], tools: [tool],
+ });
+ expect(payload.tools).toEqual([{
+ type: "custom", name: tool.name, description: tool.description,
+ format: { type: "grammar", syntax: "regex", definition: "yes|no" },
+ }]);
+ });
+
+ it.each(scheduledTools)("preserves canonical weekday uniqueness and local validation for $name", async (tool) => {
+ const canonical = structuredClone(tool.parameters);
+ await request(provider, { messages: [userMessage], tools: [tool] });
+ expect(tool.parameters).toEqual(canonical);
+ expect(tool.parameters).toHaveProperty("properties.schedule.properties.weekdays.uniqueItems", true);
+ const call = { type: "toolCall" as const, id: "call_fixture", name: tool.name };
+ const args: Record<string, string> = tool.name === "ScheduledTaskCreate"
+ ? { title: "Fixture", prompt: "Run fixture", cadence: "weekly" }
+ : { id: "fixture" };
+ const schedule = { hour: 9, minute: 0, weekday: 0 };
+ const valid = { ...args, schedule: { ...schedule, weekdays: [0, 2] } };
+ expect(validateToolArguments(tool, { ...call, arguments: valid })).toEqual(valid);
+ expect(() => validateToolArguments(tool, {
+ ...call, arguments: { ...args, schedule: { ...schedule, weekdays: [0, 0] } },
+ })).toThrow(/schedule\.weekdays/);
+ });
+});
diff --git a/patches/@[email protected] b/patches/@[email protected]
index f4074daab..7fe190c98 100644
--- a/patches/@[email protected]
+++ b/patches/@[email protected]
@@ -457,7 +457,7 @@ index c1b6038c2220633a8caf710288a8f6e6301f7a28..2b6e6d5a48731a37812cd42740156fe8
openRouterRouting: model.compat.openRouterRouting ?? {},
vercelGatewayRouting: model.compat.vercelGatewayRouting ?? detected.vercelGatewayRouting,
diff --git a/dist/api/openai-responses-shared.js b/dist/api/openai-responses-shared.js
-index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d39472222693 100644
+index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..14bd2b28a9988025bc8bb397e340f8662e255e5a 100644
--- a/dist/api/openai-responses-shared.js
+++ b/dist/api/openai-responses-shared.js
@@ -1,3 +1,4 @@
@@ -487,7 +487,18 @@ index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d394
else if (block.type === "toolCall") {
const toolCall = block;
const [callId, itemIdRaw] = toolCall.id.split("|");
-@@ -458,6 +467,28 @@ export async function processResponsesStream(openaiStream, output, stream, model
+@@ -362,9 +371,7 @@ export function convertResponsesTools(tools, options) {
+ parameters: getJsonSchemaToolParameters(tool, strict === true),
+ ...(options?.toolSearchResult ? { defer_loading: true } : {}),
+ };
+- if (supportsStrictMode) {
+- functionTool.strict = strict;
+- }
++ functionTool.strict = supportsStrictMode ? strict : false;
+ return functionTool;
+ });
+ }
+@@ -458,6 +465,28 @@ export async function processResponsesStream(openaiStream, output, stream, model
stream.push({ type: "toolcall_start", contentIndex: slot.contentIndex, partial: output });
return slot;
}
@@ -516,7 +527,7 @@ index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d394
return undefined;
};
const getOrCreateSlot = (outputIndex, item) => {
-@@ -539,11 +570,11 @@ export async function processResponsesStream(openaiStream, output, stream, model
+@@ -539,11 +568,11 @@ export async function processResponsesStream(openaiStream, output, stream, model
const slot = getSlot(event.output_index, "thinking");
if (!slot)
continue;
@@ -530,7 +541,7 @@ index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d394
partial: output,
});
}
-@@ -563,11 +594,11 @@ export async function processResponsesStream(openaiStream, output, stream, model
+@@ -563,11 +592,11 @@ export async function processResponsesStream(openaiStream, output, stream, model
const slot = getSlot(event.output_index, "thinking");
if (!slot)
continue;
@@ -544,7 +555,7 @@ index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d394
partial: output,
});
}
-@@ -575,23 +606,44 @@ export async function processResponsesStream(openaiStream, output, stream, model
+@@ -575,23 +604,44 @@ export async function processResponsesStream(openaiStream, output, stream, model
const slot = getSlot(event.output_index, "text");
if (!slot)
continue;
@@ -593,7 +604,7 @@ index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d394
partial: output,
});
}
-@@ -599,8 +651,8 @@ export async function processResponsesStream(openaiStream, output, stream, model
+@@ -599,8 +649,8 @@ export async function processResponsesStream(openaiStream, output, stream, model
const slot = getSlot(event.output_index, "toolCall");
if (slot?.input.kind !== "json")
continue;
@@ -604,7 +615,7 @@ index 3901bfc4bc6dee0eb45a209dbcbdb59d6c55d054..60b63766576f463b83a964ef9b16d394
}
else if (event.type === "response.function_call_arguments.done") {
const slot = getSlot(event.output_index, "toolCall");
-@@ -680,9 +732,25 @@ export async function processResponsesStream(openaiStream, output, stream, model
+@@ -680,9 +730,25 @@ export async function processResponsesStream(openaiStream, output, stream, model
});
outputSlots.delete(event.output_index);
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2984ef9b4..6ce47146b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -206,7 +206,7 @@ overrides:
patchedDependencies:
'@earendil-works/[email protected]': f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da
- '@earendil-works/[email protected]': b7b4aa9dd844d3ab0678ff1a62a2e1bff5ceace6b6fa2fe8654eeadd39bce6ec
+ '@earendil-works/[email protected]': 39770d873534adf2d3dfc080f411c35c8049d23e5309e78b1aa691603ab31b82
'@earendil-works/[email protected]': b1ad25365da34b5862e5263254f499e8c28a8344d66609110df5d2061c519bf9
importers:
@@ -234,7 +234,7 @@ importers:
devDependencies:
'@earendil-works/pi-ai':
specifier: 1.5.2
- version: 1.5.2(patch_hash=b7b4aa9dd844d3ab0678ff1a62a2e1bff5ceace6b6fa2fe8654eeadd39bce6ec)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ version: 1.5.2(patch_hash=39770d873534adf2d3dfc080f411c35c8049d23e5309e78b1aa691603ab31b82)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-mcp':
specifier: 1.5.2
version: 1.5.2
@@ -438,7 +438,7 @@ importers:
version: 1.5.2(patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-ai':
specifier: 1.5.2
- version: 1.5.2(patch_hash=b7b4aa9dd844d3ab0678ff1a62a2e1bff5ceace6b6fa2fe8654eeadd39bce6ec)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ version: 1.5.2(patch_hash=39770d873534adf2d3dfc080f411c35c8049d23e5309e78b1aa691603ab31b82)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-coding-agent':
specifier: 1.5.2
version: 1.5.2(patch_hash=b1ad25365da34b5862e5263254f499e8c28a8344d66609110df5d2061c519bf9)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])
@@ -5149,7 +5149,7 @@ snapshots:
'@earendil-works/[email protected](patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
dependencies:
- '@earendil-works/pi-ai': 1.5.2(patch_hash=b7b4aa9dd844d3ab0678ff1a62a2e1bff5ceace6b6fa2fe8654eeadd39bce6ec)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ '@earendil-works/pi-ai': 1.5.2(patch_hash=39770d873534adf2d3dfc080f411c35c8049d23e5309e78b1aa691603ab31b82)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-schema': 1.5.2
transitivePeerDependencies:
- '@aws-sdk/credential-provider-node'
@@ -5164,7 +5164,7 @@ snapshots:
- ws
- zod
- '@earendil-works/[email protected](patch_hash=b7b4aa9dd844d3ab0678ff1a62a2e1bff5ceace6b6fa2fe8654eeadd39bce6ec)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
+ '@earendil-works/[email protected](patch_hash=39770d873534adf2d3dfc080f411c35c8049d23e5309e78b1aa691603ab31b82)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
dependencies:
'@anthropic-ai/sdk': 0.129.0([email protected])
'@aws-sdk/client-bedrock-runtime': 3.1127.0
@@ -5189,7 +5189,7 @@ snapshots:
- ws
- zod
- '@earendil-works/[email protected](patch_hash=b7b4aa9dd844d3ab0678ff1a62a2e1bff5ceace6b6fa2fe8654eeadd39bce6ec)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
+ '@earendil-works/[email protected](patch_hash=39770d873534adf2d3dfc080f411c35c8049d23e5309e78b1aa691603ab31b82)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])':
dependencies:
'@anthropic-ai/sdk': 0.129.0([email protected])
'@aws-sdk/client-bedrock-runtime': 3.1127.0
@@ -5221,7 +5221,7 @@ snapshots:
'@earendil-works/[email protected](patch_hash=b1ad25365da34b5862e5263254f499e8c28a8344d66609110df5d2061c519bf9)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])':
dependencies:
'@earendil-works/pi-agent-core': 1.5.2(patch_hash=f7df81a6d069cd0287276085d46d531684234acb7243dc032b1a1d73b17019da)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
- '@earendil-works/pi-ai': 1.5.2(patch_hash=b7b4aa9dd844d3ab0678ff1a62a2e1bff5ceace6b6fa2fe8654eeadd39bce6ec)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
+ '@earendil-works/pi-ai': 1.5.2(patch_hash=39770d873534adf2d3dfc080f411c35c8049d23e5309e78b1aa691603ab31b82)(@aws-sdk/[email protected])(@smithy/[email protected])([email protected])([email protected])([email protected])([email protected])
'@earendil-works/pi-codemode': 1.5.2
'@earendil-works/pi-mcp': 1.5.2
'@earendil-works/pi-tui': 1.5.2
diff --git a/scripts/e2e-responses-tool-strictness.mjs b/scripts/e2e-responses-tool-strictness.mjs
new file mode 100644
index 000000000..5f8f19d0b
--- /dev/null
+++ b/scripts/e2e-responses-tool-strictness.mjs
@@ -0,0 +1,78 @@
+#!/usr/bin/env node
+import assert from "node:assert/strict";
+import { mkdtemp } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join, resolve } from "node:path";
+import { functionResult, providerConfig, startProvider } from "./e2e/hosted-search-provider.mjs";
+import { fixtureHost, OfflineSidecar } from "./e2e/hosted-search-sidecar.mjs";
+
+const [bundle] = process.argv.slice(2);
+assert.ok(bundle, "Usage: node scripts/e2e-responses-tool-strictness.mjs <built sidecar.js>");
+const dir = await mkdtemp(join(process.env.PI_SCRATCH_DIR ?? tmpdir(), "responses-tool-strictness-"));
+console.log(`Loopback evidence directory: ${dir}`);
+
+const update = { id: "fixture-task", schedule: { hour: 9, minute: 0, weekday: 0, weekdays: [0, 2] } };
+const priorReply = "The existing weekly task is fixture-task.";
+const hostReply = "FIXTURE_SCHEDULE_UPDATED";
+const finalReply = "The task now runs at 09:00 on Monday and Wednesday.";
+const provider = await startProvider(dir, (body, requests) => {
+ const previous = requests.length === 1;
+ assert.equal(body.model, previous ? "previous-model" : "custom-responses-model");
+ if (previous) return { text: priorReply };
+ assert.ok(body.input.some((item) => item.role === "assistant" &&
+ item.content?.some((part) => part.text === priorReply)), "The switched model must receive the preceding assistant turn");
+ if (requests.length === 2) {
+ return { tool: { name: "ToolSearch", args: { query: "ScheduledTaskUpdate" } } };
+ }
+ assert.match(functionResult(body, "ToolSearch"), /Activated on-demand tools: ScheduledTaskUpdate/);
+ const tool = body.tools.find((item) => item.type === "function" && item.name === "ScheduledTaskUpdate");
+ assert.equal(tool?.strict, false, "ScheduledTaskUpdate must declare strict=false");
+ assert.equal(tool.parameters.properties.schedule.properties.weekdays.uniqueItems, true);
+ if (requests.length === 3) return { tool: { name: "ScheduledTaskUpdate", args: update } };
+ assert.equal(requests.length, 4, "Exactly one provider continuation must follow the tool result");
+ assert.match(functionResult(body, "ScheduledTaskUpdate"), new RegExp(hostReply));
+ return { text: finalReply };
+});
+
+const history = [];
+const fixture = fixtureHost({ history });
+let executions = 0;
+const host = (method, params) => {
+ if (method !== "tools.execute") return fixture(method, params);
+ assert.equal(params.toolName, "ScheduledTaskUpdate");
+ assert.deepEqual(params.args, update);
+ executions++;
+ return { ok: true, content: hostReply };
+};
+
+let sidecar;
+try {
+ sidecar = await OfflineSidecar.start(resolve(bundle), join(dir, "runtime"), host, 15_000);
+ const config = {
+ sessionId: "responses-strictness", mode: "agent", thinkingLevel: "off", infiniteProviderRetry: false,
+ commandShell: { id: "bash", label: "Bash", dialect: "posix", available: true, isDefault: true },
+ scratchDir: dir, projectPath: dir, pluginTools: [], pluginSkills: [], trustedExtensions: [],
+ };
+ const previous = providerConfig(provider.baseUrl, "previous-model");
+ previous.modelConfig.compat = { supportsStrictMode: true };
+ await sidecar.prompt({ ...config, provider: previous }, "Which weekly task can I update?");
+ assert.ok([...sidecar.messages.values()].some((message) => message.content === priorReply));
+ // Electron normally persists the user and assistant rows outside the sidecar.
+ for (const message of sidecar.messages.values()) {
+ if (!history.some((entry) => entry.id === message.id)) history.push(message);
+ }
+ history.sort((left, right) => Date.parse(left.createdAt) - Date.parse(right.createdAt));
+ await sidecar.prompt({ ...config, provider: providerConfig(provider.baseUrl, "custom-responses-model") },
+ "Move that weekly task to 09:00 on Monday and Wednesday.");
+ assert.equal(executions, 1);
+ provider.check();
+ assert.equal(provider.requests.length, 4);
+ assert.ok([...sidecar.messages.values()].some((message) => message.content === finalReply));
+ console.log("PASS scheduled update after a Responses model switch (4 HTTP requests, 1 Host tool call)");
+} catch (error) {
+ provider.check();
+ throw error;
+} finally {
+ try { await sidecar?.stop(); }
+ finally { await provider.close(); }
+}