Repository navigation
Commit 9140ea0
authored
fix(agent-core-v2): cap Read at about 25k tokens and trim file tool results (#4553)
* fix(agent-core-v2): cap Read at about 25k tokens and trim file tool results
- Cap the max_chars a Read call can request at 100k characters (was
500k) and drop the description sentence that told the model to request
a larger budget for whole large files; the event log note now points
to Next Read instead of a larger max_chars.
- Stop a page at about max_chars / 4 estimated tokens. The limit is
applied while the page is assembled: drop whole lines, or cut a single
long line by token weight, without re-reading the file. It rounds up,
so pages of ASCII text never reach it and keep their exact character
pagination. A tail read whose last line cannot fit returns the bounded
forward recovery.
- Omit the Read status block when a call returns the whole file with
nothing to report.
- On an incomplete page, point to Grep for a specific section instead of
answering from that page alone.
- After a successful Edit or Write, tell the model it does not need to
Read the file back.
* fix(agent-core-v2): reject named Read ranges that exceed the token limit
When a call names a range, with n_lines or a negative line_offset, and
those lines exceed the estimated token limit, return an error that says
how many lines fit and suggests the exact arguments, instead of a page
that silently covers only part of the range. Whole-file reads, reads
from an offset to the end, single-line requests, and column
continuations still page with Next Read.
* fix(agent-core-v2): keep character paging for named Read ranges
The named-range check ran before character trimming, so an ASCII range
longer than max_chars, whose status block pushed the page over both
limits, returned a range error instead of a page with Next Read. Run the
check only once the page fits max_chars, so it rejects a range only when
the token limit would cut it shorter than the character limit does.
* test(kap-server): raise max_chars in the paginated attachment read test
Every incomplete Read page now carries one more status sentence, so with
a 500-character budget and a long attachment path the status took about
490 characters and the read could not finish within the test's 80 pages.1 parent dbb65af commit 9140ea0
14 files changed
Lines changed: 322 additions & 76 deletions
File tree
- .changeset
- docs
- en
- configuration
- reference
- zh
- configuration
- reference
- packages
- agent-core-v2
- src
- agent/tools
- edit
- os
- read
- write
- llm-adapter/contract
- test
- agent/toolExecutor
- os/backends/node-local/tools
- kap-server/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
460 | | - | |
| 460 | + | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
| 463 | + | |
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
454 | | - | |
| 454 | + | |
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
| 462 | + | |
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments