Commit a4ec6ec
authored
Fix validate_tool hang: pass stdin=DEVNULL to the validation subprocess (#218)
* Fix validate_tool hang: pass stdin=DEVNULL to the validation subprocess
`validate_tool` runs each tool's smoke test (e.g. `pi --print "say hi in 5
words or less"`) via `subprocess.run(..., timeout=60)` without setting
`stdin`, so the child inherits ucode's own stdin. In print/headless mode some
agent CLIs (pi among them) still open stdin and block waiting for input/EOF.
When ucode is launched from a non-interactive parent whose stdin is an open
pipe with no EOF — e.g. an agent harness spawning `ucode <tool>` as a
subprocess — the validation command never sees EOF, blocks for the full 60s,
and `validate_tool` returns `(False, "timed out")`. The caller
(`_auto_configure_tool` / configure) then reverts the config and aborts with
"<tool> validation failed — config reverted", even though the tool is
correctly configured and the gateway is reachable.
The validation smoke test is one-shot and never needs interactive input, so
pass `stdin=subprocess.DEVNULL`. This is benign for every tool (an interactive
prompt in a validation run would itself be a bug) and makes validation robust
regardless of how ucode was launched.
Verified on a managed sandbox: `pi --print "say hi"` returns instantly with
`stdin=DEVNULL` but hangs to the timeout when it inherits an open stdin pipe.
Signed-off-by: Edwin He <edwin.he@databricks.com>
* Remove explanatory comment on the validate_tool stdin=DEVNULL kwarg
Per review: the kwarg is self-explanatory; drop the comment block.
---------
Signed-off-by: Edwin He <edwin.he@databricks.com>1 parent eea5ffb commit a4ec6ec
2 files changed
Lines changed: 41 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
470 | 476 | | |
471 | 477 | | |
472 | 478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
0 commit comments