Skip to content

feat(diagnostics): add hint for 3rd-party relay SSE truncation on OpenAI Responses API (#167 follow-up) #180

@hqhq1025

Description

@hqhq1025

Summary

Follow-up / implementation issue for #167.

Some 3rd-party relay gateways (sub2api / claude2api / anyrouter) naively parse SSE and match the literal "response" substring as if it were `[DONE]`, causing early truncation when the upstream emits `response.output_text.delta` / `response.completed` events from OpenAI Responses API. User-visible symptom: generation stops mid-output.

Codesign's own SSE parser is strict (see `packages/providers/src/codex/client.ts` `flushEvent`) and only stops on literal `[DONE]`, so the fault is in the relay. But we should surface actionable hints so users can self-diagnose.

Proposed Fix

Extend `diagnoseGenerateFailure()` in `packages/shared/src/diagnostics.ts` (landed via #130 / PR #165) with a new hypothesis:

  • Signal: `wire === 'openai-responses'` AND `baseUrl` is a custom host (not `api.openai.com`) AND the generation ended with incomplete output (no `response.completed` seen, or `finish_reason` missing)
  • Hypothesis code: `relayStreamingBug`
  • User-facing hint: "Generation stopped early. Your gateway may mishandle OpenAI Responses API SSE events (common on older sub2api/claude2api/anyrouter builds). Try: (1) upgrading the relay, (2) switching wire to OpenAI Chat, or (3) using api.openai.com directly."

Out of Scope

  • Non-streaming fallback (tracked separately if demand materializes) — would be heavy work and most streaming tools still care about token-by-token rendering
  • Fix on the relay side (not our code, not our scope)

Acceptance

  • New test in `diagnostics.test.ts`: incomplete stream + custom baseUrl + openai-responses wire → `relayStreamingBug` hypothesis surfaces
  • i18n keys in en/zh-CN
  • Does not regress current `diagnoseGenerateFailure` behavior for official openai / anthropic endpoints

cc @hqhq1025
Refs #167, #130, #165

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions