Session State Management
This skill provides the mechanism to persist your current working state to a file. This allows you to "reboot" from a seamless context state if the session window is reset.
1. The Session File
- •Path:
.agent/sessions/latest.yaml - •Purpose: Stores the exact arguments from your last
task_boundarycall, plus session metadata. - •Persistence: surviving session clears, allowing you to pick up exactly where you left off.
2. Boot Protocol (Start of Session)
IF .agent/sessions/latest.yaml exists AND you are starting a new session (blank context):
- •READ the file using
read_fileorview_file. - •RESTORE your state:
- •Set your internal
Modeto the file'smode. - •Set your
TaskNameandTaskStatusto the file'scurrent_task. - •Read the
context_summaryto understand what you were doing. - •Check
active_blockersto see if you were blocked.
- •Set your internal
3. Update Protocol (During Work)
WHENEVER you call the task_boundary tool, you MUST immediately follow it with a call to the update_state.py script.
Command Syntax
bash
python3 .agent/skills/skill-session-state/scripts/update_state.py \ --mode "[Mode]" \ --task "[TaskName]" \ --status "[TaskStatus]" \ --summary "[TaskSummary]" \ --predicted_steps [PredictedTaskSize]
Protocol Rules
- •Sync: The arguments passed to the script MUST match the arguments you just passed to
task_boundary. - •Atomic: Always call
task_boundaryfirst, thenupdate_state.py. - •No Hallucinations: Do not invent values. Use the exact ones from your current context.
4. Task Switching Logic
If you finish one task and start another in the same session:
- •Archive History: Ensure the old
docs/TASK.mdis archived (viaskill-archive-task). - •Update State: Call
task_boundarywith the NEW Task Name. - •Persist & Track:
- •Call
update_state.pywith the new task details. - •CRITICAL: Add the flag
--add_completed_task "[Old Task Name]"to preserve history. - •Example:
...scripts/update_state.py ... --add_completed_task "Optimizing Database" - •This ensures
latest.yamlshows: Current Task = UI Bug, Completed = [Database]
- •Call
5. Advanced Usage
Adding Decisions
If you make a critical decision (e.g., "Chose Redux over Context API"), you can append it to the session log:
bash
python3 ...scripts/update_state.py ... --add_decision "Chose Redux over Context API"
Managing Blockers
- •Add Blocker:
--add_blocker "Waiting for API key" - •Clear Blockers:
--clear_blockers(Use when unblocked)