Output truncation
Running go test ./... on a large repo can emit megabytes of output. Feeding that straight back to the model is how you accidentally spend real money. Truncation is a boring but essential guard.
const maxOut = 8 * 1024 // 8KB
func truncateOutput(s string) string {
if len(s) <= maxOut {
return s
}
head := s[:maxOut/2]
tail := s[len(s)-maxOut/2:]
return head + "\n...[truncated]...\n" + tail
}Head and tail truncation. The model usually needs the first few lines to see what the command was and the last few lines to see the failure. Middle chatter is safe to drop.
Ordering exercise: Order the shell tool pipeline
Loading practice…