Repository navigation
Commit 1a47179
committed
fix(levelcode-ai): #107 review — a long command's result starts at its real start and counts what it left out
The bug: runCommand keeps only the last 262144 characters of a command's output in memory, and
commandResult then took its "start" from that buffer and counted the omitted characters against it.
Above 256 KiB the start the model saw came from the middle of the output, and the gap was a lie: a 2 MB
`cat` was reported as "[~254000 characters of output omitted]". The desktop and the browser shell share
this code, so both were affected.
The fix: runCommand also keeps the first 8000 characters of the output and counts every character it
was given. When the buffer has dropped the beginning, commandResult is handed that real start and the
true total, so the start shown is the start and kept + omitted is the whole output. Output up to 256 KiB
goes through exactly as before (nothing extra is passed).
Test: agentCommandResult.test.js "OUTPUT OVER 256 KiB: the start is the command's real start, and the
omitted count is everything that is not shown" drives the real runAgent -> run_command -> runCommand
chain with about 2.2 MB of output. It fails on the unfixed code (the result started at line 61809) and
passes now; the other agentCommandResult, agentRunCommand (untouched) and shellSeam tests still pass.1 parent 6820015 commit 1a47179
2 files changed
Lines changed: 43 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
425 | 425 | | |
426 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
427 | 430 | | |
428 | | - | |
| 431 | + | |
429 | 432 | | |
430 | | - | |
| 433 | + | |
| 434 | + | |
431 | 435 | | |
432 | | - | |
| 436 | + | |
433 | 437 | | |
434 | 438 | | |
435 | | - | |
| 439 | + | |
436 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
437 | 445 | | |
438 | 446 | | |
439 | 447 | | |
| |||
446 | 454 | | |
447 | 455 | | |
448 | 456 | | |
| 457 | + | |
449 | 458 | | |
450 | 459 | | |
451 | 460 | | |
452 | 461 | | |
453 | 462 | | |
454 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
455 | 466 | | |
456 | 467 | | |
457 | 468 | | |
| |||
481 | 492 | | |
482 | 493 | | |
483 | 494 | | |
484 | | - | |
| 495 | + | |
485 | 496 | | |
486 | 497 | | |
487 | 498 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
88 | 113 | | |
89 | 114 | | |
90 | 115 | | |
| |||
0 commit comments