NumPy allowed · plain Python earns 10 bonus points
Implement tool-output truncation with a clear indicator, protecting an agent's context window from being consumed by one oversized tool result.
Implement truncate_tool_output(output, max_chars). If len(output) <= max_chars, return it unchanged. Otherwise return the first max_chars characters followed by the literal string '... [truncated N more chars]' where N is the number of characters that were cut.
truncate_tool_output(output: str, max_chars: int) -> str