Repository navigation
Conversation
A streamed tool turn sent its preamble twice. Sentence quarantine releases the prose before the first tool-call marker live, and finalize then wrote the whole preamble again. OpenCode stored the doubled text, so the next turn's assistant echo never matched the committed response and every turn replayed the full transcript. Finalize now writes only the unsent part of the content whenever prose already streamed, then the tool-call chunks. The echo check now ignores differences the client introduces when it replays a turn: surrounding whitespace in assistant text, an empty string or null for a tool-only turn, and the key order of re-serialized tool arguments. Different text, arguments or ids still force a fresh replay. A worker that passed the capability handshake for an agent no longer probes again on every fresh job. The handshake checks the agent's installed WPP instruction, which a fresh chat does not change, and claim() still clears the result when the worker switches agents. The sessionThreads entry in AGENTS.md describes the looser echo check.
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
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. |
This was referenced Oct 19, 2026
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.
Related issue (optional)
None. Follows the bridge review findings for the duplicate preamble, the strict thread echo check and the repeated capability probe.
Companion PR: https://github.com/trmosala/CM-WPP-Bits/pull/2 ports the same fix to the extracted bridge package. That keeps the fix when the CookieMonster split removes
packages/desktop/src/main/wpp-bridge/from this repo.Overlaps #72 in
openaiCompat.mjsandAGENTS.md, on different lines. #72 changes the parser call sites and the normalizer entry. This PR changesfinalizeStreamedCompletionand thesessionThreads.mjsentry.Type of change
What does this PR do?
Restores WPP thread continuation and removes an extra WPP request from fresh turns:
Duplicate preamble. On a streamed tool turn, sentence quarantine sends the prose before the first tool-call marker live.
finalizeStreamedCompletionthen wrote the whole preamble again, and OpenCode stored the doubled text. Finalize now writes only the part of the content that wasn't streamed, then the tool-call chunks. Recovery replays and turns that streamed nothing still get the full content.Thread echo check.
sessionThreads.mjscompared the committed response with the client's replay of it byte for byte. That replay differs in harmless ways:""(V1 SDK) ornull(V2) for a tool-only turnThe doubled preamble never matched either, so every turn fell back to a fresh replay of the full transcript. The echo hash now ignores surrounding whitespace in assistant text, treats
nulland""alike, and compares arguments as JSON values. Different text, arguments or ids still force a fresh replay.Capability probe.
ensureProtocolCapabilityskipped the probe only on continued turns, so every fresh job sent an extra WPP model request for the handshake first. A worker that passed for an agent now skips the probe on fresh jobs too.claim()still clears the result when the worker switches agents, andcontent.jsstill opens a fresh chat for every job that doesn't continue a thread.Trade-off: if the WPP instruction is removed from an agent while a worker is alive, that worker no longer notices until it is retired. New workers still probe.
The
sessionThreads.mjsentry inAGENTS.mdnow describes the looser echo check. This PR doesn't change the protocol markers, the stream gate, authentication, browser grants, logging, dependencies or release workflows.How did you verify your code works?
bun test src/main/wpp-bridge/frompackages/desktop: 504 pass, 0 fail, including 4 new tests:nullcontent continues from""bun typecheckfrompackages/desktop: pass.oxlinton the six changed files: 0 errors. The 8 warnings are on lines this PR doesn't touch.sessionThreadsandworker-poolfiles are clean. The twoopenaiCompatfiles keep their existing semicolon style.Screenshots / recordings
Not a UI change.
Checklist