Skip to content

feat: allow Open Responses extension codecs to explicitly opt in to bare tool, item, and event discriminators - #19939

Merged
gr2m merged 5 commits into
mainfrom
feature-implementation-19933-20260828175750449696
Sep 28, 2026
Merged

gr2m merged 5 commits into
mainfrom
feature-implementation-19933-20260828175750449696

Conversation

@ai-sdk-factory

@ai-sdk-factory ai-sdk-factory Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

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

  • The mocked Responses-compatible example successfully encoded a bare tool, decoded a provider-executed call, and losslessly replayed the original item including opaque wire metadata.

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

Co-authored-by: me2seeks <[email protected]>
@ai-sdk-factory

Copy link
Copy Markdown
Contributor Author

Feature review

Outcome: changes-required

Implements feature

Status: 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 effects

Risk: 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.

Performance

Risk: 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 compatibility

Risk: 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:

  • Existing namespaced codec code that contextually treats item.type or event.type as Experimental_OpenResponsesNamespacedType compiled on origin/main but now fails with TS2322. Preserve namespaced callback types for namespaced registrations while exposing widened discriminator types only when bare fields are used.

Breaking changes

Risk: 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:

  • An in-memory compatibility probe against the public source types produced zero diagnostics on origin/main and two TS2322 diagnostics on the PR when namespaced decodeItem/decodeEvent callbacks assigned their contextual discriminator to OpenResponsesNamespacedType. Model the API with generic or discriminated namespaced/bare variants to avoid widening existing namespaced callbacks.

Architecture

Risk: 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 scope

Status: 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.

Security

Risk: 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.

Testing

Status: 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:

  • Add compile-time regression coverage showing that a namespaced-only codec still contextually receives Experimental_OpenResponsesNamespacedType in decodeItem and decodeEvent; the current test only asserts that bare callback discriminators are strings.

Verification

Inspected 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.

@ai-sdk-factory ai-sdk-factory Bot changed the title feat: allow extension codecs to explicitly register bare tool, item, and event discriminators feat: allow Open Responses extension codecs to explicitly opt in to bare tool, item, and event discriminators Aug 28, 2026
@ai-sdk-factory

Copy link
Copy Markdown
Contributor Author

Addressed PR comment 5458212783.

Feature review

Outcome: changes-required

Implements feature

Status: fully-implements

... 74 more line(s) omitted

Implemented the compatibility fix. The public extension type is now discriminated by allowBareTypes: existing namespaced-only codecs contextually receive Experimental_OpenResponsesNamespacedType, while explicitly opted-in bare codecs receive string discriminators. Added compile-time regression coverage for namespaced decodeItem and decodeEvent, runtime opt-in validation, and updated the documentation, example, and changeset. Focused and full verification passed.

@ai-sdk-factory

Copy link
Copy Markdown
Contributor Author

Feature review

Outcome: changes-required

Implements feature

Status: 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 effects

Risk: 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.

Performance

Risk: low

The implementation adds bounded registration-time validation and constant-time Map/Set lookups without new network operations or unbounded processing.

Concerns: none.

Backwards compatibility

Risk: 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:

  • Existing consumers can no longer declare interface MyExtension extends Experimental_OpenResponsesExtension or class MyExtension implements Experimental_OpenResponsesExtension; an in-memory TypeScript probe reports TS2312 and TS2422 for these patterns.

Breaking changes

Risk: 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:

  • Preserve an extendable public shape for existing namespaced codecs, or otherwise redesign the opt-in typing so existing interface-extension and class-implementation usage remains source compatible.

Architecture

Risk: 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 scope

Status: 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.

Security

Risk: 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.

Testing

Status: 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:

  • Add compile-time regression coverage for extending and implementing Experimental_OpenResponsesExtension; current tests cover contextual callback types but miss the interface-to-union breaking change.

Verification

Inspected the complete origin/main...HEAD diff, surrounding Open Responses API and provider code, exports, documentation, example, changeset, and architecture boundaries. git diff --check, focused Ultracite checks, @ai-sdk/open-responses type-check, and package build passed. Node and Edge suites each passed 113 tests, and the bare-extension example successfully encoded a bare tool, decoded its item, and replayed opaque metadata. An in-memory TypeScript compatibility probe produced TS2312 and TS2422 for extending and implementing the public extension type; origin/main declares that type as an interface.

@ai-sdk-factory

Copy link
Copy Markdown
Contributor Author

Addressed PR comment 5458517193.

Feature review

Outcome: changes-required

Implements feature

Status: fully-implements

... 74 more line(s) omitted

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.

@ai-sdk-factory

ai-sdk-factory Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Feature review

Outcome: approved

Implements feature

Status: 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 effects

Risk: 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.

Performance

Risk: 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 compatibility

Risk: 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 changes

Risk: 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.

Architecture

Risk: 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 scope

Status: 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.

Security

Risk: 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.

Testing

Status: 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.

Verification

Inspected 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.

cursor Bot pushed a commit to Lxr-max/maka that referenced this pull request Sep 18, 2026
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)
cursor Bot pushed a commit to Lxr-max/maka that referenced this pull request Sep 20, 2026
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)
cursor Bot pushed a commit to Lxr-max/maka that referenced this pull request Sep 21, 2026
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)
cursor Bot pushed a commit to Lxr-max/maka that referenced this pull request Sep 22, 2026
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)
cursor Bot pushed a commit to Lxr-max/maka that referenced this pull request Sep 22, 2026
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)
cursor Bot pushed a commit to Lxr-max/maka that referenced this pull request Sep 23, 2026
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)
Lxr-max added a commit to Lxr-max/maka that referenced this pull request Sep 24, 2026
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)
@gr2m
gr2m merged commit 8cf3f5b into main Sep 28, 2026
58 checks passed
@gr2m
gr2m deleted the feature-implementation-19933-20260828175750449696 branch September 28, 2026 01:07
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.119 github npm
@ai-sdk/alibaba 2.0.57 github npm
@ai-sdk/amazon-bedrock 5.0.98 github npm
@ai-sdk/angular 3.0.119 github npm
@ai-sdk/anthropic 4.0.66 github npm
@ai-sdk/anthropic-aws 2.0.58 github npm
@ai-sdk/assemblyai 3.0.50 github npm
@ai-sdk/azure 4.0.83 github npm
@ai-sdk/baseten 2.1.36 github npm
@ai-sdk/black-forest-labs 2.0.51 github npm
@ai-sdk/bytedance 2.0.53 github npm
@ai-sdk/cartesia 3.0.45 github npm
@ai-sdk/cerebras 3.0.58 github npm
@ai-sdk/code-mode 1.0.76 github npm
@ai-sdk/cohere 4.0.51 github npm
@ai-sdk/deepgram 3.1.21 github npm
@ai-sdk/deepinfra 3.0.58 github npm
@ai-sdk/deepseek 3.0.55 github npm
@ai-sdk/devtools 1.0.25 github npm
@ai-sdk/elevenlabs 3.0.51 github npm
@ai-sdk/fal 3.0.51 github npm
@ai-sdk/fireworks 3.0.61 github npm
@ai-sdk/fish-audio 3.0.28 github npm
@ai-sdk/gateway 4.0.97 github npm
@ai-sdk/gladia 3.0.50 github npm
@ai-sdk/gmicloud 3.0.29 github npm
@ai-sdk/google 4.0.83 github npm
@ai-sdk/google-vertex 5.0.96 github npm
@ai-sdk/groq 4.0.51 github npm
@ai-sdk/harness 1.0.129 github npm
@ai-sdk/harness-acp 1.0.67 github npm
@ai-sdk/harness-claude-code 1.0.133 github npm
@ai-sdk/harness-cline 1.0.56 github npm
@ai-sdk/harness-codex 1.0.131 github npm
@ai-sdk/harness-cursor 1.0.42 github npm
@ai-sdk/harness-deepagents 1.0.129 github npm
@ai-sdk/harness-fx 1.0.42 github npm
@ai-sdk/harness-github-copilot 1.0.24 github npm
@ai-sdk/harness-grok-build 1.0.66 github npm
@ai-sdk/harness-opencode 1.0.131 github npm
@ai-sdk/harness-pi 1.0.131 github npm
@ai-sdk/huggingface 2.0.58 github npm
@ai-sdk/hume 3.0.50 github npm
@ai-sdk/klingai 4.0.52 github npm
@ai-sdk/langchain 3.0.119 github npm
@ai-sdk/llamaindex 3.0.119 github npm
@ai-sdk/luma 3.0.51 github npm
@ai-sdk/mcp 2.0.61 github npm
@ai-sdk/minimax 3.0.43 github npm
@ai-sdk/mistral 4.0.53 github npm
@ai-sdk/moonshotai 3.0.59 github npm
@ai-sdk/open-responses 2.0.55 github npm
@ai-sdk/openai 4.0.79 github npm
@ai-sdk/openai-compatible 3.0.58 github npm
@ai-sdk/otel 1.0.119 github npm
@ai-sdk/perplexity 5.0.2 github npm
@ai-sdk/policy-opa 1.0.119 github npm
@ai-sdk/prodia 2.0.51 github npm
@ai-sdk/provider 4.0.19 github npm
@ai-sdk/provider-utils 5.0.50 github npm
@ai-sdk/quiverai 2.0.51 github npm
@ai-sdk/react 4.0.122 github npm
@ai-sdk/replicate 3.0.51 github npm
@ai-sdk/revai 3.0.50 github npm
@ai-sdk/rsc 3.0.119 github npm
@ai-sdk/sandbox-just-bash 1.0.129 github npm
@ai-sdk/sandbox-vercel 1.0.129 github npm
@ai-sdk/svelte 5.0.119 github npm
@ai-sdk/togetherai 3.0.59 github npm
@ai-sdk/tui 1.0.120 github npm
@ai-sdk/typesafe-ai 3.0.9 github npm
@ai-sdk/valibot 3.0.50 github npm
@ai-sdk/voyage 2.0.50 github npm
@ai-sdk/vue 4.0.119 github npm
@ai-sdk/workflow 2.0.50 github npm
@ai-sdk/workflow-harness 1.0.129 github npm
@ai-sdk/xai 5.0.11 github npm
@ai-sdk/zai 3.0.20 github npm

This branch was successfully deployed

1 active deployment
Preview — 90ccb8ab Deployed Aug 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@ai-sdk/open-responses: allow explicit codecs for documented bare extension types

2 participants