Skip to content

EFF-123: Surface unknown OpenAI-compatible stream events - #6667

Merged
tim-smart merged 1 commit into
mainfrom
agent/codex-engineer/dd359f25
Jul 27, 2026
Merged

EFF-123: Surface unknown OpenAI-compatible stream events#6667
tim-smart merged 1 commit into
mainfrom
agent/codex-engineer/dd359f25

Conversation

@tim-smart

@tim-smart tim-smart commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • surface parsed schema-mismatched chat completion SSE payloads as UnknownChatCompletionEvent
  • continue dropping malformed JSON and explicitly ignore unknown events in the generic language-model layer
  • cover malformed JSON, schema mismatch, and continuation behavior

Testing

  • pnpm --filter @effect/ai-openai-compat test --run test/OpenAiClient.test.ts test/OpenAiLanguageModel.test.ts
  • pnpm --filter @effect/ai-openai-compat check
  • pnpm check
  • pnpm lint

Closes EFF-123
Closes #6346

Summary by CodeRabbit

  • New Features

    • Streaming responses now preserve provider-specific events that don’t match the expected schema.
    • Direct clients can access these events as UnknownChatCompletionEvent data.
  • Bug Fixes

    • Malformed streaming payloads are safely ignored without interrupting the rest of the response stream.
    • Streaming continues correctly through unrecognized events until completion.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 27, 2026
@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7c903b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
@effect/ai-openai-compat Patch
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: be883ca7-5335-4ed4-9206-809c746825c5

📥 Commits

Reviewing files that changed from the base of the PR and between a3fd084 and 7c903b1.

📒 Files selected for processing (5)
  • .changeset/eff-123-openai-compat-unknown-events.md
  • packages/ai/openai-compat/src/OpenAiClient.ts
  • packages/ai/openai-compat/src/OpenAiLanguageModel.ts
  • packages/ai/openai-compat/test/OpenAiClient.test.ts
  • packages/ai/openai-compat/test/OpenAiLanguageModel.test.ts

📝 Walkthrough

Walkthrough

Chat completion SSE decoding now preserves valid schema-mismatched payloads as UnknownChatCompletionEvent, while malformed JSON remains ignored. The language model adapter skips translation for unknown events, and streaming tests cover both behaviors.

Changes

OpenAI-compatible streaming

Layer / File(s) Summary
Unknown event contract and decoding
packages/ai/openai-compat/src/OpenAiClient.ts
Adds UnknownChatCompletionEvent to the stream event union and wraps valid schema-mismatched JSON payloads instead of dropping them.
Language model stream handling
packages/ai/openai-compat/src/OpenAiLanguageModel.ts
Detects unknown events and returns the accumulated stream parts without normal event translation.
Streaming tests and release metadata
packages/ai/openai-compat/test/*, .changeset/eff-123-openai-compat-unknown-events.md
Tests provider-specific events, malformed JSON, continued streaming to [DONE], and the patch release note.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested labels: bug

Suggested reviewers: imax153

Sequence Diagram(s)

sequenceDiagram
  participant Provider
  participant decodeChatCompletionSseData
  participant OpenAiLanguageModel
  participant streamText
  Provider->>decodeChatCompletionSseData: Send SSE JSON chunk
  decodeChatCompletionSseData-->>OpenAiLanguageModel: ChatCompletionChunk or UnknownChatCompletionEvent
  OpenAiLanguageModel->>OpenAiLanguageModel: Skip translation for unknown event
  OpenAiLanguageModel-->>streamText: Continue stream processing
Loading
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR surfaces schema-mismatched SSE chunks as UnknownChatCompletionEvent and preserves malformed-JSON handling, matching issue #6346's goal.
Out of Scope Changes check ✅ Passed The changes are limited to the OpenAI compat stream path, related tests, and a changeset, with no unrelated functionality added.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the bug Something isn't working label Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
batching.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)
brand.ts 6.26 KB 6.26 KB 0.00 KB (0.00%)
cache.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)
config.ts 19.21 KB 19.21 KB 0.00 KB (0.00%)
differ.ts 18.42 KB 18.42 KB 0.00 KB (0.00%)
http-client.ts 20.76 KB 20.76 KB 0.00 KB (0.00%)
logger.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
metric.ts 8.55 KB 8.55 KB 0.00 KB (0.00%)
optic.ts 7.41 KB 7.41 KB 0.00 KB (0.00%)
pubsub.ts 14.20 KB 14.20 KB 0.00 KB (0.00%)
queue.ts 11.08 KB 11.08 KB 0.00 KB (0.00%)
schedule.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
schema-class.ts 18.16 KB 18.16 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 28.02 KB 28.02 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 24.33 KB 24.33 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.69 KB 12.69 KB 0.00 KB (0.00%)
schema-string.ts 10.35 KB 10.35 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.49 KB 14.49 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.93 KB 20.93 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 23.38 KB 23.38 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.32 KB 18.32 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.00 KB 18.00 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.88 KB 17.88 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 21.51 KB 21.51 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 18.55 KB 18.55 KB 0.00 KB (0.00%)
schema.ts 17.43 KB 17.43 KB 0.00 KB (0.00%)
stm.ts 12.05 KB 12.05 KB 0.00 KB (0.00%)
stream.ts 9.36 KB 9.36 KB 0.00 KB (0.00%)

@tim-smart
tim-smart merged commit 5283841 into main Jul 27, 2026
15 checks passed
@tim-smart
tim-smart deleted the agent/codex-engineer/dd359f25 branch July 27, 2026 10:56
@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Done in PR Backlog Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ai-openai-compat: streamed SSE chunks that fail schema validation are dropped silently

1 participant