From e72246e0df544b406fcdab4a2ad1f2a7c994be7d Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Wed, 8 May 2024 16:30:00 +0800 Subject: [PATCH] add comment for terminal tool output parser --- metagpt/tools/libs/terminal.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/metagpt/tools/libs/terminal.py b/metagpt/tools/libs/terminal.py index 85aacbef8..68bd95901 100644 --- a/metagpt/tools/libs/terminal.py +++ b/metagpt/tools/libs/terminal.py @@ -95,9 +95,10 @@ class Terminal: with self.observer as observer: cmd_output = [] observer.report(cmd + self.command_terminator, "cmd") - # report the command - - # Read the output until the unique marker is found + # report the comman + # Read the output until the unique marker is found. + # We read bytes directly from stdout instead of text because when reading text, + # '\r' is changed to '\n', resulting in excessive output. tmp = b"" while True: output = tmp + self.process.stdout.read(1)