Build a Typed Context Compaction Gate for AI Agents