Skip to content

test(platform): pin both Stop paths that doubled a round's text - #3215

Merged
Israeltheminer merged 1 commit into
mainfrom
test/pin-stop-paths-2962
Sep 4, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
test/pin-stop-paths-2962

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

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.ts settles a round's text before running its tools, so any
break after that point leaves streamed pointing at what was just settled
and the finalize would append it twice. Three paths break there:

Path Test before this
pausing ask_question tool settles pre-question text exactly once
Stop on the tool-round boundary flush, before the tools run none
Stop on the post-batch verdict read, while they run none

The roundSettled flag and its per-iteration reset are both in place, and the
guard is shared, so the two Stop paths were correct — but only by sharing a
flag the pause test happens to cover. A new break placed before
roundSettled = true would 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.

fakeStore gains two hooks so the Stop lands exactly where each path reads
it. No write-counting or index guessing is needed — 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.

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 does
not erase the round.

Verification

Mutation Went red
drop the !roundSettled guard all three: settles pre-question text exactly once, and both new tests
never reset roundSettled between rounds executes the calls, settles parts in order, and answers

Before this PR the first mutation failed one test. Now it fails three.

Test-only: turn.test.ts 46 passed, typecheck 0 errors, oxlint --type-aware clean, oxfmt --check clean.

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.
@Israeltheminer
Israeltheminer merged commit 574ec59 into main Sep 4, 2026
48 checks passed
@Israeltheminer
Israeltheminer deleted the test/pin-stop-paths-2962 branch September 4, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat turn writes a round's text twice when it stops mid-tool-execution

1 participant