Repository navigation
fix(sse): trim oversized tool enums on opencode dispatch - #15756
Merged
diegosouzapw merged 1 commit intoOct 8, 2026
Merged
Conversation
OpenCode upstream 400s requests whose single enum property exceeds 250 values or 15000 combined chars. Cap offending enums to 200 values / 12000 chars with a description note before dispatch.
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.
OpenCode upstream rejects a request with HTTP 400 when a single enum property carries more than 250 values or the combined enum string length exceeds 15000 characters. Generic SDK clients with VSCode-shaped caller tools (300+ allowed values, no native OpenCode prompt) hit this on otherwise valid oc/* requests.
Change: new shape-agnostic trimOversizedToolEnums helper (open-sse/executors/opencodeEnumTrim.ts) caps every offending enum to 200 values / 12000 combined chars with a description note. Wired into OpencodeExecutor.transformRequest after the free-tier contract prep, so caller tools and contract-borrowed declarations are covered on all surfaces (opencode, opencode-zen, opencode-go).
Complements open PR #15143 (native contract / pause scoping), which does not address the enum 400.
Tests: new tests/unit/opencode-enum-trim.test.ts (5 cases: passthrough, value cap, char cap, non-string enums, transformRequest integration). Verified 5 pass plus 13 existing opencode tests pass. Lint clean.
Live verification (local dev server, isolated DATA_DIR, base + this patch)
oc/big-pickle, generic shape:403 FreeTierError: OpenCode's free tier can only be used from within OpenCode(reproduces the reported symptom; the free-tier contract already borrows native tool declarations, upstream still refuses with a noauth routing error).opencode-zen/muse-spark-1.3-contributor-free, bare shape: same 403 (expected for non-contract shapes).200with content. The keyed native path works with this patch applied.Relationship to draft #15143
This PR fixes only the enum-400 described above. The
403 FreeTierErrorfor bare/keyless shapes is owned by draft #15143 (native request contract + pause scoping), which is the important follow-up for making opencode free-tier models usable from generic clients. The two PRs are complementary: #15143 without this fix still 400s on VSCode-shaped tools with oversized enums, and this fix without #15143 still 403s on bare shapes.