Repository navigation
Commit b4ffbc6
fix(sandbox-runner): use OpenAI's own SDK for OpenAI runs, and bump opencode to 1.18.30 (#26)
## What broke
Every Layer-2 triage run against `gpt-5.6-luna` was failing. The symptom
was maximally misleading:
```
{"is_error":true,"error":"opencode produced no usable reply",
"usage":{"input_tokens":0,"output_tokens":0,...}}
```
Zero tokens, valid key. That reads like a credential or connectivity
problem, and it is neither.
## Why
`@ai-sdk/openai-compatible` always sends `max_tokens`. OpenAI's GPT-5.x
reasoning line rejects it:
```
Unsupported parameter: 'max_tokens' is not supported with this model.
Use 'max_completion_tokens' instead.
```
OpenCode folds that 400 into an empty assistant turn, so a hard
request-shape failure surfaced to us as an empty reply with no spend.
`@ai-sdk/openai` rewrites the field per model
([`openai-chat-language-model.ts`](https://github.com/vercel/ai/blob/main/packages/openai/src/chat/openai-chat-language-model.ts))
and is the only one of the two that can: knowing which models need it
means knowing the models, which is exactly what "any OpenAI-compatible
endpoint" cannot assume. Upstream tracks this as
[opencode#45223](anomalyco/opencode#45223),
still open with no scheduled fix, so this does not wait on them.
## What changed
**`fix`** — `openAiCompatProviderBlock` selects `@ai-sdk/openai` for the
`OPENAI` mode, `@ai-sdk/openai-compatible` for everything else. One line
plus its rationale, and the two test assertions that pinned the old
value.
**`chore`** — `opencode-ai` and `@opencode-ai/sdk` 1.18.13 → 1.18.30
across both recipes, `package.json`, and the lockfile. Independent of
the fix; it stands on being current.
## For the reviewer
**The bump does not fix the bug, and that was measured rather than
assumed.** 1.18.30 reproduces the failure identically while on the
compat adapter, because
[opencode#44710](anomalyco/opencode#44710
provider gating does not recognise a custom `openai-compatible` block
like `openai-direct`. Worth knowing before anyone concludes the bump was
the cure.
**Why only the OPENAI mode moved.** The other modes are not the same
case. `api.x.ai/v1` and
`generativelanguage.googleapis.com/v1beta/openai/` are deliberately
maintained OpenAI-*compatible* surfaces with a stated compatibility
contract. OpenAI's `/v1` is the origin of the shape and owes nobody
compatibility, which is precisely how it drifted. Pointing the compat
adapter at a compat endpoint remains correct.
`@ai-sdk/xai` is a closer call than the others: it defaults to the same
`api.x.ai/v1` base URL already in use and is a standalone
implementation, so it is nearly a drop-in. It was left alone because
there is no xAI key here to verify it with, and swapping a working
provider blind inside an unrelated fix is how the next quiet zero-token
failure gets introduced. Worth doing as its own change. Gemini is
genuinely different: `@ai-sdk/google` uses a different endpoint path and
an `x-goog-api-key` header instead of Bearer, so it is a
credential-plumbing refactor, not a swap.
**The rest of the codebase was audited for the same pattern and is
clean.** The Java backend cannot hit this defect: `.maxTokens(4096)`
appears exactly once in the whole tree
([`ChatModelFactory.java:515`](backend/llm-runtime/src/main/java/ai/tessary/llm/ChatModelFactory.java#L515)),
on the Anthropic builder, because Anthropic's API requires it. No
OpenAI-wire path sets a token cap at all. Its OpenAI path already uses
OpenAI's own LangChain4j client.
## Verification
- Reproduced and fixed against a real key inside the agent image, on
both 1.18.13 and 1.18.30: compat adapter throws the 400, native package
replies.
- Confirmed the key, auth, egress and model access were never the
problem (`GET /v1/models` → 200, model present).
- Launcher suite 42/42.
- **Not yet run end-to-end through a rebuilt launcher against a live
triage job.** That is the remaining gap.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5 <[email protected]>1 parent 6cc6a8e commit b4ffbc6
7 files changed
Lines changed: 26 additions & 16 deletions
File tree
- sandbox-runner
- agent-sandbox
- launcher
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
382 | 392 | | |
383 | 393 | | |
384 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
0 commit comments