Commit 1fa7d65
authored
fix(router): scope hasToolResult to the current turn (multi-turn replay) (#316)
## Problem
`match.hasToolResult` is a whole-conversation predicate — "does ANY
message have role `tool`". In a multi-turn chat session that pins it to
`true` forever after the first tool call, so a turn's **leg-1** fixture
(`hasToolResult: false`, the tool-call leg) can never match again: every
2nd+ user turn carries an earlier turn's tool result.
Symptom in the CopilotKit showcase (Beautiful Chat): the first pill/tool
in a thread works, but every pill after it returns **"No fixture
matched"** (schedule-meeting, excalidraw, calculator, etc.). Reproduced
+ verified fixed against the live showcase.
## Fix
Scope `hasToolResult` to the **current turn** — messages after the last
`user` message. For a single-turn request this is identical to the old
check (so existing fixtures are unaffected); multi-turn leg-1 fixtures
match again.
## Tests
Updated the `hasToolResult` unit tests to use realistic leg-2 shapes
(the tool result is the last message of the turn, not followed by a
fresh user message — the old tests appended a trailing user message,
which is actually the multi-turn leg-1 case) and added a multi-turn
regression test. Full suite green (4448 tests).
## Consumer note
CopilotKit showcase needs the released version (npm + ghcr) to fix
multi-turn manual testing; CI single-turn probes are unaffected either
way.2 files changed
Lines changed: 65 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
1225 | | - | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
1226 | 1234 | | |
| 1235 | + | |
1227 | 1236 | | |
1228 | 1237 | | |
1229 | 1238 | | |
1230 | 1239 | | |
1231 | 1240 | | |
1232 | | - | |
1233 | 1241 | | |
1234 | 1242 | | |
1235 | 1243 | | |
| |||
1255 | 1263 | | |
1256 | 1264 | | |
1257 | 1265 | | |
1258 | | - | |
| 1266 | + | |
1259 | 1267 | | |
| 1268 | + | |
1260 | 1269 | | |
1261 | 1270 | | |
1262 | 1271 | | |
1263 | 1272 | | |
1264 | 1273 | | |
1265 | | - | |
1266 | 1274 | | |
1267 | 1275 | | |
1268 | 1276 | | |
1269 | 1277 | | |
1270 | 1278 | | |
1271 | | - | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
1272 | 1296 | | |
1273 | 1297 | | |
1274 | 1298 | | |
| |||
1278 | 1302 | | |
1279 | 1303 | | |
1280 | 1304 | | |
| 1305 | + | |
1281 | 1306 | | |
1282 | 1307 | | |
1283 | 1308 | | |
1284 | 1309 | | |
1285 | 1310 | | |
| 1311 | + | |
1286 | 1312 | | |
1287 | 1313 | | |
1288 | 1314 | | |
1289 | 1315 | | |
1290 | 1316 | | |
1291 | | - | |
1292 | 1317 | | |
1293 | 1318 | | |
1294 | 1319 | | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1295 | 1333 | | |
1296 | 1334 | | |
1297 | 1335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
461 | 461 | | |
462 | 462 | | |
463 | 463 | | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
468 | 477 | | |
469 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
470 | 486 | | |
471 | 487 | | |
472 | 488 | | |
| |||
0 commit comments