Skip to content

Commit 3899432

Browse files
Update lambda_agent/tools.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent d1844aa commit 3899432

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

lambda_agent/tools.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,23 @@ def list_directory(path: str = ".", max_depth: int = 3, git_aware: bool = True)
125125
).strip()
126126
if tracked:
127127
lines = tracked.splitlines()
128+
# Enforce max_depth for git-aware output as well.
129+
normalized_root = os.path.normpath(path)
130+
filtered: list[str] = []
131+
for p in lines:
132+
rel = (
133+
os.path.relpath(p, normalized_root)
134+
if normalized_root not in (".", "")
135+
else p
136+
)
137+
depth = rel.count(os.sep) + 1
138+
if depth <= max_depth:
139+
filtered.append(p)
140+
lines = filtered
128141
if len(lines) > 300:
129142
return (
130143
"\n".join(lines[:300])
131-
+ f"\n\n... and {len(lines) - 300} more files."
144+
f"\n\n... and {len(lines) - 300} more files."
132145
)
133146
return "\n".join(lines)
134147
except Exception:

0 commit comments

Comments
 (0)