VI. Resume Work
Work should survive context limits. Bundle state, restore seamlessly.
The Problem
Without Session Continuity
Context limits break work:
- Context resets mid-task
- Work lost without trace
- Start over repeatedly
- Can't handle complex projects
- No memory between sessions
With Session Continuity
Bundles preserve everything:
- Compress state to 5-10% size
- Resume exactly where you left
- Multi-day projects enabled
- Complex work becomes possible
- Knowledge compounds across sessions
The Solution
Lost Context
Session 1:
- Research complete (2 hours)
- Context hits limit
- All work gone
Session 2:
- Start research from scratch
- Rediscover same things
- Context hits limit again
Result: Groundhog Day
Context Bundles
Session 1:
- Research complete (2 hours)
- Save as bundle (5% size)
Session 2:
- Load bundle (5 seconds)
- Continue from where you left
- Build on previous work
Result: Continuous progress
How Bundles Work
Research Bundle
Findings compressed
Key insights only
Plan Bundle
Decisions captured
Ready to implement
Progress Bundle
Work status
Next steps defined
Context Bundle
Full session state
Restore anywhere
Why It Works
::: info Compression Enables Continuity The math:
- Full session context: 100%
- Bundle compression: 5-10%
- Compression ratio: 10:1 to 20:1
What this enables:
- Multi-day projects (previously impossible)
- Complex research spanning sessions
- Knowledge that compounds over time :::
Real-World Evidence
| Metric | Without Bundles | With Bundles |
|---|---|---|
| Multi-day work | Impossible | 45 sessions completed |
| Context recovery | Start from scratch | 5 seconds to restore |
| Work continuity | Lost at limit | 100% preserved |
| Complex projects | Broken | Enabled |
Bundle Structure
::: code-group
# Research Bundle: Authentication Redesign
## Summary
JWT with refresh token rotation selected.
Current sessions expire too quickly.
## Key Findings
1. Current auth: Session-based, 30-minute timeout
2. User feedback: "Constantly logging back in"
3. Industry standard: JWT + refresh tokens
4. Security requirement: Token rotation
## Decision
Implement JWT with 15-minute access tokens
and 7-day refresh tokens with rotation.
## Files Identified
- src/auth/middleware.ts (main changes)
- src/auth/routes.ts (new endpoints)
- src/types/auth.ts (new types)
## Next Steps
1. Design token structure
2. Plan migration strategy
3. Implement refresh endpoint
# Plan Bundle: JWT Implementation
## Approved Approach
JWT with refresh token rotation
## Implementation Steps
1. [ ] Add JWT dependencies
2. [ ] Create token service
3. [ ] Update auth middleware
4. [ ] Add refresh endpoint
5. [ ] Migrate existing sessions
## Files to Modify
| File | Change |
|------|--------|
| auth/middleware.ts | JWT validation |
| auth/routes.ts | /refresh endpoint |
| types/auth.ts | Token types |
## Risk Assessment
- Medium risk: Production auth system
- Mitigation: Feature flag for rollback
## Session Resume Point
Ready to start Step 1: Add dependencies
# Progress Bundle: JWT Implementation
## Status
3 of 5 steps complete
## Completed
- [x] Add JWT dependencies
- [x] Create token service
- [x] Update auth middleware
## In Progress
- [ ] Add refresh endpoint (50% done)
## Remaining
- [ ] Migrate existing sessions
## Current State
- Working on: src/auth/routes.ts
- Last change: Added token rotation logic
- Next action: Complete refresh error handling
## Resume Instructions
Open src/auth/routes.ts at line 145
Continue implementing refreshToken function
:::
Implementation
Save Bundle
class BundleManager:
def save_bundle(self, session_state):
# 1. Extract key information
summary = self.summarize(session_state.findings)
decisions = self.extract_decisions(session_state.log)
next_steps = self.identify_next_steps(session_state.plan)
# 2. Compress to bundle format
bundle = {
'type': session_state.phase,
'summary': summary, # 10% of original
'decisions': decisions, # Key choices only
'next_steps': next_steps, # Clear resume point
'files': session_state.files, # Relevant paths
'timestamp': datetime.now()
}
# 3. Save to bundle storage
bundle_path = f".agents/bundles/{session_state.task_id}.md"
self.write_bundle(bundle_path, bundle)
return bundle_path
Load Bundle
def load_bundle(self, task_id):
bundle_path = f".agents/bundles/{task_id}.md"
if not exists(bundle_path):
return None
bundle = self.read_bundle(bundle_path)
# Restore context from bundle
return {
'summary': bundle['summary'],
'decisions': bundle['decisions'],
'next_steps': bundle['next_steps'],
'files': bundle['files'],
'resume_point': bundle['next_steps'][0]
}
Bundle Lifecycle
1. Create
End of session
Compress state
2. Store
Git-tracked
Versioned
3. Load
New session
Restore context
4. Update
Progress made
Re-compress
Implementation Checklist
- Bundle format defined (markdown recommended)
- Save bundles at natural breakpoints
- Load bundles at session start
- Track bundles in git (versioned)
- Clean up old bundles (retention policy)
Anti-Patterns
The "Start Fresh" Trap
Wrong: Each session starts from scratch
Right: Load bundle, continue where you left off
The "Save Everything" Trap
Wrong: Bundle contains full session (100%)
Right: Bundle contains compressed essentials (5-10%)
The "Manual Memory" Trap
Wrong: Rely on user to remember context
Right: Automated bundle save/load
The "Single Bundle" Trap
Wrong: One bundle for all work
Right: Bundle per phase (research, plan, implement)
Related Factors
| Factor | Relationship |
|---|---|
| I. Automated Tracking | Bundles stored in git |
| II. Context Loading | Bundles enable JIT loading |
| V. Measure Everything | Track bundle effectiveness |
| VIII. Human Validation | Natural gate boundaries |