Repository navigation
test(platform): pin both Stop paths that doubled a round's text - #3215
Merged
Merged
Conversation
The duplicate-text fix landed with a regression test for one of the three paths that can break out of a tool round after it settles: the pausing `ask_question` lane. The two Stop paths #2962 actually named had none. Both break after the settle, so both relied on the same `roundSettled` guard the pause test covers — but only by coincidence of sharing it. A new `break` placed before the flag is set would reintroduce the bug on a path nothing asserts. Add the two the issue named: - a Stop that lands on the tool-round boundary flush, before the tools run - a Stop that lands on the post-batch verdict read, while they run Both stream NON-EMPTY text before the call, which is the whole reason this went unnoticed: a model that says nothing before calling passes straight through the bug. The issue says so explicitly, and the existing pause test carries the same note. `fakeStore` gains two hooks to place the Stop precisely. The tool-round boundary is the only `streamProgress` write that is both flushed and empty, and the post-batch verdict the only empty unflushed one, so neither hook has to count writes and guess. Dropping the `!roundSettled` guard now fails three tests instead of one.
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.
Closes #2962 — the bug itself is already fixed on main; this adds the coverage
for the two paths the issue actually named.
What was and wasn't covered
lib/chat/turn.tssettles a round's text before running its tools, so anybreakafter that point leavesstreamedpointing at what was just settledand the finalize would append it twice. Three paths break there:
ask_questiontoolsettles pre-question text exactly onceThe
roundSettledflag and its per-iteration reset are both in place, and theguard is shared, so the two Stop paths were correct — but only by sharing a
flag the pause test happens to cover. A new
breakplaced beforeroundSettled = truewould reintroduce the bug on a path nothing asserts.The tests
Both stream non-empty text before the call. That is the whole reason this
went unnoticed: a model that says nothing before calling passes straight
through the bug. The issue says so, and the existing pause test carries the
same note about its own first attempt.
fakeStoregains two hooks so the Stop lands exactly where each path readsit. No write-counting or index guessing is needed — the tool-round boundary is
the only
streamProgresswrite that is both flushed and empty, and thepost-batch verdict the only empty unflushed one.
The boundary test also asserts the tools never executed, and the verdict test
that the finished batch keeps its
tool-result— a Stop ends the loop, it doesnot erase the round.
Verification
!roundSettledguardsettles pre-question text exactly once, and both new testsroundSettledbetween roundsexecutes the calls, settles parts in order, and answersBefore this PR the first mutation failed one test. Now it fails three.
Test-only:
turn.test.ts46 passed,typecheck0 errors,oxlint --type-awareclean,oxfmt --checkclean.