Repository navigation
Description
Problem
When OpenCode's free gateway blocks the egress IP, the gateway treats the 403 as
an ordinary upstream rejection and keeps working through the retry plan:
doAnonymousUpstreamtries the next anonymous upstream on the same exit even
though the block belongs to the IP, not to the lane;doUpstreamTiersthen falls through to the keyed tiers, which leave from the
same network and get the same 403;- the block is not remembered, so every following client request (and every
background availability probe) repeats the whole walk.
Upstream's message is explicit that retrying lengthens the penalty and that the
official client sees the same answer from the same IP, so the current behaviour
is the worst possible reaction. Clients also receive the upstream text ("turn it
off" if you are on a VPN), which misdescribes a gateway whose egress is a
configured proxy.
Evidence
Observed on a local instance (single direct exit) through a shim that logs
every upstream request:
18:16:50 client request deepseek-v4.1-flash-free (329 KB, Anthropic session X)
18:16:50 → 403 abusive traffic (v1 /zen lane)
18:16:54 → 403 abusive traffic (v2 /inference lane, same exit)
18:16:57 → 403 abusive traffic (keyed Zen tier, same exit)
18:17:01 → 403 abusive traffic (keyed Zen tier, same exit)
18:19:22 same pattern for a different session, 4 more requests
So one client request produced four upstream 403s from the same IP. The
availability probe has the same problem with a different symptom: issue #54
showed probes misreading upstream rejections, and this 403 is currently recorded
as http_403, indistinguishable from a request-shape rejection.
A control run minutes later proved the block is per-IP and transient rather
than per-session: the exact failed request body replayed with the same session
id returned 200. The defect is therefore not "which requests are blocked" but
"how the gateway reacts to being blocked".
Source: internal/gateway/upstream.go (doAnonymousUpstream,
doUpstreamTiers), internal/gateway/pool.go (anonymousCursor.Next),
internal/gateway/probe.go (probeAttempt).
Scope
- Recognition of the IP-abuse 403 body (three known wordings, per
https://github.com/azrinaldi/opencode-free-bridge and
https://github.com/trefeon/pi-freeflow). - Anonymous lane and tier selection: no second lane on the same exit, no keyed
fallback, cool the exit instead of the node. - Cursor: a blocked exit must not be reached through either the first pass or
the cooldown fallback. - Client-visible error when every exit is blocked.
- Probe reason classification.
Expected Outcome
- One client request against a flagged exit sends at most one upstream request.
- The flagged exit is skipped for a bounded TTL and comes back by itself.
- Other configured exits still serve traffic.
- Clients receive
503 free_tier_ip_blockedwith the gateway's own message; the
upstream text is never forwarded. - Availability probes record
network_abuse_blockedinstead ofhttp_403.
Related
- [BUG]免费模型可用性探测疑似使用了非 OpenCode 格式的会话 ID,导致大量健康模型被误判为不可用并禁用 24 小时 #54 (probe classification, same area)
- [Bug] 匿名模式未记忆最后成功代理,后续请求会重复遍历已 429/403 的节点 #12 (anonymous lane re-walking rejected nodes)
- fix(upstream): cap the number of anonymous exits tried per request #127 caps how many exits one request walks; this issue is about the reaction
to the IP block itself, so the two are complementary.
Activity
tubimasky commentedon Oct 20, 2026
补充一个本地已实现并验证的互补方案,供参考:
车道级熔断(而非只冷却出口)
base_hours << (strike-1),封顶max_hours(默认 1h → 2h → 4h → … → 24h 指数退避),任意一次成功即复位;models.anonymous_backoff = {threshold, base_hours, max_hours},默认关闭(threshold: 0),保持现有行为不变;可在诊断/日志中暴露paused_until与strikes。与 #131 的一个关键差异:不建议"全部出口被封就给 503"
/zen/go,认证请求)不受免费层 IP 封禁影响,实测同一 IP 下返回 200;本地验证
direct;如方向认可,我可以提 PR(
config+pool+upstream约 190 行,默认关闭、向后兼容)。cheerc commentedon Oct 20, 2026
Thanks a lot for digging into this issue. Could you open a new PR to fix it? Looking forward to your fix. Thanks again.
tubimasky commentedon Oct 20, 2026
按上一条讨论实现了对应 PR:#140 —— 默认关闭,配置
models.anonymous_backoff后启用:threshold次连续失败,或单次403/429立即暂停整条匿名车道;每次再触发暂停窗口翻倍(1h → 2h → … → 24h),成功即复位;/zen/go不受免费层 IP 封禁影响,因此回落到已认证层级仍可服务,而不是统一 503(Zen key 共享免费网关,仍会 403)。若维护者倾向 503 语义,可在此 PR 上叠加。jasonxu114514 commentedon Oct 20, 2026
Fixed in 0bb23c7.
performance.max_anonymous_exitsnow caps distinct static exits per anonymous request (default 8); rotating#pooltransports still followretry.max_attempts. An IP-abuse 403 marks only that exit (performance.free_tier_block_seconds, default 900s); the lane breaker opens only when every exit is blocked, and a single shape 403/429 no longer pauses the lane. After a block, the Zen keyed tier is skipped because it shares the free gateway, while the authenticated Go tier is still tried.