💡 English is recommended so global developers can help. 推荐使用英文提交,谢谢 ❤️
Environment
Version: current master (commit 08f64f7)
OS: any — platform-independent
Python: 3.11 / 3.13 (CI matrix)
Install: any
Channel: any (ls is a built-in tool, reachable from every channel)
What happened?
The ls tool reports a non-empty directory as (empty directory) when the model passes a limit of 0 or a negative number. It also fails with a raw TypeError when limit is not a number.
limit is read straight out of the tool arguments and used in the loop guard:
limit = args.get("limit", DEFAULT_LIMIT)
...
for entry in entries:
if len(results) >= limit:
entry_limit_reached = True
break
With limit=0 the guard is already true for the first entry, so the loop breaks with nothing collected. The if not results: branch that follows cannot tell that apart from a genuinely empty directory, and answers (empty directory) — and returns status=success, so nothing looks wrong.
This matters more than a cosmetic slip: the model is told the directory is empty and will conclude the files are not there, then move on or ask the user to check their path. The entry_limit_reached notice is swallowed too, so there is no hint that anything was truncated.
Steps to reproduce
Directory containing alpha.txt, beta.txt, gamma.md:
>>> from agent.tools.ls.ls import Ls
>>> Ls().execute({"path": d, "limit": 0}).result
{'message': '(empty directory)', 'entries': []}
>>> Ls().execute({"path": d, "limit": -1}).result
{'message': '(empty directory)', 'entries': []}
>>> Ls().execute({"path": d, "limit": "10"}).result
"Error listing directory: '>=' not supported between instances of 'int' and 'str'"
>>> Ls().execute({"path": d, "limit": None}).result
"Error listing directory: '>=' not supported between instances of 'int' and 'NoneType'"
>>> Ls().execute({"path": d, "limit": 1.5}).result
{'output': 'alpha.txt\n\n[1.5 entries limit reached. Use limit=3.0 for more]', 'entry_count': 2, ...}
Expected: limit=0 / negative still list something and say the limit was reached; a non-numeric limit falls back to the default (or is rejected with a clear message) instead of raising TypeError.
Actual: as above — an empty directory is reported for a full one, and non-numeric values produce an internal error message rather than a listing.
Why this happens
limit is declared as an integer in the tool's JSON schema, but the schema is a hint to the model, not an enforcement boundary — the value is model output, and null, "20" and 1.5 all show up in practice. The tool never coerces or validates it before using it in a numeric comparison.
Note the last case: limit=1.5 does not raise, it silently truncates to a 2-entry listing and then reports the raw fraction back in the notice ("Use limit=3.0 for more"), which is not a value the model can meaningfully use.
Logs
Not applicable — reproducible directly through Ls().execute(...) as shown above; the empty-directory case returns status=success with no log line.
Environment
Version: current
master(commit08f64f7)OS: any — platform-independent
Python: 3.11 / 3.13 (CI matrix)
Install: any
Channel: any (
lsis a built-in tool, reachable from every channel)What happened?
The
lstool reports a non-empty directory as(empty directory)when the model passes alimitof0or a negative number. It also fails with a rawTypeErrorwhenlimitis not a number.limitis read straight out of the tool arguments and used in the loop guard:With
limit=0the guard is already true for the first entry, so the loop breaks with nothing collected. Theif not results:branch that follows cannot tell that apart from a genuinely empty directory, and answers(empty directory)— and returnsstatus=success, so nothing looks wrong.This matters more than a cosmetic slip: the model is told the directory is empty and will conclude the files are not there, then move on or ask the user to check their path. The
entry_limit_reachednotice is swallowed too, so there is no hint that anything was truncated.Steps to reproduce
Directory containing
alpha.txt,beta.txt,gamma.md:Expected:
limit=0/ negative still list something and say the limit was reached; a non-numericlimitfalls back to the default (or is rejected with a clear message) instead of raisingTypeError.Actual: as above — an empty directory is reported for a full one, and non-numeric values produce an internal error message rather than a listing.
Why this happens
limitis declared as anintegerin the tool's JSON schema, but the schema is a hint to the model, not an enforcement boundary — the value is model output, andnull,"20"and1.5all show up in practice. The tool never coerces or validates it before using it in a numeric comparison.Note the last case:
limit=1.5does not raise, it silently truncates to a 2-entry listing and then reports the raw fraction back in the notice ("Use limit=3.0 for more"), which is not a value the model can meaningfully use.Logs
Not applicable — reproducible directly through
Ls().execute(...)as shown above; the empty-directory case returnsstatus=successwith no log line.