Repository navigation
fix(opencode): clarify review and efficient tool use, refresh native cassettes (Refs #772) - #778
Closed
agenteinstinct1-max wants to merge 2 commits into
Closed
agenteinstinct1-max wants to merge 2 commits into
agenteinstinct1-max wants to merge 2 commits into
Conversation
Scoped replacement for #773, whose diff carried four unrelated Windows owner-death test/fixture files and reverted two accepted TUI files because it was based on a pre-a241c84 commit. This branch starts from the accepted tip a241c84 and carries only the five owned files: review.txt, session/llm/request.ts, session/prompt/efficiency.txt, test/session/ste-lite.test.ts and specs/agent-effort.md. Refs #772 Co-authored-by: arena-agent <[email protected]>
…iency prompt (Refs #772) The shared efficient-tool-use block is injected in LLMRequestPrep.prepare, so every provider request body carries it. The three native tool-loop cassettes assert the exact outgoing body, so they rejected the new request before any assertion ran (deterministically, on Linux and Windows alike). This refreshes only the recorded *request* snapshots of those three cassettes and leaves the recorded *responses* byte-identical: - The snapshots were produced by the real recorder code path (HttpRecorderInternal.recordingLayer, mode "record", same url/body redactor and metadata the replay path uses), so the body, headers and URL are exactly what the current stack sends - not hand-written text. - That recording layer ran against a stub upstream that replayed the existing recorded response bytes in order, so no provider was contacted and no credentials were used. Responses are unmodified, which is why the tool-loop assertions (get_weather call, "Paris is sunny") are unchanged. - metadata keeps the original recordedAt (the responses are the originals) and adds requestBodiesRecapturedAt/requestBodiesRecapturedFrom so the provenance is explicit rather than a cassette that silently claims to be newer. The diff per file is therefore the two request bodies plus two metadata lines. Causal control: restoring packages/opencode/src/session/llm/request.ts to the pre-change content makes all three cassettes fail again with the same "$.instructions"/"$.input[0].content" mismatch, so the fixtures track the injection instead of being loosened to accept it. The matcher, the assertions and the cassette format are untouched. A live re-record with OPENCODE_RECORD_* credentials remains the preferred refresh once available. Refs #772 Co-authored-by: arena-agent <[email protected]>
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
4 of 6 tasks
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.
Issue for this PR
Closes #772
#772stays open: this PR targetsdev-vibecoded, and GitHub only auto-closes issues from PRs merged into the repository default branch (dev). The closing keyword is present to satisfy the linked-issue check inpr-standards.yml, not to close the issue.This continues #776 (
arena/6f7f66ad-silvercode, head4c11b1b9407cf7423eeef768fcb42af9b70f0543, basea241c84e3b57c958977fd31d51cc3a30e84d341f). #776 carried the change and left it as a draft because three recorded cassettes rejected the new request body. This branch keeps #776's five files byte-identical and adds the missing cassette refresh, so it is the same change with the known-red blocker resolved. #776 is superseded by this PR; nothing here is a revert of it.Type of change
What does this PR do?
Two commits on top of
a241c84e3b57c958977fd31d51cc3a30e84d341f, no history rewrite, no force-push, no rebase, no base revert.9e09311— #776's change, unchanged. The one shared prompt block is injected inLLMRequestPrep.prepare, so it applies to every agent, every provider and every effort level with no runtime fan-out, no effort gating, and no exemption for OAuth or fallback paths:packages/opencode/src/agent/prompt/review.txt— Review may not author tests/scripts, make production edits, fix the implementation or take over Code/Work; existing non-destructive checks stay allowed. Review still evaluates premise, completion, instruction following and the Assessment/verdict envelope, including the bar on unsupported approval. Reading guidance is scope-first with batched range reads.packages/opencode/src/session/prompt/efficiency.txt(new) — fast/quick/direct at every effort level; targeted searches then batched reads; independent read/grep/glob calls in parallel, dependent calls sequential.packages/opencode/src/session/llm/request.ts— injects that block into the system prompt of every prepared request.packages/opencode/test/session/ste-lite.test.ts— regression tests for prompt assembly across fast/medium/thorough and for the Review text contract.specs/agent-effort.md— documents efficient work at every level.26e98f8— the cassette fix. The three native tool-loop cassettes assert the exact outgoing body, so the recorder rejected the new request before any assertion ran (Fixture "session/native-openai-oauth-tool-loop" does not match the current request: body: $.instructions expected … received …). Only the recorded request snapshots are refreshed; the recorded responses are byte-identical to what was originally recorded, which is why the tool-loop assertions (theget_weathercall and "Paris is sunny") are untouched.Why this seam and not an exemption: instructions are part of the recorded request protocol, so a request-body change must show up in the cassette. The alternatives were all worse — deleting or skipping the assertions, exempting
$.instructionsin the matcher, writing a test-only bypass in production code, or a paid re-record. Those are exactly the things this change must not do, so the fixture was refreshed truthfully instead.How the cassettes were refreshed (offline, no provider contacted)
HttpRecorderInternal.recordingLayer(cassette, { mode: "record", metadata, redactor: Redactor.make(redact) })with the same url/body redactor and metadata the replay path uses — driven by the same test stack (Provider.node+LLM.node, realRequestExecutor, realLLM.stream, the same weather tool and tool loop). The bodies are what this code actually sends, not hand-written text.HttpClientthat replayed the existing recorded response bytes in order, so no network call and no credential were used. The stub only fed back the original responses; it did not alter the request.metadata.recordedAtis preserved (the responses are the originals) and two fields are added —requestBodiesRecapturedAtandrequestBodiesRecapturedFrom: "replayed-recorded-responses"— so provenance is explicit instead of a cassette silently claiming to be newer. A future live re-record drops them automatically, because the test's metadata does not contain them.Honest limits of the offline refresh
instructionsinside its response objects, so that echo still shows the pre-change prompt even though the adjacent request now carries the new one. Rewriting the echo would fabricate provider output, so it is left as recorded.RECORD=trueplusOPENCODE_RECORD_*credentials (documented inllm-native-recorded.test.ts) remains the preferred refresh and clears that inconsistency. This PR's alternative — leaving three cassettes red — cannot be merged.session/native-openai-tool-loopis still skipped: that cassette has never existed in the repo, so the "OpenAI API key" scenario skips rather than exercises the API-key path.Scope
git diff a241c84 HEADis exactly these eight paths, and every other tracked file matches the accepted tip byte for byte:Three fixture files beyond #776's five is the honest minimum: without them the change cannot be tested at all, and no code file was widened. Deliberately excluded: the four
win-owner-deathfiles from #773, the two TUI files #773 silently reverted,packages/opencode/src/session/llm.ts, andsrc/session/prompt.ts(owned by draft #770).specs/agent-effort.mdis also edited by #770, so that documentation overlap still needs reconciling before integration.How did you verify your code works?
Linux sandbox, 2 vCPU / 3 GB RAM. Bun 1.3.14 installed outside the repo;
bun install --frozen-lockfile --ignore-scripts.bun test test/session/llm-native-recorded.test.ts: 3 pass, 1 skip, 0 fail, 24 assertions.request.tstoa241c84turns all three red again with the same$.instructions/$.input[0].contentmismatch, then the tree was restored and re-verified clean. The fixtures therefore track the injection instead of being loosened to accept it.ste-lite.test.tsfails withExpected to contain: "Be fast, quick, and direct at every effort level"; it detects the change rather than passing vacuously.bun test test/session/ste-lite.test.ts test/agent/agent.test.ts test/session/system.test.ts test/session/review-specialization.test.ts test/session/llm-native-recorded.test.ts: 115 pass, 2 skip, 0 fail, 458 assertions.bun test test/session: 865 pass, 8 skip, 1 todo, 0 fail across 36 files. fix(opencode): clarify review and efficient tool use (Refs #772) #776 reported 860 pass / 5 fail on the same directory; all five now pass, including the two it had flagged as pre-existing (session.processor model-switch during retry > … cancels retry promptlytiming assertion and the order-sensitivesession.llm.stream > sends temperature, tokens, and reasoning options for openai-compatible models). Both were also re-run in isolation here and passed, but they were genuinely flaky at fix(opencode): clarify review and efficient tool use (Refs #772) #776's head, so treat them as such rather than as fixed by this change.prettier --checkclean on the changed JSON, TS and spec files (the two.txtprompts have no parser, which is expected);git diff --checkreports no whitespace errors; all three cassettes parse as JSON and their request bodies parse as JSON.tsc --noEmitexit 0. In this sandboxtsc --noEmitaborts with OOM (exit 134) andtsgois SIGKILLed, at 3 GB with no swap; that is environmental, and I am not claiming a typecheck I did not get.No CI run on this exact commit and no independent review is claimed. The tests exercise prompt assembly, cassette replay and text contracts, not model compliance in live use.
Screenshots / recordings
Not a UI change.
Checklist