fix(mcp): cap codegraph_context output to prevent context bloat (#296)

Route handleContext's output through the shared truncateOutput cap
(MAX_OUTPUT_LENGTH) so codegraph_context can no longer blow past the context
budget — every sibling MCP tool already truncates; this was the one uncapped
output path.

Closes #296

Co-authored-by: Baijack-star <71923891+Baijack-star@users.noreply.github.com>
This commit is contained in:
Baijack-star
2026-05-22 13:20:08 -05:00
committed by GitHub
parent 7340892290
commit 23ad4ea923
2 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -775,11 +775,11 @@ export class ToolHandler {
// buildContext returns string when format is 'markdown'
if (typeof context === 'string') {
return this.textResult(context + reminder);
return this.textResult(this.truncateOutput(context + reminder));
}
// If it returns TaskContext, format it
return this.textResult(this.formatTaskContext(context) + reminder);
return this.textResult(this.truncateOutput(this.formatTaskContext(context) + reminder));
}
/**