Skip to content

Conversation

@nforro
Copy link
Member

@nforro nforro commented Nov 13, 2025

No description provided.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces functionality to ellipsize long outputs from shell commands, which is a valuable addition for managing verbose command outputs. The implementation correctly handles the full_output flag and truncates stdout and stderr when full_output is False. A new test case has been added to cover this new functionality, which is good. The logic for calculating the number of lines to keep from the beginning and end of the output is sound.

@nforro
Copy link
Member Author

nforro commented Nov 13, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces a valuable feature to ellipsize long command outputs, improving readability and preventing excessive log sizes. The implementation correctly handles full output and truncated output, including the insertion of an ellipsis. The new test case test_run_shell_command_huge_output effectively validates this new functionality, covering both scenarios. Overall, the changes are well-implemented and tested.

Comment on lines +64 to +76
def ellipsize(output):
if output is None:
return None
if tool_input.full_output:
return output
lines = output.splitlines(keepends=True)
if len(lines) <= ELLIPSIZED_LINES:
return output
return "".join(
lines[: math.floor((ELLIPSIZED_LINES - 1) / 2)]
+ ["[...]\n"]
+ lines[-math.ceil((ELLIPSIZED_LINES - 1) / 2) :]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ellipsize function is currently defined as a nested function within _run. While functional, defining it as a private method (e.g., _ellipsize) of the RunShellCommandTool class would improve code organization and avoid recreating the function object on every call to _run. This enhances maintainability and makes the helper function more explicitly part of the class's behavior.

        def _ellipsize(output: str | None, full_output_flag: bool) -> str | None:
            if output is None:
                return None
            if full_output_flag:
                return output
            lines = output.splitlines(keepends=True)
            if len(lines) <= ELLIPSIZED_LINES:
                return output
            return "".join(
                lines[: math.floor((ELLIPSIZED_LINES - 1) / 2)]
                + ["[...]
"]
                + lines[-math.ceil((ELLIPSIZED_LINES - 1) / 2) :]
            )

        result = {
            "exit_code": exit_code,
            "stdout": _ellipsize(stdout, tool_input.full_output),
            "stderr": _ellipsize(stderr, tool_input.full_output),
        }

Copy link
Member

@lbarcziova lbarcziova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@nforro nforro merged commit 74a6f99 into packit:main Nov 13, 2025
7 checks passed
@nforro nforro deleted the commands branch November 13, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants