Repository navigation
feat: allow Open Responses extension codecs to explicitly opt in to bare tool, item, and event discriminators - #19939
Conversation
Co-authored-by: me2seeks <[email protected]>
Feature reviewOutcome: changes-required Implements featureStatus: fully-implements The new bareToolType, bareItemTypes, and bareEventTypes fields are explicitly registered in createOpenResponsesExtensionRegistry and used across tool/tool-choice encoding, generate and stream decoding, fallback history encoding, and lossless replay. Exact lookup, duplicate rejection, core-discriminator collision checks, documentation, an example, and a patch changeset are present. Concerns: none. Side effectsRisk: low Runtime dispatch remains fail-closed: open-responses-language-model.ts performs exact registry lookups before invoking a codec, and unregistered bare events and items continue through normal core handling or are ignored. Concerns: none. PerformanceRisk: low The implementation adds small registration-time arrays and set/map lookups; request and response paths retain constant-time registry dispatch without new network, polling, or unbounded processing. Concerns: none. Backwards compatibilityRisk: medium Existing runtime behavior is preserved, but open-responses-extension.ts widens the contextual decodeItem and decodeEvent discriminator types from namespaced template literals to string for every extension, including existing namespaced-only codecs. Concerns:
Breaking changesRisk: medium The public experimental callback signatures changed from OpenResponsesExtensionItem/Event with namespaced type defaults to OpenResponsesExtensionItem and OpenResponsesExtensionEvent, producing a source-level TypeScript regression for existing consumers. Concerns:
ArchitectureRisk: low All production changes remain localized to @ai-sdk/open-responses and reuse its existing codec registry, conversion, decoding, and replay ownership; no cross-package src imports, new dependencies, or provider-layer boundary violations were introduced. Concerns: none. Change scopeStatus: minimal The nine changed files are limited to the extension registry and dispatch paths, focused tests and type tests, provider documentation, one runnable example, and the required @ai-sdk/open-responses changeset. Concerns: none. SecurityRisk: low assertBareType rejects empty, namespaced, and core discriminators; registry maps reject duplicate ownership; decoding and replay require exact registered values; and the documentation tells codecs to validate all non-discriminator fields and warns about persisted opaque metadata. Concerns: none. TestingStatus: needs-more Runtime coverage exercises registration, collision rejection, request encoding, generate/stream decoding, unknown values, and both replay paths, but the type tests do not protect existing namespaced callback discriminator types. Concerns:
VerificationInspected the complete origin/main...HEAD diff and surrounding Open Responses API, registry, conversion, streaming, exports, documentation, example, and changeset code. @ai-sdk/open-responses type-check passed; build passed; focused formatting/lint checks passed; Node and Edge suites each passed 112 tests; the bare-extension example ran and demonstrated encoded tools, decoded calls, and replay. A no-file TypeScript compatibility probe reported 0 diagnostics against origin/main and 2 TS2322 diagnostics against the PR for existing namespaced callback usage. |
Co-authored-by: Gregor Martynus <[email protected]>
|
Addressed PR comment 5458212783.
Implemented the compatibility fix. The public extension type is now discriminated by |
Feature reviewOutcome: changes-required Implements featureStatus: fully-implements The dedicated bareToolType, bareItemTypes, and bareEventTypes registrations require allowBareTypes: true and are used for exact tool/tool-choice encoding, generate and stream decoding, fallback history encoding, and lossless replay. Registry validation rejects unknown ownership, duplicates, namespaced values in bare fields, and core discriminator collisions. Concerns: none. Side effectsRisk: low Runtime dispatch remains fail-closed: open-responses-language-model.ts invokes codecs only after exact registry lookup, while unregistered bare items and events are ignored or continue through existing core handling. Concerns: none. PerformanceRisk: low The implementation adds bounded registration-time validation and constant-time Map/Set lookups without new network operations or unbounded processing. Concerns: none. Backwards compatibilityRisk: medium Existing namespaced callback discriminator types and runtime behavior are preserved, but the exported Experimental_OpenResponsesExtension changed from an interface on origin/main to a discriminated union type alias. Concerns:
Breaking changesRisk: medium Changing the public Experimental_OpenResponsesExtension from an extendable/implementable interface to a union type removes supported TypeScript composition behavior, even though ordinary object-literal namespaced codecs still compile. Concerns:
ArchitectureRisk: low Production changes remain localized to @ai-sdk/open-responses and reuse its existing registry, conversion, decoding, and replay ownership without cross-package src imports or new dependencies. Concerns: none. Change scopeStatus: minimal All nine changed files are directly relevant: localized implementation paths, runtime and type tests, provider documentation, one runnable example, and the required patch changeset. Concerns: none. SecurityRisk: low Bare values require explicit opt-in, exact registration, valid JSON objects, and non-core/non-namespaced discriminators; arbitrary unknown JSON is not passed to codecs or replayed. Concerns: none. TestingStatus: needs-more Node and Edge each pass 113 tests and coverage includes registration, collisions, encoding, generation, streaming, unknown values, callback behavior, and both replay paths, but public-type compatibility coverage is incomplete. Concerns:
VerificationInspected the complete origin/main...HEAD diff, surrounding Open Responses API and provider code, exports, documentation, example, changeset, and architecture boundaries. |
Co-authored-by: Gregor Martynus <[email protected]>
|
Addressed PR comment 5458517193.
Restored Experimental_OpenResponsesExtension as an extendable and implementable interface for existing namespaced codecs. Added Experimental_OpenResponsesBareExtension for the new discriminated bare opt-in shape, updated provider settings and internal registry types to accept both, and updated documentation and the example accordingly. Added compile-time regression coverage for both interface extension and class implementation; focused and repository-wide verification passed. |
Feature reviewOutcome: approved Implements featureStatus: fully-implements Experimental_OpenResponsesBareExtension adds explicit allowBareTypes, bareToolType, bareItemTypes, and bareEventTypes registration. Registry lookups cover tool and tool-choice encoding, generate and stream decoding, fallback history encoding, and lossless replay while retaining namespaced validation. Concerns: none. Side effectsRisk: low Dispatch remains exact and fail-closed: response events and items invoke codecs only through byEventType and byItemType matches, while unregistered values continue through existing core handling or are ignored. Concerns: none. PerformanceRisk: low The change adds bounded registration-time validation and constant-time Map lookups; history handling only combines the small registered item-type arrays. Concerns: none. Backwards compatibilityRisk: low Experimental_OpenResponsesExtension remains an extendable and implementable namespaced interface with its original callback discriminator types. Compile-time tests cover object literals, interface extension, and class implementation, while provider settings are additively widened to accept the new bare variant. Concerns: none. Breaking changesRisk: none No existing exports, accepted namespaced registrations, defaults, wire outputs, or replay formats are removed or narrowed. New generic parameters retain namespaced defaults, and bare behavior requires a new explicit type and opt-in. Concerns: none. ArchitectureRisk: low Production changes remain localized to @ai-sdk/open-responses and extend its existing codec registry and conversion paths. No new dependencies, cross-package src imports, or provider-layer boundary violations were introduced. Concerns: none. Change scopeStatus: minimal All 11 changed files directly support the feature: registry and dispatch implementation, focused runtime and type tests, provider documentation, one runnable example, public export, and the required patch changeset. Concerns: none. SecurityRisk: low Bare registrations must be explicit, non-empty, non-namespaced, non-core, and unique. Callback outputs and replay items are validated as JSON objects with exactly registered types, and documentation requires codecs to validate remaining fields and warns about persisted opaque metadata. Concerns: none. TestingStatus: appropriate Coverage includes registration validation, namespace and core collisions, duplicates, tool and tool-choice encoding, generate and stream decoding, unknown values, callback behavior, fallback history, lossless replay, and public type compatibility in both Node and Edge environments. Concerns: none. VerificationInspected the complete origin/main...HEAD diff and surrounding API, registry, conversion, streaming, exports, documentation, example, and changeset. git diff --check passed; focused Ultracite checks passed; @ai-sdk/open-responses type-check and build passed; Node and Edge suites each passed 113 tests; and the bare-extension example successfully demonstrated encoded tools, decoded calls, and replay of opaque wire metadata. |
Register DeepSeek hosted web_search codecs on createOpenResponses. The runtime already pins @ai-sdk/[email protected]; until vercel/ai#19939 ships allowBareTypes, map only DeepSeek's documented bare discriminators at the network boundary. Hosted search stays fail-closed. Generated-by: Cursor Cloud Agent (Grok 4.6)
Register DeepSeek hosted web_search codecs on createOpenResponses. The runtime already pins @ai-sdk/[email protected]; until vercel/ai#19939 ships allowBareTypes, map only DeepSeek's documented bare discriminators at the network boundary. Hosted search stays fail-closed. Generated-by: Cursor Cloud Agent (Grok 4.6)
Register DeepSeek hosted web_search codecs on createOpenResponses. The runtime already pins @ai-sdk/[email protected]; until vercel/ai#19939 ships allowBareTypes, map only DeepSeek's documented bare discriminators at the network boundary. Hosted search stays fail-closed. Generated-by: Cursor Cloud Agent (Grok 4.6)
Register DeepSeek hosted web_search codecs on createOpenResponses. The runtime already pins @ai-sdk/[email protected]; until vercel/ai#19939 ships allowBareTypes, map only DeepSeek's documented bare discriminators at the network boundary. Hosted search stays fail-closed. Generated-by: Cursor Cloud Agent (Grok 4.6)
Register DeepSeek hosted web_search codecs on createOpenResponses. The runtime already pins @ai-sdk/[email protected]; until vercel/ai#19939 ships allowBareTypes, map only DeepSeek's documented bare discriminators at the network boundary. Hosted search stays fail-closed. Generated-by: Cursor Cloud Agent (Grok 4.6)
Register DeepSeek hosted web_search codecs on createOpenResponses. The runtime already pins @ai-sdk/[email protected]; until vercel/ai#19939 ships allowBareTypes, map only DeepSeek's documented bare discriminators at the network boundary. Hosted search stays fail-closed. Generated-by: Cursor Cloud Agent (Grok 4.6)
Register DeepSeek hosted web_search codecs on createOpenResponses. The runtime already pins @ai-sdk/[email protected]; until vercel/ai#19939 ships allowBareTypes, map only DeepSeek's documented bare discriminators at the network boundary. Hosted search stays fail-closed. Generated-by: Cursor Cloud Agent (Grok 4.6)
|
🚀 Published in:
|
Background
Responses-compatible implementations may document legacy bare extension discriminators that cannot be represented by the existing namespaced codec API, otherwise requiring provider forks or request-mutating wrappers.
Summary
Adds explicit bare tool, item, and event registration behind allowBareTypes: true, with exact registry dispatch, namespace and core-type collision validation, duplicate rejection, request tool and tool-choice encoding, generation and streaming decoding, fallback history encoding, and lossless replay. Namespaced codecs retain their original callback discriminator types and extendable Experimental_OpenResponsesExtension interface, while bare codecs use Experimental_OpenResponsesBareExtension.
Testing
Runtime and compile-time coverage verifies namespaced compatibility, interface extension and class implementation, bare opt-in and validation, duplicate and core collisions, request encoding, generation and stream decoding, unknown-value rejection, callback behavior, and lossless and fallback history replay. Focused Node and Edge suites each passed 113 tests, and repository-wide tests passed.
End-to-end Validation
Documentation
Documents portable namespaced codecs and non-portable bare registrations, the dedicated bare extension type and required compatibility opt-in, validation and fail-closed behavior, codec responsibilities, persistence considerations, and consumer usage. Includes a runnable bare-extension example and patch changeset.
Related Issues
Fixes #19933