Skip to content

fix(gateway): fall back from exhausted WARP exits and filter deprecated models - #196

Closed
skargaklop wants to merge 1 commit into
jasonxu114514:mainfrom
skargaklop:fix/warp-fallback-and-deprecated-model-handling
Closed

skargaklop wants to merge 1 commit into
jasonxu114514:mainfrom
skargaklop:fix/warp-fallback-and-deprecated-model-handling

Conversation

@skargaklop

Copy link
Copy Markdown

I am an AI agent submitting this pull request on behalf of the user.

Summary of Changes

  1. WARP-to-Proxy/Direct Fallback for Anonymous Free Models (internal/gateway/upstream.go):

    • When warp.enabled: true is configured and anonymous free-model requests go through WARP, rate limits (429), IP abuse blocks (errFreeTierIPBlocked), or tunnel/acquisition unavailability (errWARPUnavailable) previously caused the request to fail immediately even if working proxies or "direct" were configured.
    • Added automatic fallback to doAnonymousProxyUpstream using the configured proxies list, properly buffering and draining superseded response bodies and chaining attempt offsets.
  2. Filter Deprecated Models in Capability Discovery (internal/models/discovery.go):

    • Added Status parsing to capabilityModel in FetchCapabilities.
    • Models marked with "status": "deprecated" in https://models.opencode.ai/api.json (e.g. glm-5.3-flash-free) are no longer imported into native protocols and metadata.
  3. Accurate Error Reporting for Retired vs Unsupported Protocol Models (internal/models/catalog.go, internal/gateway/gateway.go):

    • Added HasUnsupportedProtocol(model) on ModelCatalog.
    • Avoids emitting 400 invalid_request_error: "the model uses an upstream protocol that opencode2api does not expose" for models that are retired/unavailable upstream; instead returns 410 Gone (or 404 model_not_found), reserving 400 for models that actually declare unsupported SDKs.
  4. Client Version Alignment (internal/httpx/client.go):

    • Updated v2ClientVersion from "2.1.1" to "2.4.2" to match current OpenCode releases.

Verification

  • Built with Go 1.27.4 (go vet ./... and gofmt clean).
  • Verified end-to-end against upstream OpenCode gates:
    • WARP returning 429 automatically fell back to direct egress with HTTP 200 on deepseek-v4.1-flash-free (anon:429@warp -> anon:200@direct).
    • Deprecated model glm-5.3-flash-free returned clear 404 model_not_found instead of misleading 400 protocol error.

…ed models

- Fall back to configured proxy/direct pool when WARP anonymous exits fail with 429, IP block, or unavailability
- Filter deprecated models during capability discovery
- Return 410/404 instead of misleading 400 unsupported protocol for retired models
- Align v2 client version to 2.4.2
@jasonxu114514

Copy link
Copy Markdown
Owner

已在 main 以 fc7744a 修正後實作並驗證,本 PR 由該提交取代,將納入 v1.5.2。與原提案不同,warp.proxy_fallback 預設 false,必須明確允許匿名流量改走已配置代理/直連;WARP 與回退共用一次熔斷准入,避免 threshold=1/half-open 提前阻斷。另排除 deprecated 能力並防止同 Tier 文件重新引入,區分未知/不可用/不支援協議。未包含無必要的客戶端版本號變更。感謝提案;關閉此 PR 而不直接合併。

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