Skip to content

fix: avoid bash commands that may not be installed - #196

Open
ruanzhengxin-zhuxing wants to merge 1 commit into
mainfrom
harness/641cc8f2
Open

fix: avoid bash commands that may not be installed#196
ruanzhengxin-zhuxing wants to merge 1 commit into
mainfrom
harness/641cc8f2

Conversation

@ruanzhengxin-zhuxing

Copy link
Copy Markdown
Collaborator

背景

Session 85d5c325f9fd442cbad185dc63e16578 中 bash 工具调用使用了运行环境未安装的 file 命令检查模板文件,返回 exit 127 /bin/sh: 1: file: not found,属工具选择错误。

根因

_build_tools_section 的 bash 使用指引只说明「用专用工具替代 cat/sed/grep」,没有约定「命令可能未安装」这类失败,模型排查文件可读性时选了不保证存在的 file

改动

src/iac_code/agent/system_prompt.py

  • 检查文件是否存在/可读时使用 ReadFile,或 ls -lstathead 等基础命令,不依赖可能未安装的 file
  • bash 命令返回 exit 127 / not found 时改用基础命令或专用工具,不重试同一条命令。

tests/agent/test_system_prompt.py:新增 TestBuildToolsSection 覆盖上述两条约定。

验证

  • tests/agenttests/tools/test_bash.pytests/tools/bashtests/pipeline/engine/test_step_executor.py:796 passed。
  • ruff check src/iac_code/agent/system_prompt.py tests/agent/test_system_prompt.py:通过。
  • tests/test_i18n.py 的 12 个失败在改动前后完全一致,属仓库既有问题,与本次改动无关。

Harness work item: 641cc8f2-df97-4427-819a-ea58414271f3

Agent runs picked `file` to inspect template readability and hit exit 127
`/bin/sh: 1: file: not found`. The bash tool guidance only covered using
dedicated tools over cat/sed/grep, with no rule about missing commands.

Tell the model to inspect file existence/readability with ReadFile or basic
commands (`ls -l`, `stat`, `head`), and to switch away from a command that
exits 127 instead of retrying it.
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.

1 participant