[Bug]: ACP PTY execution reports success without command output or exit status
Description
When the ACP client advertises the terminal capability, VT Code forwards an exec_command call with tty=true (or mode=pty) to terminal/create and immediately returns status success with {terminal_id, mode:'pty', command}. It never reads terminal output or waits for exit, so the model receives no output and no exit status; a command that exits 3 is reported as success, and write_stdin on the returned id fails with 'exec session not found'.
Observed behavior: In 10/10 runs the tool call completed as success with rawOutput {status:success, result:{terminal_id, mode:'pty', command, working_dir:null}}, no output and no exit_code; follow-up write_stdin calls failed; the agent told the user it could not obtain the output or exit code.
Steps to Reproduce
- Use the tested revision and reproduction environment below.
- Prepare the fixture described here:
Use ACP with a client advertising terminal capability and an empty workspace. Call exec_command with tty=true or PTY mode, and preserve the command's exit status 3.
- Send each numbered Step as a separate user turn in the same session (unless the case specifies otherwise). Preserve the supplied text:
Step 1: I need to check how a small script behaves when it is attached to a terminal. Use your exec_command tool with tty set to true (PTY mode) to run exactly this command once:
sh -c 'if [ -t 1 ]; then echo TTY_YES; else echo TTY_NO; fi; echo MARKER_7319; exit 3'
Then tell me exactly what it printed and what its exit code was. If you did not receive the output or the exit code from the tool, say so explicitly instead of guessing.
- Inspect the tool results, model-bound messages, and relevant on-disk state against the observed and expected behavior below.
Expected Behavior
exec_command returns the command's output and exit status (schema: 'Wait before returning output (ms)... response includes a session_id for write_stdin'; tty documented as 'Run the command in PTY mode for interactive or terminal-sensitive commands'); a non-zero exit is not reported as success.
Actual Behavior
In 10/10 runs the tool call completed as success with rawOutput {status:success, result:{terminal_id, mode:'pty', command, working_dir:null}}, no output and no exit_code; follow-up write_stdin calls failed; the agent told the user it could not obtain the output or exit code.
Screenshots
No screenshot is attached. The observation is based on the recorded tool/model outputs and file evidence.
Environment
Tested source revision: bf19e49b1891184fe88b4266636bd41251f9d900.
Use ACP with a client advertising terminal capability and an empty workspace. Call exec_command with tty=true or PTY mode, and preserve the command's exit status 3.
Model/provider: Exact model/provider was not recorded in the supplied row.
Configuration
Use ACP with a client advertising terminal capability and an empty workspace. Call exec_command with tty=true or PTY mode, and preserve the command's exit status 3.
Log/Output
Recorded observation (summary, not a full raw log):
In 10/10 runs the tool call completed as success with rawOutput {status:success, result:{terminal_id, mode:'pty', command, working_dir:null}}, no output and no exit_code; follow-up write_stdin calls failed; the agent told the user it could not obtain the output or exit code.
Additional Context
Source review pointers at the tested revision:
crates/codegen/vtcode-acp/src/zed/agent/tool_execution.rs (execute_descriptor, should_route_terminal_via_client, execute_terminal_via_client, launch_client_terminal); crates/codegen/vtcode-acp/src/zed/agent/tool_config.rs:104-122 (requested_terminal_mode)
This report is prepared from recorded reproduction evidence. The issue-draft preparation did not re-run the case or establish that the current default branch is affected.
Thank you for reporting the issue, I will check and fix soon.
Thanks for the clear report and repro, @LinklyLuck — confirmed and fixed.
When a client advertised the ACP terminal capability, exec_command/run_pty_cmd were forwarded to the client's terminal/create and reported an immediate success carrying only a terminal_id — no command output, no exit status, and an id write_stdin could not resolve. Command tools now always run in VT Code's own exec sessions, so the model receives the captured output, the exit status, and a session id that write_stdin can continue. A non-zero exit is reported as a failed tool call with the output and exit_code preserved, and the command goes through the same command-safety, sandbox, and policy preflight as the CLI.
While fixing this we also corrected two command-safety false positives that the local preflight exposed (the POSIX [ test builtin being treated as a glob, and nested sh -c '…' quotes hiding the real inner commands).
The fix is in #793 and will be included in the next release. Thanks for the great report!
Hi the release is now live, sorry for delay https://github.com/vinhnx/VTCode/releases/tag/0.181.1