Skip to content

fix(llm): preserve nested OpenAI stream errors - #36130

Merged
rekram1-node merged 2 commits into
anomalyco:v2from
harshmathurx:nested-errors
Jul 9, 2026
Merged

rekram1-node merged 2 commits into
anomalyco:v2from
harshmathurx:nested-errors

Conversation

@harshmathurx

Copy link
Copy Markdown

Issue for this PR

Closes #36118

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Preserves OpenAI Responses SSE error details when the event arrives as:

{ "type": "error", "error": { "code": "...", "message": "..." } }

The stream parser already handled top-level code/message and response.error; this adds the missing top-level error object shape so provider errors keep their code/message and context-overflow classification.

@rekram1-node tagging you since you have recent ownership in the LLM/provider area. Could you assign #36118 to me if this direction looks right?

How did you verify your code works?

  • Added a regression test for type: "error" with nested error.code / error.message.
  • Ran git diff --check.
  • Attempted the focused Bun test from packages/llm, but dependency install is blocked in this environment by a 403 while resolving ghostty-web@github:anomalyco/ghostty-web#513463a6f....

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally where possible
  • I have not included unrelated changes in this PR

@rekram1-node
rekram1-node changed the base branch from dev to v2 July 9, 2026 19:36
@rekram1-node
rekram1-node merged commit bd0dffd into anomalyco:v2 Jul 9, 2026
14 of 18 checks passed
teknium1 added a commit to NousResearch/hermes-agent that referenced this pull request Jul 17, 2026
… frames

Port from anomalyco/opencode#36130: the Responses spec carries streaming
error details at the top level of the error frame, but the official OpenAI
SDK and several OpenAI-compatible proxies wrap them in an HTTP-style nested
envelope ({"type": "error", "error": {code, message, param}}).

_raise_stream_error only read top-level fields, so nested-envelope frames
collapsed to the generic 'stream emitted error event' placeholder with
code=None — the error classifier never saw the provider's real failure
reason, misrouting rate-limit / context-overflow / entitlement errors into
the generic retry path.

Top-level fields keep precedence; the envelope is a fallback. Null-tolerant
for spec-compliant frames with explicit nulls.
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
… frames

Port from anomalyco/opencode#36130: the Responses spec carries streaming
error details at the top level of the error frame, but the official OpenAI
SDK and several OpenAI-compatible proxies wrap them in an HTTP-style nested
envelope ({"type": "error", "error": {code, message, param}}).

_raise_stream_error only read top-level fields, so nested-envelope frames
collapsed to the generic 'stream emitted error event' placeholder with
code=None — the error classifier never saw the provider's real failure
reason, misrouting rate-limit / context-overflow / entitlement errors into
the generic retry path.

Top-level fields keep precedence; the envelope is a fallback. Null-tolerant
for spec-compliant frames with explicit nulls.
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
… frames

Port from anomalyco/opencode#36130: the Responses spec carries streaming
error details at the top level of the error frame, but the official OpenAI
SDK and several OpenAI-compatible proxies wrap them in an HTTP-style nested
envelope ({"type": "error", "error": {code, message, param}}).

_raise_stream_error only read top-level fields, so nested-envelope frames
collapsed to the generic 'stream emitted error event' placeholder with
code=None — the error classifier never saw the provider's real failure
reason, misrouting rate-limit / context-overflow / entitlement errors into
the generic retry path.

Top-level fields keep precedence; the envelope is a fallback. Null-tolerant
for spec-compliant frames with explicit nulls.
prmartinow pushed a commit to prmartinow/hermes-agent that referenced this pull request Aug 26, 2026
… frames

Port from anomalyco/opencode#36130: the Responses spec carries streaming
error details at the top level of the error frame, but the official OpenAI
SDK and several OpenAI-compatible proxies wrap them in an HTTP-style nested
envelope ({"type": "error", "error": {code, message, param}}).

_raise_stream_error only read top-level fields, so nested-envelope frames
collapsed to the generic 'stream emitted error event' placeholder with
code=None — the error classifier never saw the provider's real failure
reason, misrouting rate-limit / context-overflow / entitlement errors into
the generic retry path.

Top-level fields keep precedence; the envelope is a fallback. Null-tolerant
for spec-compliant frames with explicit nulls.
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
… frames

Port from anomalyco/opencode#36130: the Responses spec carries streaming
error details at the top level of the error frame, but the official OpenAI
SDK and several OpenAI-compatible proxies wrap them in an HTTP-style nested
envelope ({"type": "error", "error": {code, message, param}}).

_raise_stream_error only read top-level fields, so nested-envelope frames
collapsed to the generic 'stream emitted error event' placeholder with
code=None — the error classifier never saw the provider's real failure
reason, misrouting rate-limit / context-overflow / entitlement errors into
the generic retry path.

Top-level fields keep precedence; the envelope is a fallback. Null-tolerant
for spec-compliant frames with explicit nulls.
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
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.

fix(llm): preserve nested OpenAI stream error details

2 participants