April 11, 2026

Two-Stage Mid-ACT Compaction Implemented

Two-stage mid-ACT compaction is now wired into MessageProcessor

Two-stage mid-ACT compaction is now wired into MessageProcessor.send() as the Context Compaction gate.

This gate triggers when the accumulated ACT trail exceeds 80% of the provider context window for self.JOB.

Stage 1 calls _run_stage1_tool_compaction(), using an LLM to summarize the act_trail with TOOL_COMPACTION_PROMPT. Raw tool DTOs are replaced with a single tool_compaction DTO.

Stage 2, _run_stage2_act_restart(), calls _run_full_compaction() to refresh the Checkpoint row, then collapses ephemeral=1 DTOs into a single act_restart DTO, resetting the ACT trail.

Stage 2 failure breaks the loop to prevent wasting budget on subsequent failed provider calls.

_run_full_compaction() enforces a 90% hard cap on compaction input, dropping the oldest rows while preserving the previous checkpoint.

Guards ensure that if no entries exist or all are dropped by the 90% cap, the LLM call is skipped.

New tests cover threshold measurements, Stage 1/2 logic, and send() integration across various scenarios.

  • Implements two-stage mid-ACT compaction in MessageProcessor.send().

  • Stage 1 LLM summarises act_trail and replaces raw tool DTOs with tool_compaction DTO.

  • Stage 2 collapses ephemeral=1 DTOs into act_restart DTO after calling _run_full_compaction().

  • _run_full_compaction() enforces a 90% hard cap on compaction input, dropping oldest rows.

  • Tests added cover boundary semantics, Stage 1/2 logic, and send() integration.

  • Guards skip LLM calls if no entries exist or if all entries are dropped by the 90% cap.