Implement Context Compaction
Memory & Context
90-120 minutes0/4 steps0%
Step 1 of 4
Add token accounting
You cannot manage what the loop does not measure.
First time here? Paste the Context Pack first so the AI understands your project - open it from the header above.
Prompt Capsule
Instrument the agent loop with context accounting. Requirements: before every model call, compute the token count of the assembled context (system prompt + history + reminders) using the model's tokenizer or a reliable estimator; log it per turn with a breakdown (system, history, tool results, reminders); expose current usage as a fraction of the model's window; add a warning log at 60% and a trigger event at the compaction threshold (default 75%, configurable). Verify by running a file-heavy session and watching the per-turn accounting climb in the logs.
Paste into EmergentFull Build: complete implementation prompt with explicit requirements
Quick is short. Full Build is recommended for most steps. Strict forces real logic when the AI keeps faking output.
Actual change check
Expected after this step
Per-turn context accounting with threshold events.
Should NOT happen
- An existing feature broke
- A button only logs to console
- Data disappears after refresh
- Errors fail silently with no visible state
This is what should exist before you continue. If reality does not match, do not move on.
Track what changed, failed, or needs follow-up. Notes export with the flow.
Pass the Verify Gate to complete this step