MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / TruncateResult

Function TruncateResult

agent/compact.go:7–19  ·  view source on GitHub ↗
(content string, maxChars ...int)

Source from the content-addressed store, hash-verified

5const maxCompactChars = 50_000
6
7func TruncateResult(content string, maxChars ...int) string {
8 limit := maxCompactChars
9 if len(maxChars) > 0 {
10 limit = maxChars[0]
11 }
12 runes := []rune(content)
13 if len(runes) <= limit {
14 return content
15 }
16 half := floorDiv(limit, 2)
17 removed := len(runes) - limit
18 return string(runes[:pythonSliceEnd(len(runes), half)]) + "\n\n... [" + strconv.Itoa(removed) + " characters truncated] ...\n\n" + string(runes[pythonSliceStart(len(runes), -half):])
19}
20
21func floorDiv(value, divisor int) int {
22 result := value / divisor

Calls 3

floorDivFunction · 0.85
pythonSliceEndFunction · 0.70
pythonSliceStartFunction · 0.70