(content string, absoluteMax int)
| 50 | return fmt.Sprintf( |
| 51 | "<persisted-output>\nOutput too large (%s). Full output saved to: %s\n\nPreview (first %d characters):\n%s\n</persisted-output>", |
| 52 | sizeLabel, |
| 53 | filePath, |
| 54 | previewCount, |
| 55 | preview, |
| 56 | ), nil |
| 57 | } |
| 58 | |
| 59 | func ClampToAbsoluteMax(content string, absoluteMax int) string { |
| 60 | if charLen(content) <= absoluteMax { |
| 61 | return content |
| 62 | } |
| 63 | |
| 64 | half := absoluteMax / 2 |
| 65 | head := firstChars(content, half) |
| 66 | tail := lastChars(content, half) |
| 67 | if absoluteMax == 0 { |
| 68 | tail = content |
| 69 | } |
| 70 | removed := charLen(content) - absoluteMax |
| 71 | return fmt.Sprintf( |
| 72 | "%s\n\n[OUTPUT TRUNCATED: %s, %d characters removed — exceeds absolute limit of %s]\n\n%s", |
| 73 | head, |
| 74 | formatSize(len([]byte(content))), |
| 75 | removed, |
no test coverage detected