fix(code_execution): recover from closed PTY sessions

Detect closed or exited local TTY sessions before writing, convert invalid PTY write errors into retryable session failures, and reset/retry the terminal session once after send/read failures.
This commit is contained in:
Agent Zero Local 2026-05-02 13:34:27 +00:00
parent 2ce1947b0f
commit a0f0c2e8d2
2 changed files with 16 additions and 7 deletions

View file

@ -194,12 +194,11 @@ class CodeExecution(Tool):
)
except Exception as e:
if i == 1:
PrintStyle.error(str(e))
await self.prepare_state(cfg, reset=True, session=session)
PrintStyle.error(str(e))
await self.prepare_state(cfg, reset=True, session=session)
if i == 0:
continue
else:
raise e
raise e
def format_command_for_output(self, command: str):
short_cmd = command[:250]