Repository navigation
Commit d5fb009
committed
fix: share one bounded reader between read_file and grep_file
grep_file's scanner set a 1MB line buffer; ReadFileContent kept bufio's
64KB default. A file with one longer line -- a minified bundle, a
single-line JSON blob -- therefore failed read_file outright, losing every
other line in the file, while grep_file handled the same file fine and
read_file's own tool description promises such lines are truncated.
Python truncated correctly throughout, so this was a Go-only regression
introduced alongside grep_file.
Extract scanFileLines as the single reader behind both. It owns the
non-regular-file rejection (previously duplicated), the buffer cap, and
error wrapping, so the two paths can no longer drift on any of the three.
Lines past maxLineBytes still error rather than truncate: uncapping would
mean buffering an arbitrarily long line in a sandbox reading untrusted
files.
Also in this change:
- Wrap ListDirContent's os.ReadDir error, the last bare return beside a
wrapped one.
- Correct file_search_tools_enabled()'s docstring, which still claimed
list_files/grep_file are "disabled by default, same as bash". Bash's
gate was removed upstream in #2498; this was the last of six such sites.
- Drop the _validate_path call in grep_content's entry loop. The
search-root bound added beside it is strictly narrower, and
file_or_dir_path is already validated against allowed_root, so the
wider check is dead.
- Give Python the _MAX_LINE_CHARS/_truncate_line pair Go already had,
replacing four repetitions of the literal 2000.
- Express the three path resolvers as pathPolicy values. allowSkillsRoot
had been picking the denial message as a side effect, which would
misdescribe any future resolver that denied the skills root for a
reason other than writability.
- Fold TestResolveReadPath_AllowsSymlinkedSkillsDirectory and
TestResolveWritePath_BlocksSkillsSymlink into TestResolvePathContainment,
which already covered both cells of that matrix.
- Correct the grep_file call site's no-timeout rationale, which cited
RE2's linearity -- an answer about the match, not the walk that
GrepContent's own doc comment identifies as the unbounded part.
Signed-off-by: brandonkeung <[email protected]>1 parent 07e4d62 commit d5fb009
6 files changed
Lines changed: 424 additions & 170 deletions
File tree
- go/adk/pkg/tools
- python/packages/kagent-skills/src/kagent
- skills
- tests/unittests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
23 | 70 | | |
24 | 71 | | |
25 | 72 | | |
| |||
82 | 129 | | |
83 | 130 | | |
84 | 131 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | 132 | | |
103 | | - | |
104 | | - | |
105 | 133 | | |
106 | 134 | | |
107 | 135 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
116 | 139 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
121 | 145 | | |
122 | 146 | | |
123 | 147 | | |
| |||
183 | 207 | | |
184 | 208 | | |
185 | 209 | | |
186 | | - | |
| 210 | + | |
187 | 211 | | |
188 | 212 | | |
189 | 213 | | |
| |||
302 | 326 | | |
303 | 327 | | |
304 | 328 | | |
305 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
306 | 336 | | |
307 | 337 | | |
308 | 338 | | |
| |||
320 | 350 | | |
321 | 351 | | |
322 | 352 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
| 353 | + | |
| 354 | + | |
334 | 355 | | |
335 | 356 | | |
336 | | - | |
337 | | - | |
338 | | - | |
| 357 | + | |
| 358 | + | |
339 | 359 | | |
340 | 360 | | |
341 | 361 | | |
| |||
355 | 375 | | |
356 | 376 | | |
357 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
358 | 383 | | |
359 | 384 | | |
360 | 385 | | |
| |||
385 | 410 | | |
386 | 411 | | |
387 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
388 | 416 | | |
389 | 417 | | |
390 | 418 | | |
| |||
0 commit comments