haigou-web commented on PR #886:
URL: https://github.com/apache/burr/pull/886#issuecomment-6537334169
Confirmed on the CI point — here's the exact change, no other edits needed:
`.github/workflows/python-package.yml`, job `validate-examples`:
```diff
- name: Validate examples
working-directory: ./examples
- run: python -m pytest validate_examples.py
+ run: python -m pytest validate_examples.py
coding-agent/test_coding_agent.py
```
`working-directory: ./examples` is set on the step, so
`coding-agent/test_coding_agent.py` resolves relative to it and the
module-level sibling imports in the test (`import tools`, `from application
import ...`) keep working. I ran that combined command against `2b30eb27`: 58
passed.
While you're in `examples/coding-agent/tools.py`, two things from my comment
above are still present on this head and are cheap to fold into the same commit:
1. **`write_file` truncates before validating.** `open(full, "w")` runs
before `f.write(contents)`, so a non-str `contents` (list/dict from a small
local model) leaves the file **empty**, and the `TypeError` is not caught by
`except (ValueError, OSError)` — it escapes the tool and kills the run. Fix is
a three-line guard before the `try`, plus `encoding="utf-8"`:
```diff
+ if not isinstance(contents, str):
+ return {"error": f"contents must be a string, got
{type(contents).__name__}"}
try:
```
2. **`run_bash` timeout does not kill the command.** `subprocess.run(...,
shell=True, timeout=30)` kills `sh -c`, not the process it spawned; and after
`TimeoutExpired` it re-enters `communicate()` with no timeout, so with an
orphan holding the pipes the 30s budget is not actually enforced. Needs `Popen`
+ process-group kill (`os.killpg` on POSIX, `taskkill /T` on Windows). Full
patch and two regression tests are in my earlier comment.
Neither is affected by the `working-directory` change, so both can land in
the same commit as the workflow edit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]