promptdojo_
Checkpoint

One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.

Final context-engineering drill. Write manage_session(items, budget, threshold_pct) that combines budget-planning with a compaction trigger.

Returns a dict with FOUR fields:

  • loaded: list of item names that fit in the budget (priority-desc, then name-asc; greedy fill)
  • offloaded: list of item names that didn't fit (same sort order)
  • load_pct: int 0-100, percentage of budget used (rounded to nearest, round(100 * used / budget))
  • compact_targets: list of up to TWO item names — the LOWEST priority items currently in loaded. Only populated if load_pct > threshold_pct; otherwise empty list. Order: priority ascending, then name ascending.

Five items, 4000-token budget, 75% threshold. Expected output:

loaded: ['claude_md', 'current_task', 'recent_tool_results', 'session_history']
offloaded: ['deploy_skill']
load_pct: 92
compact_targets: ['session_history', 'recent_tool_results']

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.