test(rpc): 7098 route-to-predecessor waits for agent_end before the follow-up prompt (#7388)
Refs #7388 (one of its two failing families; the other is still being traced and stays open on the issue).
Failure
CI run 45075332026, Test (coding-agent 5/10): test/suite/regressions/7098-route-to-predecessor.test.ts > "routes a detached turn, then keeps the handle after predecessor park" failed at line 140: the follow-up prompt ("running on successor") answered success: false.
Cause (test side)
In the park transition the test releases the held model, waits only for the client's message_end, and then sends the next prompt. message_end arrives while the turn is still settling; a prompt without streamingBehavior during a streaming turn is refused (docs/rpc.md, "During streaming"). The test raced the end of the turn, not the product.
Fix
Wait for the turn's end (agent_end for the session) before sending the next prompt. JsonlPeer.waitFor also matches records already received, so the signal cannot be missed. No retry, longer timeout or skip.
Evidence
- The file passes locally (2/2) on a built tree.
- Under CPU stress (30 busy loops), 10/10 runs pass with the change. The old version also passed 10/10 locally, so the race did not reproduce on this machine; the CI log above is the failing evidence, and the refusal contract is the documented streaming rule.
Summary by cubic
Fixes a test race in 7098-route-to-predecessor.test.ts where the follow-up prompt could be refused as streaming.
- The test now waits for
agent_endinstead ofmessage_endbefore sending the next prompt, sincemessage_endarrives while the turn is still settling. JsonlPeer.waitFormatches already-received records, so the turn-end signal cannot be missed.