Skip to content

fix(web): chain MRTR rounds when the server rotates requestState - #2610

Merged
cliffhall merged 4 commits into
v2/mainfrom
v2/fix/2608-mrtr-rotating-request-state
Oct 7, 2026
Merged

cliffhall merged 4 commits into
v2/mainfrom
v2/fix/2608-mrtr-rotating-request-state

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2608

What changed

The Protocol panel grouped MRTR rounds (spec §7.3) by one shared key: extractRequestState preferred the token a round's result issued over the one its params echoed. mrtr_two_step mints a fresh token every round (it is opaque, so servers are free to do that). Retry 1 was therefore keyed on the token it received (done) rather than the one it echoed (step2). The conversation split in two, and the original call was left showing Awaiting input even though it completed.

groupProtocolEntries (clients/web/src/components/groups/protocolUtils.ts) now links rounds by hand-off:

  • A round joins the row before it when it echoes the requestState that the neighbouring round's result issued. Two retries that echo the same token are also linked, so a round whose result was an error and was then retried stays in the conversation, as it did before.
  • The check runs in both directions, because the list is sorted Newest First by default. In that order the earlier round arrives second.
  • A conversation is named by its chronologically first token, whichever way the list is sorted.

extractRequestState keeps its signature and behaviour.

Tests

protocolUtils.test.ts adds four cases:

  • a rotating-token conversation, oldest-first;
  • the same conversation newest-first;
  • a lone retry named by the token it echoed;
  • two retries echoing one token after an error round.

The first three fail on origin/v2/main (3 failed / 25 passed) and pass with the fix. The fourth is a regression guard for behaviour the old single-key grouping already had.

Screenshots

mrtr_two_step against mrtr-showcase-http.json (Protocol Era: modern), both prompts answered, Protocol panel in its default Newest First order. Web client at 1280×900, full page.

Before After
before after
Two rows: "2 rounds · Complete" plus "1 round · Awaiting input" One row: "3 rounds · Complete"

Gate

npm run local:gate is green, run with TMPDIR=/tmp. Under macOS's default TMPDIR it fails at one TUI test, useCopyKeys › "W saves the value to a file and shows its path". That failure is unrelated to this diff, which touches only clients/web, and it reproduces on v2/main. The long temp path wraps in Ink's 80-column frame. It is filed as #2609.

🤖 Generated with Claude Code

The Protocol panel keyed each round on one requestState, preferring the
token a round's result issued over the one its params echoed. A server
that mints a fresh token per round (mrtr_two_step) split the conversation
in two and left the original call shown as Awaiting input.

Link rounds by hand-off instead: a retry joins the conversation when it
echoes the token the round before it was issued, checked in both
directions so a newest-first list chains too.

Closes #2608

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall cliffhall added the v2 Issues and PRs for v2 label Oct 6, 2026
@cliffhall
cliffhall requested a balanced review from Copilot October 6, 2026 21:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Bidirectional matching remains sort-dependent when opaque request-state values are reused cyclically.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes #2608 by chaining MRTR rounds through request-state hand-offs rather than a shared token.

Changes:

  • Adds issued/echoed token correlation in both sort orders.
  • Adds regression coverage for rotating tokens and retries.
File Description
protocolUtils.ts Implements MRTR round chaining.
protocolUtils.test.ts Tests rotating-token conversations and retries.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Checking both directions let a reused opaque token (A -> B, then B -> A)
match the wrong way round, so a newest-first list named the conversation
differently from an oldest-first one. Pass the panel's sort direction
and test only the chronological hand-off.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1: one finding, fixed.

  • Bidirectional check misgroups conversations with reused requestState values (protocolUtils.ts): fixed in 284b6dc. Grouping now takes the list's sort direction and checks only the chronological hand-off, so naming no longer depends on sort order. Covered by two new tests, which fail on the old logic. local:gate is green (with TMPDIR=/tmp; see TUI useCopyKeys save-path test fails on macOS's long default TMPDIR #2609).

There was nothing in the suppressed block. Requesting round 2.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation matches MCP request-state semantics and includes focused regression coverage.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed. Round 2 was clean ("Approval recommended", no findings, no inline or suppressed comments) and it marked round 1's finding resolved. Stopping on the first clean round.

@cliffhall
cliffhall merged commit de88759 into v2/main Oct 7, 2026
2 checks passed
@cliffhall
cliffhall deleted the v2/fix/2608-mrtr-rotating-request-state branch October 7, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Protocol panel splits a multi-round MRTR conversation when the server rotates requestState

2 participants