Skip to content

fix(openai): accept SDK response event interfaces - #98

Merged
Kinfe123 merged 2 commits into
mainfrom
fix/openai-sdk-event-types
Oct 30, 2026
Merged

Kinfe123 merged 2 commits into
mainfrom
fix/openai-sdk-event-types

Conversation

@Kinfe123

Copy link
Copy Markdown
Collaborator

Problem

With streamfold 0.1.14 and openai 7.45.1, passing the result of client.responses.create({ model, input, stream: true }) directly to readStructured(events, { integration: openAI }) fails TypeScript compilation. Feeding SDK events into push or pushAll fails too, even though the adapter can ignore non-tool events at runtime.

Root cause

The fallback event type requires a string index signature. The SDK declares its events as interfaces without that signature, so events such as audio deltas cannot satisfy the adapter's union.

Change

Add a minimal discriminator-only fallback to the existing union. Keep the existing branches so raw event literals with extra provider fields remain accepted. There is no runtime or parser change and no SDK runtime dependency.

Verification

  • Added a compile-time consumer fixture using the real OpenAI SDK response stream, both manual push methods, and an unknown event literal.
  • pnpm typecheck fails before the declaration change with TS2322/TS2345 at the real SDK boundaries and passes afterward.
  • pnpm release:check passes: 197 JavaScript tests, 11 Rust tests, type/syntax checks, WASM build, formatting, Clippy, and package checks.
  • This is separate from fix(openai): preserve final arguments and suppress duplicate completions #94, which fixes runtime completion behavior and does not change these declarations.

Public surface

Widens OpenAiResponsesToolEvent without removing any existing shape. Updates API documentation and the unreleased changelog. OpenAI is a development-only dependency for the consumer type check.

@Kinfe123 Kinfe123 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, real openai sdk streams now typecheck without casts.

@Kinfe123
Kinfe123 merged commit 67f9b35 into main Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant