Feature Proposal: Agent Continuity - Persistent Agents Across Session Boundaries
Feature Proposal: Agent Continuity - Persistent Agents Across Session Boundaries
Summary
Proposal for a new feature enabling Claude Code agents to persist and resume across session boundaries. When a session ends unexpectedly (context limit, crash, user exit), agents can be resumed in a new session with full context restoration.
Problem Statement
Currently, when using parallel agents in Claude Code:
- Session Loss = Agent Loss - Agents exist only in session memory
- No Recovery Mechanism - When session ends, all context is lost
- Manual Reconstruction Required - Users must manually restart work
- Wasted Development Time - Significant work loss in multi-agent scenarios
Real-World Scenario
From a recent use case with 3 parallel agents:
- 3 agents spawned to work on different features in parallel
- Session ran out of context during development
- Compaction failed due to conversation size
- All agents became unreachable
- ~1,800 lines of work (540+670+470 lines) was lost
- No way to recover or resume
Proposed Solution
Agent Continuity - A comprehensive plugin + core infrastructure changes enabling:
- Automatic State Persistence - Agents save minimal context snapshots (~10 KB)
- Session Recovery - Full context injection when resuming
- Orphaned Agent Detection - Automatic notification of agents from previous sessions
- Intelligent Auto-Resume - Claude automatically detects and resumes previous work
- Agent Lifecycle Management - Automatic archival and cleanup
Key Innovation: Minimal Context Snapshots
Instead of saving massive transcripts (1-10 MB), save focused snapshots (< 10 KB):
- Current objective
- What's been completed
- Known blockers
- Next steps
- Key file references
This enables fast context injection without massive file I/O.
Implementation Plan
Phase 1: Plugin - Can start immediately
/resume-agentscommand- Auto-detect resume agent
- SessionStart/SubagentStop hooks
- State file management
Phase 2: Core Infrastructure - Blocking for full functionality
- Agent identity system (CLAUDE_AGENT_ID)
- Registry management API with file locking
- State writing API for agents
- Context injection mechanism
- New hook events (PreAgentResume, PostAgentResume, etc.)
- CLI commands for agent management
Phase 3: Integration & Testing
- Full flow testing
- Edge case handling
- Performance verification
Why Now?
- Multi-Agent Bottleneck - Parallel agents hit context limits frequently
- Developer Friction - Session loss is unpredictable and costly
- Feasible Architecture - Existing hook system provides foundation
- Clear Spec - Complete design already documented
Design Specification
Comprehensive design specification available in the public repository:
📍 https://github.com/richardwhiteii/agent-continuity**
The repository includes:
- Complete technical design
- Core infrastructure requirements with code examples
- Implementation guide with step-by-step instructions
- Real-world examples and data flow diagrams
- 30+ code examples
- Architecture documentation
- Executive summary for stakeholders
Key Design Documents
- TECHNICAL_DESIGN.md - Complete specification
- CORE_INFRASTRUCTURE.md - Core changes needed with code
- IMPLEMENTATION_GUIDE.md - Developer manual
- EXECUTIVE_SUMMARY.md - High-level overview
What This Enables
For Users
$ claude code
🔄 ORPHANED AGENTS DETECTED
Found 3 agents from previous session...
> /resume-agents agent_001 agent_002 agent_003
✓ All agents context loaded and injected
For Developers
- Longer running agent tasks without context anxiety
- Parallel agent workflows without fear of loss
- Better productivity in complex development scenarios
- Clear state management and observability
Questions for the Team
- Is this a priority feature for the roadmap?
- Which phase can we prioritize first?
- Would you like to discuss the architecture approach?
- Are there alternate approaches you'd prefer to evaluate?
- What resources are available for implementation?
Next Steps
- Review - Feedback on design and feasibility
- Discuss - Architecture decisions and trade-offs
- Plan - Schedule for plugin development
- Coordinate - Planning for core infrastructure
Related
- Design Repository: https://github.com/richardwhiteii/agent-continuity
- Problem Context: Multi-agent workflows and session resilience
- Component Impact: Agent lifecycle, session management, hooks system
---
Status: Design Complete | Awaiting Team Feedback
Design Quality: Production-ready specification with code examples
Community: Open for discussion and collaboration
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗