Skip to content

fix(sandbox-runner): use OpenAI's own SDK for OpenAI runs, and bump opencode to 1.18.30 - #26

Merged
infinitetrooper merged 2 commits into
mainfrom
claude/tessary-triage-monitoring-378257
Sep 9, 2026
Merged

infinitetrooper merged 2 commits into
mainfrom
claude/tessary-triage-monitoring-378257

Conversation

@infinitetrooper

Copy link
Copy Markdown
Member

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) 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 — 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's 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), 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

infinitetrooper and others added 2 commits September 9, 2026 23:07
…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]>
@infinitetrooper
infinitetrooper merged commit b4ffbc6 into main Sep 9, 2026
1 of 2 checks passed
@infinitetrooper
infinitetrooper deleted the claude/tessary-triage-monitoring-378257 branch September 9, 2026 17:53
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.

1 participant