Commit a53aff3
authored
fix(codex): emit paired tool_result chunks so UI tool cards close (#1032)
* fix(codex): emit paired tool_result chunks so UI tool cards close
Tool cards in the web UI sometimes spin forever for Codex workflows.
The Codex client only yielded { type: 'tool', ... } on item.completed
events, never the paired tool_result chunk. The web adapter's running
tool entry then had nothing to close it, leaving the UI relying on the
emitLockEvent fallback at lock release — which never fires inside a
multi-node DAG, on cancel, or when SSE is briefly disconnected.
The Codex SDK only emits item.completed once a command_execution,
web_search, or mcp_tool_call is fully done (it carries aggregated_output,
exit_code, status, etc). So we can emit the start and the result
back-to-back in the same handler.
Changes:
- command_execution: emit tool_result with aggregated_output, append
[exit code: N] when non-zero so failures are visible.
- web_search: emit empty tool_result so the searching card closes.
- mcp_tool_call: always emit tool + tool_result, including for the
status === 'completed' branch which previously emitted nothing at all
(so completed MCP calls were invisible) and for status === 'failed'
where we previously emitted only a system message (leaving no card to
close, but inconsistent with command_execution failures).
- Update codex.test.ts assertions to cover paired chunks and exit codes.
Note: tool_result is paired to its tool by the web adapter's name-based
reverse-scan in web.ts. Since these chunks are yielded back-to-back with
no other tools in between, the match is unambiguous. PR #1031 will add
stable tool_use_id pairing for Claude; a follow-up can plumb Codex's
item.id through once that lands.
* fix(codex): log silent drops and assert paired web_search tool_result
- command_execution: warn when item.command is falsy (was silently dropped)
- mcp_tool_call: warn when result.content has unexpected shape (was silent empty)
- Simplify exit_code guard to != null, drop redundant String() cast
- Test: assert paired tool_result chunk for web_search
Addresses review feedback on #1032.1 parent a5091b2 commit a53aff3
2 files changed
Lines changed: 141 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| 115 | + | |
| 116 | + | |
110 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
111 | 151 | | |
112 | 152 | | |
113 | 153 | | |
| |||
143 | 183 | | |
144 | 184 | | |
145 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
146 | 191 | | |
147 | 192 | | |
148 | 193 | | |
| |||
349 | 394 | | |
350 | 395 | | |
351 | 396 | | |
| 397 | + | |
352 | 398 | | |
353 | 399 | | |
354 | | - | |
355 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
356 | 410 | | |
357 | 411 | | |
358 | 412 | | |
| |||
384 | 438 | | |
385 | 439 | | |
386 | 440 | | |
| 441 | + | |
387 | 442 | | |
388 | | - | |
389 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
390 | 456 | | |
391 | 457 | | |
392 | 458 | | |
| |||
405 | 471 | | |
406 | 472 | | |
407 | 473 | | |
408 | | - | |
409 | | - | |
410 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
411 | 479 | | |
412 | 480 | | |
413 | 481 | | |
414 | | - | |
| 482 | + | |
415 | 483 | | |
416 | 484 | | |
417 | 485 | | |
418 | 486 | | |
419 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
420 | 494 | | |
421 | 495 | | |
422 | 496 | | |
| |||
427 | 501 | | |
428 | 502 | | |
429 | 503 | | |
430 | | - | |
431 | | - | |
432 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
433 | 513 | | |
434 | 514 | | |
435 | 515 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
312 | 315 | | |
313 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
314 | 328 | | |
315 | 329 | | |
316 | 330 | | |
| |||
323 | 337 | | |
324 | 338 | | |
325 | 339 | | |
326 | | - | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
327 | 344 | | |
328 | 345 | | |
329 | 346 | | |
| |||
394 | 411 | | |
395 | 412 | | |
396 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
397 | 419 | | |
398 | 420 | | |
399 | 421 | | |
400 | 422 | | |
401 | 423 | | |
402 | 424 | | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
409 | 449 | | |
410 | 450 | | |
411 | 451 | | |
| |||
0 commit comments