# Agent: Include partial output if terminal tool fails \(\#29115\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/68e0105627aa21679a7579e2c061a2f9bbd6b843)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 68e0105627aa21679a7579e2c061a2f9bbd6b843

Requested commit: 68e0105627aa21679a7579e2c061a2f9bbd6b843

Commit: 68e0105627aa21679a7579e2c061a2f9bbd6b843

Tree: 53d6927341a4ea5457cb606ebde4f9fc30570a5b

Author: Mani Rash Ahmadi

Committer: GitHub

## Message

```
Agent: Include partial output if terminal tool fails (#29115)

This PR addresses the behavior of the agent's terminal tool when the
executed command is interrupted or fails after producing some output.
Currently, if the command doesn't finish successfully, any partial
output captured before the interruption/failure is discarded, and only
an error message (or a generic cancellation message) is returned to the
LLM.

This change modifies the `run_command_limited` function in the terminal
tool to catch errors when awaiting the command's status (which includes
interruptions). In the case of such an error, it now includes any
partial stdout/stderr captured up to that point within the error message
returned to the `ToolUseState`. This ensures the LLM receives the
partial context even when the command doesn't complete cleanly, framed
appropriately as part of an error/interruption message.

Closes #29101

Release Notes:

- N/A
```

## Parents

- [e98e6c7426d8197a75177b45c34224aeb1dade5e](https://git.cafe/gitcafe/zed/commit/e98e6c7426d8197a75177b45c34224aeb1dade5e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/68e0105627aa21679a7579e2c061a2f9bbd6b843?format=markdown)
