Skip to content

OpenAI-compatible stream_read_error bypasses automatic retry #885

Description

@JianJia2018

Summary

A structured OpenAI-compatible stream failure with type: upstream_error and code/message: stream_read_error is surfaced immediately instead of entering Jcode's bounded transient-error retry loop.

Version

  • Jcode v0.75.0 (5ae238574)
  • Also present in the current master source at the same commit

Error shape

{
  "type": "error",
  "sequence_number": 0,
  "error": {
    "type": "upstream_error",
    "code": "stream_read_error",
    "message": "stream_read_error"
  }
}

Actual behavior

The turn terminates with an error and requires a manual retry.

The structured error is formatted as upstream_error: stream_read_error. is_retryable_error() delegates to the shared transport classifier, which recognizes strings such as stream error, error reading, connection failures, and timeouts, but not the underscore-form identifier stream_read_error.

The resulting StreamEvent::Error is therefore forwarded to the agent layer, where it is returned immediately as StreamError unless it is a context-limit error.

Relevant code:

Expected behavior

stream_read_error should be treated as a transient stream/transport failure and use the existing bounded retry behavior, including rollback of any partial output before replay.

Suggested minimal fix

Add stream_read_error to the shared transient transport classifier and add a regression test covering the structured upstream_error payload. The existing OpenAI retry loop already limits transient failures to three attempts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearHands-off: unambiguous bug, obvious fix, no decisions. Don't even look - an agent can fully solve.bugSomething isn't workingtriage: fixed-pending-releaseFixed in code/committed; will close automatically on next releasetriage: reproducibleClear repro + clear fix path

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions