Repository navigation
test: simulate opencode's request instead of running its CLI - #131
Merged
Merged
Conversation
The opencode job has been red on every PR for weeks. Its Test 2 installed opencode-ai from npm and ran `npx opencode run`, which the runner OOM-kills (`Killed: 9`) — after the server had already answered correctly. The failure said nothing about SwiftLM, and a permanently red job that nobody can act on is a job people stop reading. What is worth testing is the request shape opencode sends, so Test 2 now issues it directly through the OpenAI SDK: a coding-agent system prompt, a tool catalogue, streaming on. It then reassembles the response the way a strict client must — tool-call deltas keyed by index — and asserts the stream parses, reports a finish_reason, every tool call carries a function name, and the accumulated arguments are valid JSON. No npm, no CLI, no OOM. Because the job can now pass, it is no longer continue-on-error: a failure here means SwiftLM misbehaved and should block the merge. Local run against the same model CI uses: 2 passed, 0 failed — 28 chunks, finish_reason=tool_calls, tool_calls=1, so the tool-call reassembly path is genuinely exercised rather than skipped. Refs #128. Co-Authored-By: Claude Opus 5 <[email protected]>
- release.yml's comment asserted the opposite of the new behaviour: it said opencode is continue-on-error so its failures do not block releases. This PR removed that waiver, and #127 gates releases on CI success, so an opencode failure now stops the release. That coupling is intentional but was documented nowhere else. - The simulation omitted stream_options: {include_usage: true}, which opencode's networking layer injects into every streaming request. It makes SwiftLM append a terminal chunk with an empty `choices` array — exactly the shape a strict SSE client can trip on, and previously covered only by curl+grep, never by an SDK parser and never alongside tools. - A run where the model emits no tool call still passes, by design, so the job cannot flake. But it could then go quietly vacuous — green forever while the reassembly path stops being exercised — so that case now prints a loud WARNING. Local run: 2 passed, 0 failed, 31 chunks, finish_reason=tool_calls, tool_calls=1 with the usage chunk present. Co-Authored-By: Claude Opus 5 <[email protected]>
solderzzc
added a commit
that referenced
this pull request
Aug 8, 2026
Removing the opencode CLI in #131 was right — the runner OOM-killed it after the server had already answered, and its assertions were a two-string grep — but it left every SSE assertion in CI going through Python httpx. That matters because SwiftLM frames SSE with \r\n\r\n rather than the spec's \n\n. httpx tolerates it; whether a different parser does is exactly what a second implementation establishes, and there was no longer one. tests/test-sse-node.js uses Node's built-in fetch and a manual event split — no npm install, node is preinstalled on macos-15, so it reintroduces none of the memory pressure that motivated #131. It asserts the framing is parseable, there is exactly one [DONE] terminator, every payload is valid JSON with a choices array, a finish_reason is reported, content accumulates, and the terminal usage chunk with an empty choices array does not break accumulation. Run from test-contract.sh against the already-running server, and skipped rather than failed where node is absent. Local run: 7 passed, 0 failed. It confirms empirically that the server emits \r\n\r\n, which was previously only an implementation detail nothing asserted. Fixes #134. 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.
The
opencodejob has been red on every PR for weeks, and its failure never said anything about SwiftLM.What was happening
Test 2 ran
npm install opencode-aithennpx opencode run. The runner OOM-kills the CLI:The server had already answered correctly. The job was measuring the npm CLI's memory footprint on a CI runner, and it was waived with
continue-on-error— a permanently red job nobody can act on, which is a job people stop reading.What it does now
Issues the request shape opencode actually sends, through the OpenAI SDK already installed for Test 1:
bash,read)stream: trueindexand asserts: the stream parses, it reports a
finish_reason, every tool call carries a function name, and the accumulatedargumentsare valid JSON. No npm, no CLI, no OOM.Result
Local run against the same model CI uses:
tool_calls=1matters: the model really did emit a tool call, so the index-keyed reassembly path is exercised rather than vacuously skipped. That is a stronger assertion than "the CLI did not crash" — it would catch the missingindexfield regression that OpenAI-compat clients depend on.continue-on-erroris removed. The job can pass now, so a failure means SwiftLM misbehaved and should block.Refs #128.
🤖 Generated with Claude Code