fix(agent): address code review findings for tool hint enhancement
- C1: Fix IndexError on empty list arguments via _get_args() helper - I1: Remove redundant branch in _fmt_known - I2: Export abbreviate_path from nanobot.utils.__init__ - I3: Fix _abbreviate_url negative-budget format consistency - S1: Move FORMATS to class-level _TOOL_HINT_FORMATS constant - S2: Add list_dir to FORMATS registry (ls path) - G1-G5: Add tests for empty list args, None args, URL edge cases, mixed folding groups, and list_dir format
This commit is contained in:
@@ -89,7 +89,8 @@ def _abbreviate_url(url: str, max_len: int = 40) -> str:
|
||||
|
||||
budget = max_len - len(domain) - len(basename) - 4 # "…/" + "/"
|
||||
if budget < 0:
|
||||
return domain + "/\u2026" + basename[: max_len - len(domain) - 4]
|
||||
trunc = max_len - len(domain) - 5 # "…/" + "/"
|
||||
return domain + "/\u2026/" + (basename[:trunc] if trunc > 0 else "")
|
||||
|
||||
# Build abbreviated path
|
||||
kept: list[str] = []
|
||||
|
||||
Reference in New Issue
Block a user