-
-
Notifications
You must be signed in to change notification settings - Fork 199
fix(ai): current model seeds and a truthful Sync now notice #1811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c47a89b
fix(ai): ship the current OpenAI, Gemini, and Claude model seeds
ampagent 71b3f45
fix(ai): make the provider "Sync now" notice match the list on screen
ampagent d77216e
fix(ai): ignore Sync now after Cancel leaves the edit view
cursoragent 11f3b4a
fix(ai): keep background sync results when Cancel discards an edit
ampagent 7cf7434
fix(ai): count only source-reported models in the Sync now notice
ampagent 2949d3a
fix(ai): route every provider sync result through one landing path
ampagent b36170a
fix(ai): let GPT-5.6 and GPT-6 run function tools on Chat Completions
ampagent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| import { beforeEach, describe, expect, it } from "vitest"; | ||
| import type { AIProvider, Model } from "./Provider"; | ||
| import type { NormalizedChatRequest } from "./tools/NormalizedTools"; | ||
|
|
||
| import { storeState, mocks, makeApp } from "../../tests/helpers/ai/requestHarness"; | ||
|
|
||
| const { requestUrlMock, noticeMock } = mocks; | ||
|
|
||
| const { chatRequest } = await import("./OpenAIRequest"); | ||
|
|
||
| const openaiProvider: AIProvider = { | ||
| name: "OpenAI", | ||
| endpoint: "https://api.openai.com/v1", | ||
| kind: "openai", | ||
| apiKey: "sk", | ||
| models: [], | ||
| modelSource: "modelsDev", | ||
| }; | ||
|
|
||
| const gpt6: Model = { | ||
| name: "gpt-6-sol", | ||
| maxTokens: 1_050_000, | ||
| maxOutputTokens: 128_000, | ||
| supportsTemperature: false, | ||
| }; | ||
|
|
||
| // Exact live error for gpt-6-sol with function tools on /v1/chat/completions | ||
| // (2026-09-26); gpt-5.6-* and the other gpt-6-* models return the same text. | ||
| function toolsWhileReasoningFailure(model = "gpt-6-sol") { | ||
| return { | ||
| status: 400, | ||
| json: { | ||
| error: { | ||
| message: `Function tools with reasoning_effort are not supported for ${model} in /v1/chat/completions. To use function tools, use /v1/responses or set reasoning_effort to 'none'.`, | ||
| type: "invalid_request_error", | ||
| param: null, | ||
| code: null, | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function toolCallSuccess() { | ||
| return { | ||
| status: 200, | ||
| json: Promise.resolve({ | ||
| id: "1", | ||
| model: "gpt-6-sol", | ||
| choices: [ | ||
| { | ||
| finish_reason: "tool_calls", | ||
| index: 0, | ||
| message: { | ||
| role: "assistant", | ||
| content: null, | ||
| tool_calls: [ | ||
| { | ||
| id: "call_1", | ||
| type: "function", | ||
| function: { name: "get_weather", arguments: '{"city":"Paris"}' }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| usage: { prompt_tokens: 1, completion_tokens: 1, total_tokens: 2 }, | ||
| created: 0, | ||
| }), | ||
| }; | ||
| } | ||
|
|
||
| function toolRequest( | ||
| modelParams: Record<string, unknown> = {}, | ||
| ): NormalizedChatRequest { | ||
| return { | ||
| messages: [{ role: "user", content: "Weather in Paris?" }], | ||
| modelParams, | ||
| tools: [ | ||
| { | ||
| name: "get_weather", | ||
| description: "Get weather", | ||
| parameters: { | ||
| type: "object", | ||
| properties: { city: { type: "string" } }, | ||
| required: ["city"], | ||
| }, | ||
| }, | ||
| ], | ||
| toolChoice: "auto", | ||
| }; | ||
| } | ||
|
|
||
| function sentBody(callIndex: number): Record<string, unknown> { | ||
| return JSON.parse(requestUrlMock.mock.calls[callIndex][0].body as string); | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| requestUrlMock.mockReset(); | ||
| noticeMock.mockReset(); | ||
| storeState.disableOnlineFeatures = false; | ||
| }); | ||
|
|
||
| describe("function tools on models that reason by default", () => { | ||
| it("retries once with reasoning_effort 'none' when the model rejects tools while reasoning", async () => { | ||
| requestUrlMock | ||
| .mockReturnValueOnce(Promise.resolve(toolsWhileReasoningFailure())) | ||
| .mockReturnValueOnce(Promise.resolve(toolCallSuccess())); | ||
|
|
||
| const res = await chatRequest(makeApp(), "sk", gpt6, openaiProvider, toolRequest()); | ||
|
|
||
| expect(res.toolCalls?.map((call) => call.name)).toEqual(["get_weather"]); | ||
| expect(requestUrlMock).toHaveBeenCalledTimes(2); | ||
| expect(sentBody(0).reasoning_effort).toBeUndefined(); | ||
| expect(sentBody(1).reasoning_effort).toBe("none"); | ||
| expect(sentBody(1).tools).toEqual(sentBody(0).tools); | ||
| }); | ||
|
|
||
| it("keeps a reasoning effort the caller chose and surfaces the error", async () => { | ||
| requestUrlMock.mockReturnValueOnce( | ||
| Promise.resolve(toolsWhileReasoningFailure()), | ||
| ); | ||
|
|
||
| await expect( | ||
| chatRequest( | ||
| makeApp(), | ||
| "sk", | ||
| gpt6, | ||
| openaiProvider, | ||
| toolRequest({ reasoning_effort: "high" }), | ||
| ), | ||
| ).rejects.toThrow(/reasoning_effort/); | ||
| expect(requestUrlMock).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it("does not retry other 400s", async () => { | ||
| requestUrlMock.mockReturnValueOnce( | ||
| Promise.resolve({ | ||
| status: 400, | ||
| json: { | ||
| error: { | ||
| message: "Invalid schema for function 'get_weather'.", | ||
| type: "invalid_request_error", | ||
| }, | ||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| await expect( | ||
| chatRequest(makeApp(), "sk", gpt6, openaiProvider, toolRequest()), | ||
| ).rejects.toThrow(/Invalid schema/); | ||
| expect(requestUrlMock).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it("does not add reasoning_effort to a request without tools", async () => { | ||
| requestUrlMock.mockReturnValueOnce( | ||
| Promise.resolve(toolsWhileReasoningFailure()), | ||
| ); | ||
|
|
||
| await expect( | ||
| chatRequest(makeApp(), "sk", gpt6, openaiProvider, { | ||
| messages: [{ role: "user", content: "hi" }], | ||
| }), | ||
| ).rejects.toThrow(); | ||
| expect(requestUrlMock).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.