"""Invariant: terminal, execute_code, MCP and the bounded output collector truncate through one head/tail algorithm — 40% head / 60% tail, exactly one notice, kept text equal to the budget. """ import re import pytest from tools.tool_output_truncate import HEAD_RATIO, truncate_head_tail _NOTICE = re.compile(r"\n\n\.\.\. \[(?P