feat(diagnostics): hint for 3rd-party relay SSE truncation (#180)#181
Merged
feat(diagnostics): hint for 3rd-party relay SSE truncation (#180)#181
Conversation
Contributor
There was a problem hiding this comment.
Findings
- No high-confidence issues found in added/modified lines.
Summary
- Review mode: initial
- No issues identified in the latest diff.
- Residual risk/testing gap: automated tests were not run in this environment (
pnpmnot found), so behavioral validation depends on CI. docs/VISION.mdanddocs/PRINCIPLES.md: Not found in repo/docs.
Testing
- Not run (automation):
pnpmunavailable in runner environment.
open-codesign Bot
Some gateways (older sub2api / claude2api / anyrouter builds) mishandle OpenAI Responses API SSE events and treat `response.output_text.delta` / `response.completed` as `[DONE]`, cutting the stream short with no HTTP status — the error surfaces as a transport-level "terminated" / "premature close" / ECONNRESET. diagnoseGenerateFailure() now recognises this pattern and returns a `relayStreamingBug` hypothesis with actionable fix copy (upgrade the relay, switch wire to openai-chat, or use api.openai.com directly). Detection signal (b): wire=openai-responses AND baseUrl host is not *.openai.com AND no HTTP status attached AND the message matches a truncated-stream shape. HTTP-status errors still route to the existing gatewayIncompatible / serverError / keyInvalid paths. Refs #167. Stacked on #165 (introduces diagnoseGenerateFailure). Signed-off-by: hqhq1025 <1506751656@qq.com>
1e80a69 to
95d26bb
Compare
Contributor
There was a problem hiding this comment.
Findings
- No high-confidence issues found in added/modified lines.
Summary
- Review mode: follow-up after new commits
- No issues identified in the latest PR diff.
docs/VISION.mdanddocs/PRINCIPLES.md: Not found in repo/docs.- Residual risk/testing gap: heuristic matching for truncated streams is covered by unit tests in
packages/shared/src/diagnostics.test.ts, but integration behavior remains dependent on CI/runtime paths.
Testing
- Not run (automation)
open-codesign Bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix #180 (implementation of #167): give users an actionable diagnostic when a third-party relay (older sub2api / claude2api / anyrouter builds) mishandles OpenAI Responses API SSE events and cuts the stream short with no HTTP status.
What changed
packages/shared/src/diagnostics.ts— newrelayStreamingBughypothesis indiagnoseGenerateFailure(). Triggers when:wire === 'openai-responses'baseUrlhost is not*.openai.comstream ended,premature close,terminated,ECONNRESET,abortedpackages/i18n/src/locales/en.json+zh-CN.json—diagnostics.cause.relayStreamingBug+diagnostics.fix.relayStreamingBug.packages/shared/src/diagnostics.test.ts— 6 new tests covering positive + negative cases:api.openai.com+ "terminated" → does NOT trigger (official endpoint isn't the culprit)serverError)Detection signal used: (b) from the task spec — pattern-matching on baseUrl + wire + message, since the existing error path (
packages/providers/src/codex/client.ts,retry.ts) does not yet attach a "stream closed without response.completed" context field.Stacked on #165
This PR builds on the
diagnoseGenerateFailure()function introduced in #165 (branchworktree-agent-a75d65c7). Merge #165 first, then this PR. Rebasing onto main after #165 lands will be a no-op.Four-principle check
serverError/unknownwhen signals don't matchTest plan
pnpm --filter @open-codesign/shared test— 174 passed (8 files)pnpm typecheck— 10 packages greenpnpm lint— biome clean (360 files)response.*SSE events, confirm the diagnostic panel renders the new cause + fix stringsRefs #167, closes #180.