Repository navigation
fix(sandbox-runner): use OpenAI's own SDK for OpenAI runs, and bump opencode to 1.18.30 - #26
Merged
Conversation
…ps rejecting them
Every Layer-2 triage run against gpt-5.6-luna failed with "opencode produced no
usable reply" and zero tokens booked, on a valid key.
The cause is that `@ai-sdk/openai-compatible` always sends `max_tokens`, and the
GPT-5.x reasoning line rejects it outright ("Unsupported parameter ... use
max_completion_tokens instead"). OpenCode folds that 400 into an empty assistant
turn, so a hard credential-shaped failure reached us as an empty reply with no
spend, which is why it read as a key problem and was not one.
`@ai-sdk/openai` rewrites the field per model 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 the gap as
opencode #45223, still open, so this does not wait on them.
Scoped to the OPENAI mode alone. Every other mode this function serves (gemini,
glm, grok, moonshot, openrouter, custom-openai) points at a deliberate
OpenAI-compatible endpoint, where the compat adapter stays the right tool.
Verified against a real key inside the agent image, on both the pinned 1.18.13 and
1.18.30: the compat adapter reproduces the 400, the native package returns a reply.
Co-Authored-By: Claude Opus 5 <[email protected]>
1.18.13 dated from 4 August. Moved across both recipes at once, plus the host-local package.json and lockfile, since the Dockerfile's own header requires the CLI and @opencode-ai/sdk to ship in lockstep: agent-stream.js reads message-part field names that move between releases. This does NOT fix the max_tokens rejection the previous commit addresses. That was measured, not assumed: 1.18.30 reproduces the failure identically while still on the compat adapter, because opencode #44710's provider gating does not recognise a custom `openai-compatible` block like `openai-direct`. The two changes are independent and this one stands on being current, not on fixing anything. The release-age exclusion names 1.18.30 alone. pnpm appends rather than replaces, and that file asks for one exact version so it lapses on the next bump. Verified: the image builds clean on this base and reports 1.18.30 for both the CLI and the SDK. Launcher suite is 42/42. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
Every Layer-2 triage run against
gpt-5.6-lunawas failing. The symptom was maximally misleading:Zero tokens, valid key. That reads like a credential or connectivity problem, and it is neither.
Why
@ai-sdk/openai-compatiblealways sendsmax_tokens. OpenAI's GPT-5.x reasoning line rejects it: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/openairewrites the field per model (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, still open with no scheduled fix, so this does not wait on them.What changed
fix—openAiCompatProviderBlockselects@ai-sdk/openaifor theOPENAImode,@ai-sdk/openai-compatiblefor everything else. One line plus its rationale, and the two test assertions that pinned the old value.chore—opencode-aiand@opencode-ai/sdk1.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's provider gating does not recognise a custom
openai-compatibleblock likeopenai-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/v1andgenerativelanguage.googleapis.com/v1beta/openai/are deliberately maintained OpenAI-compatible surfaces with a stated compatibility contract. OpenAI's/v1is 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/xaiis a closer call than the others: it defaults to the sameapi.x.ai/v1base 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/googleuses a different endpoint path and anx-goog-api-keyheader 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), 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
GET /v1/models→ 200, model present).🤖 Generated with Claude Code