Repository navigation
refactor(core)!: provider results carry request and response information as upstream does - #219
Draft
cunninghamcard-bit wants to merge 14 commits into
Draft
cunninghamcard-bit wants to merge 14 commits into
cunninghamcard-bit wants to merge 14 commits into
Conversation
… upstream does What: `GenerateResult` has `request: Option<RequestInfo>` and `response: Option<ResponseInfo>`; `ResponseInfo` holds the response id, timestamp and model id next to headers and body. `StreamResult` has `request` and `response: Option<StreamResponseInfo>` (headers only). The flat `request_body` and `response_headers` fields are removed, and `response` is no longer required. Vendors, tools, FFI and tests build and read the new fields. The call layer fills a missing response id, timestamp and model id where upstream `generateText` and `streamText` do, so a provider no longer has to invent them. Why: this is the shape of upstream's `LanguageModelV4GenerateResult` and `LanguageModelV4StreamResult`. Before, a provider had to return response metadata even when the API gave none, and the response body had no place. Kept on purpose: the user-facing results and their JSON do not change. The `raw` field of `GenerateTextResult` still serializes the flat keys through a small adapter, because six language bindings parse that shape; it goes away with `raw` in the user-result pull request. No cassette or fixture changes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
…ds as breaking The provider trait output changes shape, so implementers of a custom provider need the old and new field names side by side. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
Why: carry the media-type, text-data and tool-result alias fixes up the stack so every branch above the prompt types has them. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
Why: carry the tool, content, provider-option and prompt type changes up the stack. This branch's request and response information is kept and the newly arrived code is converted to it. Hand-written tests that no longer compile are deleted. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
What: removes 86 test functions and in-file test modules that the branch below had deleted and the last merge resolution restored. Why: the project keeps cassette replays, upstream samples and contract fixtures as its tests. The difference from the branch below is now only this branch's own work on request and response information. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
Why: carry the tag spelling fix up the stack. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
What: removes the adapter that re-serialized GenerateTextResult.raw into an earlier flat JSON. raw now serializes the provider result directly, with its request and response information. The language bindings' result types follow. Why: the adapter was a second JSON path for one value and dropped the response body. The Go, Java, Kotlin, Swift and Flutter changes are not compiled here. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
…ontract fixtures Why: carry up the stack the source union, the removal of the separate thought-signature field, the deletion of the self-generated contract fixtures and the changes below this branch. This branch's code is converted to them. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
…st and response on results What: the call-layer stream no longer emits a separate metadata event; response information arrives on the finish step, and an empty provider stream is NoOutputGeneratedError. GenerateTextResult and the stream aggregate carry request body and response id, timestamp, model id, headers and body from the provider result. OpenAI Responses and Azure expose the request body without the stream flag added for sending. Why: upstream surfaces request and response this way and has no public metadata event; the review found the extra event and the missing fields. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
Why: carry up the stack the fixes made after the third independent review on the branches below; this branch's code is converted to them. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
Why: carry up the stack the fixes made after the third independent review on the branches below; this branch's code is converted to them. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
Why: carry up the stack the fixes made after the third independent review on the branches below; this branch's code is converted to them. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
Why: carry the formatting commit up the stack; no code change. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Move language-model request and response information into the provider result objects and carry it into the call-layer results, following
LanguageModelV4GenerateResult,LanguageModelV4StreamResult,generateText, andstreamText. This pull request is based onrfc-0036/provider-prompt-typesand precedesrfc-0036/factory-test-removal. It removes the old flat JSON adapter, separates public text-stream chunks from provider chunks, and absorbs provider response metadata into the completed step. Provider implementations and language bindings are updated for these changes.Before and after
GenerateResultWireflattened request body and response headers during serializationGenerateResultserializes directly with optionalrequest: RequestInfoandresponse: ResponseInfo, corresponding toLanguageModelV4GenerateResultGenerateResponseandStreamResponsetypesResponseInfocontains optional id, timestamp, model id, headers, and body;StreamResponseInfocontains optional headers, as inLanguageModelV4StreamResultGenerateTextResult.requestcarries the provider request andresponsecarries metadata, headers, and body, followinggenerate-text.ts; missing metadata gets call-layer defaultsGenerateTextResult.rawGenerateResultdirectly. The call layer moves request and response into its top-level fields, leaving those fields empty inrawTextStreamPartwas an alias of the provider union and exposed response metadata eventsTextStreamPartenum receives content chunks; provider metadata is absorbed and exposed throughFinishStep.response, followingstream-text.tsNoOutputGenerated, and consumption returns that error, following the upstreamNoOutputGeneratedErrorpathStreamTextResultAggregatedcarries request information and the last step's response metadata and headersstream: truestream: true; the returned request body excludes it, followingopenai-responses-language-model.tsUpstream's
Dateandnumbertypes are compile-time constraints, not runtime validation in these result types. Rust retainsStringtimestamps andu32token counts. Request and response bodies remainValue, which cannot represent every value allowed by upstream'sunknown.Tests
Earlier deletions of self-generated contract tests and hand-written tests remain in the stack. This branch retains upstream-ported tests and cassette replays;
cassette_full_test.rsnow matchesTextStreamPart. Existing end-to-end stream assertions are migrated toFinishStepfollowed byFinish, and output round-trip callers usegenerate_text_result_to_chat_completionto read call-layer response metadata. Those hand-written end-to-end and round-trip test files still exist in this branch; this pull request does not claim they were deleted or ported from upstream. Cassette payloads andfixtures/are unchanged.Not in this pull request
Optionvalues serialized as null where not omitted, and generated Node types with required-nullable fields. These representations are not claimed to match upstream's optional properties.ModelMessagetool-result shape remains pending the maintainer's decision. The new public stream enum still carries the providerToolResultpayload; it does not complete the call-layer tool-result and error separation. The stream also retains its RustResulterror channel.rfc-0036/vendor-alignment.Not verified
No cargo command or runtime test was run for this documentation update. Go, Java, Kotlin, Swift, and Flutter files edited on this branch were not compiled locally. Node
npm testand Pythonpytestwere not run. CI YAML was only syntax-checked; CI execution is not verified. Providers without corresponding source in the local upstream packages were not independently checked for behavioral parity.Verification
Gate on the final commit
6a1da337:cargo fmt --check,cargo clippy --workspace --all-targets -D warnings,cargo doc, tests of core, provider-utils, providers, ffi, web, replay and cli: 2,316 passed, 0 failed; Node and Python bindingscargo check; provider boundary script;gen_ts_types.py --check,gen_providers_doc.py --check. Cassettes andfixtures/aisdkunchanged relative to the base. 61 files, +986 / −627.🤖 Generated with Claude Code
https://claude.ai/code/session_01WGwanvo9WLU9HWD7sRR8TS