Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
The fix works. I ran the #55984 reproduction from source: on the base, the AI SDK request still goes to the original baseURL. With this PR it goes to the baseURL set in the model.request hook, and models without the override keep their original endpoint. The new tests pass here and fail on the base, the nearby AI SDK, session model request and model resolver tests pass, and packages/core type-checks cleanly.
Public API: the model.request session hook's baseURL value changes for AI SDK models. It used to be the placeholder https://ai-sdk.local; it is now the configured settings.baseURL, or undefined if none is set. Setting it now takes effect. This is backwards compatible: no plugin could usefully rely on the placeholder.
The only thing worth changing is the size of the tests: 354 lines for a 26-line fix (see the inline comment).
| const chunk = | ||
| 'data: {"id":"r","object":"chat.completion.chunk","created":0,"model":"api-model","choices":[{"index":0,"delta":{"content":"ok"},"finish_reason":"stop"}]}\n\ndata: [DONE]\n\n' | ||
|
|
||
| // Returning the original route from AISDK.route.with must fail the overridden cases. |
There was a problem hiding this comment.
These two new files add 354 lines of tests for a 26-line fix: three parameterised adapter cases, three more adapter scenarios, and a four-way session test that checks headers, auth, session IDs and HTTP hooks the fix doesn't touch. Could you cut this down to the core cases? One adapter test showing that route.with({ endpoint: { baseURL } }) changes the URL the SDK fetch receives while the original model keeps its URL, plus one session test showing a model.request hook redirecting an AI SDK request. The rest can be dropped, so the change stays small and easy to maintain.
There was a problem hiding this comment.
Addressed in c92fa95. Reduced the two files from 354 to 166 lines, keeping one adapter URL-override/original-model control and one real session model.request redirect. Removed the extra adapter scenarios, four-kind matrix and unrelated header/auth/session-ID/HTTP-hook assertions; production code is unchanged.
Both retained tests fail with the original aisdk.ts and pass with the fix. Ten randomized repetitions pass (20/20), the five-file nearby set passes (64/64), and core source/test typecheck, scoped lint and formatting pass. Independent review found no actionable defects. The PR description now distinguishes these results from the broader validation on the previous head.
There was a problem hiding this comment.
Thanks, this addresses it. I read c92fa95: aisdk.ts is unchanged, and the tests are down to the two core cases. One checks that route.with({ endpoint: { baseURL } }) changes the SDK fetch URL while the original model keeps its URL. The other checks that a session model.request hook redirects an AI SDK request and sees the configured baseURL. Nothing else from my review is outstanding.
Issue for this PR
Closes #55984.
Type of change
What does this PR do?
AI SDK routes currently discard
route.with({ endpoint: { baseURL } }), so a sessionmodel.requesthook cannot redirect a request. Clone the route with the requested setting and resolve its SDK model through the existing cache. Expose the configured endpoint to hooks, while retaining SDK defaults when none is configured. Original models and their cached endpoints remain reusable.How did you verify your code works?
Native Windows / Bun 1.4.2, against
devat37e3912d8using an existing dependency runtime:route.with({ endpoint: { baseURL } })changes the URL received by SDK fetch while the original model keeps its URL; onePluginHooks→SessionModelRequest.primary→ AI SDK request verifies that amodel.requesthook redirects the request. Responses are scripted; no provider calls.aisdk.tsfrom37e3912d8and pass with the fix. Ten randomized repetitions give 20 pass / 0 fail; five nearby AI SDK/model/session test files give 64 pass / 0 fail. These controls use the existing frozen dependency runtime and the repository's core test runner; onlyaisdk.tsis reversed for the failure control.f64a7fd; the reduction removes the extra adapter cases, four-kind session matrix, and header/authentication/session-ID/HTTP-hook assertions requested by review.f64a7fduses frozen dependencies, a private stdio-owned server, a disk-loaded Promise plugin, the real AI SDK bridge and a loopback fake provider. Reversing onlyaisdk.tsto37e3912d8leaves the request at/original/v1/chat/completions; restoring the fix sends it to/replacement/v2/chat/completions. Both controls execute the hook and preserve model/HTTP/session headers; the fixed run renders the fixture reply. The source is restored after the control.Broader validation at
f64a7fd: all 264 core test files were covered in eight bounded, separate-process batches (48 AI SDK/model/provider/session-request files: 560 pass / 0 fail; total: 5,184 pass / 1,220 skip / 277 fail, with no batch timeout). Every tracked core source/test blob matched this head after CRLF normalization. Replaying all 12 failing files on the same source/dependencies, first with onlyaisdk.tsreversed to37e3912d8and then with the fix restored, produced the same 277 failure occurrences in both controls (1,182 pass / 413 skip each). This is a single-module reversal, not a complete base checkout. The failures cover Windows shell/symlink/socket fixtures, snapshot fixtures and the external harness's XDG layout; correcting that layout separately gives 2 passes for the preload contract. No application/test changes were made for these environment failures.Core source/test typecheck passes. Root
bun run checkcompletes lint with 0 errors and SDK documentation checks with 0 problems, then stops on missing Astro and@tsconfig/node22dependencies in other workspace packages. The partitioned checks do not establish a green single-process full suite, a packaged CLI build or live-provider compatibility.AI-assisted implementation and review; reviewed and tested locally.
Screenshots / recordings
Not applicable; core request routing.
Checklist
Added by the opencode bot (AI-generated).
Public API: the model.request hook's baseURL for AI SDK models is now the configured settings.baseURL (was the placeholder https://ai-sdk.local) and setting it takes effect (backwards compatible)