Commit 0b4bcc1
fix(core): address codex review findings on async memory recall
Three findings fixed:
1. Abort previous prefetch before installing a new one (line 1059):
A new UserQuery/Cron used to overwrite pendingMemoryPrefetch without
aborting the old controller, leaking an unbounded background recall now
that the 1s side-query timeout is gone.
2. Move the UserQuery consume poll AFTER the async reminder setup:
ensureTool + listSubagents are awaited between the old poll location and
the final assembly, so recalls that settled during those awaits used to
be missed (and a tool-less turn never got a ToolResult retry). The poll
now runs immediately before requestToSend assembly, and unshifts memory
to the front of systemReminders to preserve ordering.
3. Append memory after functionResponse on ToolResult turns:
The Qwen API requires the functionResponse part to immediately follow
the model's functionCall (see lines 1209-1213). Prepending memory text
risked breaking that pairing on the native Gemini path. Appending keeps
the pair intact on Gemini and produces the same OpenAI output (text
becomes a separate user message after the tool messages).
Tests:
- Updated ToolResult inject test to assert memory index > functionResponse
- Added abort-previous-prefetch test (mid-flight UserQuery aborts old handle)
224/224 tests pass; tsc clean on changed files.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 90b8d26 commit 0b4bcc1
2 files changed
Lines changed: 98 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2445 | 2445 | | |
2446 | 2446 | | |
2447 | 2447 | | |
2448 | | - | |
2449 | | - | |
2450 | | - | |
2451 | | - | |
2452 | | - | |
2453 | | - | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
2454 | 2479 | | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
2455 | 2513 | | |
2456 | 2514 | | |
2457 | 2515 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1057 | 1057 | | |
1058 | 1058 | | |
1059 | 1059 | | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
1060 | 1065 | | |
1061 | 1066 | | |
1062 | 1067 | | |
| |||
1274 | 1279 | | |
1275 | 1280 | | |
1276 | 1281 | | |
1277 | | - | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
1283 | | - | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
1287 | | - | |
1288 | | - | |
1289 | | - | |
1290 | | - | |
1291 | | - | |
1292 | | - | |
1293 | | - | |
1294 | | - | |
1295 | 1282 | | |
1296 | 1283 | | |
1297 | 1284 | | |
| |||
1326 | 1313 | | |
1327 | 1314 | | |
1328 | 1315 | | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
1329 | 1337 | | |
1330 | 1338 | | |
1331 | 1339 | | |
| |||
1340 | 1348 | | |
1341 | 1349 | | |
1342 | 1350 | | |
1343 | | - | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
1344 | 1359 | | |
1345 | 1360 | | |
1346 | 1361 | | |
| |||
0 commit comments