trw_pre_compact_checkpoint
Prevent workflow disruption by capturing a safety checkpoint before context compaction. Supply directive and context anchor to resume exactly where you left off.
Instructions
Capture a safety checkpoint before the context window compacts.
Use when:
Invoked by the PreCompact hook on imminent context compaction.
You suspect compaction is near and want a clean resume point on disk.
PRD-CORE-165 FR-01: pass directive (the active operator directive /
task you are mid-flight on) and context_anchor (where you are in it —
e.g. the in-flight experiment or handoff pointer). These live in the
conversation, not in trw state, so they cannot be auto-derived; when
supplied they are persisted into the pre-compact state and surfaced on the
next trw_session_start so the post-compaction session resumes exactly
instead of re-orienting by hand. Both are optional and backward-compatible.
Best-effort: sub-step failures populate status but do not raise.
Output: PreCompactResultDict with fields {status: "written"|"skipped"|"error", reason?: str, checkpoint_path?: str, instructions_path?: str, compact_state_path?: str, directive?: str, context_anchor?: str}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directive | No | ||
| context_anchor | No |