DeepGandhi01 commented on PR #886:
URL: https://github.com/apache/burr/pull/886#issuecomment-5912830842

   Thanks for putting this together — the state-machine framing of the agent 
loop reads really well, and the scripted client makes it easy to try. I checked 
out this branch and ran it in a clean Python 3.14 venv built only from 
`examples/coding-agent/requirements.txt` (burr 0.42.0, openai 3.22.1), then 
probed the loop with `ScriptedClient` scripts. A few things came up that seem 
worth fixing before merge; each is reproducible with the scripted client and no 
API key.
   
   ### 1. Example fails to import from its own requirements
   `tools.py` imports `requests` (and `openai`, `inspect`, `json`, `typing`, 
and `burr.core`, plus `os` twice), none of which it uses. `requests` is not in 
`requirements.txt`, so in a clean environment:
   
   ```
   $ pip install -r requirements.txt && python application.py
     File ".../tools.py", line 25, in <module>
       import requests
   ModuleNotFoundError: No module named 'requests'
   ```
   
   Suggested fix: drop the unused imports from `tools.py` (it only needs `os` 
and `subprocess`). With `requests` installed manually, the scripted run 
completes, which confirms this is the only blocker.
   
   ### 2. `create_prompt` only runs once per task, not before each LLM call
   The README describes `create_prompt` as the seam "for shaping the prompt 
before each call", but the tool actions transition straight back to `call_llm`:
   
   ```python
   (["read_file", "write_file", "list_files", "run_bash"], "call_llm"),
   ```
   
   Observed trace for one tool call: `human_input → create_prompt → call_llm → 
list_files → call_llm → respond`. Anyone adding a file tree or history summary 
in `create_prompt` (the extension the README suggests) would only see it 
applied to the first call. Routing tool actions back to `create_prompt` fixes 
it:
   
   ```python
   (["read_file", "write_file", "list_files", "run_bash"], "create_prompt"),
   ```
   
   ### 3. An unknown tool name halts the run silently
   If the model requests a tool that isn't registered (common with real 
models), no transition out of `call_llm` matches, and 
`app.run(halt_after=["respond"])` stops at `call_llm` with `final_answer=None` 
and no error. Trace: `human_input → create_prompt → call_llm`. One option is to 
validate in `call_llm` and feed an error back as a `tool` message, or add a 
fallback transition such as `("call_llm", "respond", default)` after the tool 
transitions so the run always terminates in `respond`.
   
   ### 4. Tool errors crash the whole run instead of going back to the model
   `execute_tool` calls `tool_function(**state["next_args"])` directly, so:
   
   - Wrong argument names from the model (`{"filename": "x"}` for `read_file`) 
raise `TypeError: read_file() got an unexpected keyword argument 'filename'`.
   - `run_bash` before the workspace directory exists raises 
`FileNotFoundError` from `subprocess.run(cwd=...)` (only `TimeoutExpired` is 
caught). `./workspace` isn't created until the first `write_file`, so a model 
that starts with `run_bash` crashes on the first step.
   
   Since the example's point is that the agent "sees them fail, and tries 
again", catching exceptions in `execute_tool` and returning `{"error": ...}` as 
the tool message would make the loop self-correcting. Creating the workspace up 
front (`os.makedirs(WORKSPACE, exist_ok=True)`) fixes the second case directly.
   
   ### 5. Malformed tool-call JSON crashes `OpenAIClient`
   `json.loads(c.function.arguments)` raises `JSONDecodeError` on malformed 
arguments, which models occasionally produce. Worth catching and returning an 
error tool message, same as (4).
   
   ### 6. Minor: `_resolve` can be escaped via symlinks
   `_resolve` uses `os.path.abspath`, which doesn't resolve symlinks, so a 
symlink inside the workspace pointing outside it passes the check 
(`read_file("link/secret.txt")` returned a file from outside the workspace). 
The README is clear that this isn't a sandbox and `run_bash` can `cd` anywhere, 
so this is low severity, but `os.path.realpath` for both `root` and `full` 
would make `_resolve` do what its docstring says.
   
   ### 7. Nit
   Without the Graphviz binary, `app.visualize()` in `__main__` prints a 
`ModuleNotFoundError: No module named 'graphviz'` traceback before the run (it 
still completes). Wrapping it in a `try/except ImportError` or only visualizing 
on request would keep first-run output clean.
   
   Happy to help with any of these or open a follow-up PR against this branch 
if that's useful.
   


-- 
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]

Reply via email to