docs: tool system performance audit for long-session regressions - #7695
docs: tool system performance audit for long-session regressions#7695kilo-code-bot[bot] wants to merge 1 commit into
Conversation
Research recent changes (Feb 26 - Mar 26, 2026) to tool definitions, system prompts, and agent metadata that could cause performance regressions in long-running sessions by increasing token count. Key findings: - New codebase_search tool (+350 tokens when experimental flag on) - environment_details injection on every request (+15-250 tokens) - Config paths added to system prompt (+35 tokens) - PlanExitTool always registered (filtered by agent permissions) - Session diff memory leak fix (PR #7617) addresses major long-session issue
| 1. A new `codebase_search` tool was added (PR #6685), adding ~974 bytes to tool definitions when enabled via experimental flag. | ||
| 2. The `environment_details` system was introduced (PR #6225), injecting per-message dynamic context into user messages — a net token increase but only on the last user message. | ||
| 3. Config location awareness was added to the system prompt (PR #7444), adding ~2 lines to every `<env>` block. | ||
| 4. `PlanExitTool` is now always registered in the tool registry instead of being feature-flag-gated, adding its description (~614 bytes) to every session. |
There was a problem hiding this comment.
WARNING: Executive summary overstates the PlanExitTool token impact
The detailed analysis later in this document correctly notes that resolveTools() filters plan_exit out for agents that do not allow it, so its description is not added to most LLM requests. Saying it is added "to every session" contradicts that conclusion and overstates the reported regression risk.
| 4. `PlanExitTool` is now always registered in the tool registry instead of being feature-flag-gated, adding its description (~614 bytes) to every session. | |
| 4. `PlanExitTool` is now always registered in the tool registry instead of being feature-flag-gated, but agent permission filtering keeps its description out of most sessions. |
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments: None. Files Reviewed (1 files)
Reviewed by gpt-5.4-20260305 · 293,893 tokens |
|
This writes to docs/ at the repo root, but we don't have a top level docs/ tree here. Looks like a one off research note that wasn't going to any published docs surface, closing it out. |
Summary
Key Findings
codebase_searchtoolenvironment_detailsinjectionPlanExitToolalways registeredTypical case (default settings, CLI): +~50 tokens per request
Worst case (all features enabled, VS Code with many tabs): +~635 tokens per request
Recommendations
environment_detailsto limit token growthbash.txt(9.6 KB) andtodowrite.txt(8.8 KB) are the largest tool descriptions — prime targets for compression if token budget is a concern