Skip to content

fix(cursor): upstream errors, transport stability, auto model, request logs - #73

Closed
Wibias wants to merge 1 commit into
lidge-jun:mainfrom
Wibias:fix/cursor-upstream-errors-and-transport
Closed

Wibias wants to merge 1 commit into
lidge-jun:mainfrom
Wibias:fix/cursor-upstream-errors-and-transport

Conversation

@Wibias

@Wibias Wibias commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Improves Cursor provider reliability and request-log diagnosis when upstream calls fail or streams cancel benignly. Also fixes cursor/auto disappearing after live model discovery and maps it to Cursor wire id default.

Changes

Upstream error mapping

  • Add shared adapter failure helpers in src/lib/errors.ts
  • Map resource_exhausted / rate limits to 429 (rate_limit_error) instead of generic 502
  • Map auth, overloaded, invalid, and timeout failures to appropriate HTTP statuses
  • Use shared mapping in bridge, relay, and request-log terminal status handling

Cursor transport stability

  • Treat benign NGHTTP2_CANCEL after client-tool suspend as non-fatal
  • Skip retries for rate limits and benign cancels in transport-retry.ts
  • Add opt-in provider transport diagnostics via unified debugProviderDiagnostic("cursor", ...)

Request logs

  • Persist richer terminal fields: upstreamError, requestedModel, requestedEffort, resolvedModel, usage status
  • Show upstream reason in GUI log detail panel

cursor/auto

  • Keep auto in catalog even when GetUsableModels omits it
  • Map Codex-facing auto / cursor/auto to wire id default
  • Add effort tiers for claude-sonnet-5 and glm-5.2

Testing

  • bun test tests/errors-adapter-failure.test.ts
  • bun test tests/cursor-discovery.test.ts tests/codex-catalog.test.ts tests/cursor-request-builder.test.ts tests/cursor-adapter.test.ts
  • bun test tests/cursor-transport-retry.test.ts tests/request-log.test.ts tests/adapter-error-inline.test.ts

Notes

@lidge-jun

Copy link
Copy Markdown
Owner

Thanks — this is a useful reliability pass. The shared upstream error mapping, 429/rate-limit handling, request-log enrichment, and the cursor/auto -> default wire mapping all look directionally right (and they line up with what users are hitting in #72).

Requesting changes before landing though:

  1. Rebase needed. This PR predates the 260709 cursor catalog refresh on dev; src/adapters/cursor/discovery.ts now conflicts. When rebasing, please preserve the refreshed state: stale grok-4.x/kimi-k2.5/composer-1.5/composer-2 ids stay removed, gpt-5.5-extra stays (it survives the live GetUsableModels filter), glm-5.2 stays at 1M, and kimi-k2.7-code/claude-opus-4-7-fast stay present. The static-list test expectations in tests/cursor-discovery.test.ts need the same treatment.
  2. Cancel suppression is too broad. isCursorBenignCancelError (src/adapters/cursor/cursor-errors.ts:30) treats any NGHTTP2_CANCEL as benign and live-transport.ts:459 returns silently on it. The expected client-tool suspend path already has expectedClose — please narrow benign cancellation to that path, or show that unexpected server-side CANCELs still surface as errors.
  3. Prefix filter false-activation. id.startsWith(\${modelId}-`)indiscovery.ts:58lets a liveclaude-4-sonnet-1mactivate a configuredclaude-4-sonnet`. Distinguishing effort suffixes from sibling model ids would make the filter safe.

Decision: request changes. The core fixes are wanted — after a rebase and the cancel-scope fix I'd like to land this quickly.

lidge-jun added a commit that referenced this pull request Jul 9, 2026
- re-export httpStatusFromTerminalError from server/index (import-time test failure)
- gate benign NGHTTP2_CANCEL handling on the expectedClose suspend path so
  unexpected server-side stream cancels surface as real transport errors
- restrict live GetUsableModels base-model activation to known effort suffixes
  (claude-4-sonnet-1m no longer activates claude-4-sonnet) + regression tests
@lidge-jun

Copy link
Copy Markdown
Owner

Update: rather than waiting on a rebase, I've landed this on dev by cherry-pick with your authorship preserved — commit 07afa28 — plus a follow-up hardening commit 949e08d addressing the review points:

  • src/adapters/cursor/discovery.ts conflict resolved in favor of the refreshed 260709 catalog (your glm-5.2 effort tiers + supportsReasoningEffort kept, at 1M context).
  • Fixed an import-time failure: httpStatusFromTerminalError was consumed by tests/request-log.test.ts via src/server/index.ts but never re-exported there.
  • Benign NGHTTP2_CANCEL handling is now gated on the expectedClose suspend path, so unexpected server-side cancels still surface as transport errors.
  • Live-filter base activation restricted to known effort suffixes (a live claude-4-sonnet-1m no longer activates claude-4-sonnet), with regression tests.

Gates after landing: tsc --noEmit clean, full bun test 1673 pass / 0 fail. Closing this PR as landed-via-cherry-pick — the error mapping, 429 handling, request-log enrichment, and auto -> default mapping are all in. Thanks for the substantial fix!

@lidge-jun lidge-jun closed this Jul 9, 2026
@Wibias
Wibias deleted the fix/cursor-upstream-errors-and-transport branch July 13, 2026 19:18
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
- re-export httpStatusFromTerminalError from server/index (import-time test failure)
- gate benign NGHTTP2_CANCEL handling on the expectedClose suspend path so
  unexpected server-side stream cancels surface as real transport errors
- restrict live GetUsableModels base-model activation to known effort suffixes
  (claude-4-sonnet-1m no longer activates claude-4-sonnet) + regression tests
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.

2 participants