Repository navigation
Description
Summary
Model routes on OpenCode Go (https://opencode.ai/zen/go/v1) fail at scale. They are perfect at 1–5 concurrent chats, then abruptly fail once the swarm scales up, and keep failing.
Root cause captured from logs: OpenCode Go proxies union-alpha to OpenRouter's stealth/union-alpha, which runs on a shared upstream pool (limit_source: upstream_provider_shared_pool). At scale the upstream returns 429, but OpenCode Go surfaces it to the client as an opaque HTTP 500 / endpoint failure, discarding the 429, the Retry-After guidance, and the remedy hint. Callers therefore see a "dead endpoint" instead of "rate limited, retry shortly."
Environment
| Field | Value |
|---|---|
| Harness | jcode v0.84.0 (57d5878) |
| Provider | OpenCode Go / OpenCode Zen (gateway) → OpenRouter (upstream) |
| Base URL | https://opencode.ai/zen/go/v1 |
| Models affected | union-alpha, mimo-2.5 / mimo-v2.5 |
| Models OK | deepseek-v4.1-flash (200 OK on the same endpoint) |
| Config | ~/.jcode/config.toml: default_provider = "opencode-go", default_model = "mimo-v2.5", swarm_max_concurrent_agents = 32 |
Evidence — union-alpha at scale
ERROR AGENT_PROVIDER_STREAM_LIFECYCLE elapsed_ms=92171
error="OpenAI-compatible chat request failed
endpoint: https://opencode.ai/zen/go/v1/chat/completions
model: union-alpha
auth: OPENCODE_GO_API_KEY
status: 500 ..."
The upstream body (seen in the same record) is actually a 429:
{"error":{"message":"Provider returned error","code":429,
"metadata":{"raw":"stealth/union-alpha is temporarily rate-limited upstream. Please retry shortly.",
"provider_name":"Stealth","is_byok":false,
"limit_source":"upstream_provider_shared_pool",
"remedy_hint":"Retry shortly, add your own provider key, or route to another provider"}},
"user_id":"user_2vIPgFZC2n64ufSHAf55kZ0QV20"}So: upstream 429 → gateway 500 → client endpoint error. The actionable signal is destroyed in transit.
Evidence — mimo-2.5
Same class of failure on the default model:
Failed to send OpenAI-compatible chat request
endpoint: https://opencode.ai/zen/go/v1/chat/completions
model: mimo-v2.5
auth: OPENCODE_GO_API_KEY
Confirmed independently by the user ("occurs on mimo 2.5 model too"), so this is not model-specific — it is a gateway concurrency/backpressure defect.
Evidence — muse-spark-1.3
Two separate problems:
- Routing ambiguity. A bare
model: muse-spark-1.3resolved to OpenRouter (provider=OpenRouter), not the configureddefault_provider = opencode-go. The catalog exposes bothmeta/muse-spark-1.3 via OpenRouterandmuse-spark-1.3 via OpenCode Zen; the bare name picked the wrong one. - Opaque 403. Once routed to OpenRouter:
ERROR elapsed_ms=41044
error="OpenAI-compatible chat request failed
endpoint: https://openrouter.ai/api/v1/chat/completions
model: muse-spark-1.3
auth: OPENROUTER_API_KEY
status: 403 ..."
Also observed on this request: request_json_chars=338329, system_json_chars=262155, tools_json_chars=75093, tool_count=41, and 40.9s just to open the stream. Needs investigation whether the 403 is model-access or the oversized payload.
Reproduction
- Set OpenCode Go as default with
union-alpha(ormimo-2.5). - Run 1–5 concurrent chats/workers. Succeeds reliably.
- Scale the swarm to 10–32 workers and dispatch short-request bursts.
- Requests begin failing at the endpoint layer within a short window and continue failing.
Abrupt transition, no visible backoff, no 429 surfaced to the caller.
Impact
- Large fan-out test-generation / codegen swarms cannot use this provider.
- A full agent wave was lost to this and had to be re-run on a different route.
- Operators/agents cannot tell whether to retry, throttle, or switch providers, because the retryable 429 is hidden behind a 500.
- Bare model names can silently route to the wrong provider, bypassing the configured default.
Requested fixes
- Propagate the upstream status. Pass through
429(andRetry-After) instead of collapsing it to500. Keep theremedy_hintandlimit_sourcefor diagnostics. - Distinguish saturation from failure with a machine-readable error (e.g.
provider_overloaded). - Client backpressure: bounded in-flight semaphore + exponential backoff with jitter, so bursts don't exceed the shared-pool ceiling.
- Deterministic model routing: bare
muse-spark-1.3should resolve to the configureddefault_provider, or require an explicitprovider/modelwhen a name is ambiguous. - Log the truncated upstream body at the gateway, since the real cause is only visible in the raw response today.
Notes
- Low-concurrency correctness is confirmed — this is scale-only.
- Found during an AgilePlus test-coverage swarm (Wave 6). After switching to a working route, the same wave completed and pushed (
a57c17e7). - Workaround in use:
deepseek-v4.1-flashon the same OpenCode Go endpoint returned200 OKwhileunion-alphawas failing.
Activity
docs(session): round 11 — all 3 high-hazard are no-ops; issue #38 res…