Release Notes: v1.12.0 - Checkpoint System & Usage Tracking¶
Release Date: 2025-12-29
Type: Major Feature Release
Branch: feature/agent-multi-file-atomic-edit โ master
๐ฏ Overview¶
ppxai v1.12.0 introduces a checkpoint system for atomic multi-file rollback and real-time token usage tracking with cost estimation.
Checkpoint System: - โ Safe Experimentation - Try agent tasks risk-free, undo with one command - โ Git Integration - Uses native git commits for version-controlled projects - โ Zero Configuration - Works out of the box with sensible defaults - โ Fallback Support - File snapshots when git is not available
Usage Tracking: - โ Real-time Tokens - See prompt/completion tokens in status line - โ Cost Estimation - Automatic USD cost calculation per model - โ VSCode Integration - Usage badge with live updates - โ All Providers - Works with streaming responses (OpenAI, Perplexity, Gemini)
๐ New Features¶
1. Checkpoint System¶
Git Backend (Preferred)
- Auto-commits changes before agent tasks: git commit -m "ppxai checkpoint: <task>"
- Atomic rollback with: git revert HEAD --no-edit
- Fully compatible with standard git workflow
- No storage overhead, commits visible in git history
File Backend (Fallback)
- Snapshots files to ~/.ppxai/checkpoints/{session_id}/
- Works without git repository
- Preserves directory structure
- Auto-cleanup keeps last 10 checkpoints
Auto-Detection
- Automatically selects best backend (git โ file โ none)
- Configurable via tools.agent.checkpoint_backend in ppxai-config.json
- Options: "auto" (default), "git", "file", "none"
2. New Commands¶
/undo - Revert Last Agent Task
You: /undo
โ ๏ธ Undo Last Agent Task
Backend: git
Checkpoint: abc123de
Confirm undo? (y/n): y
โ Changes reverted using git revert (checkpoint: abc123de)
Reverts all changes from the last /agent task atomically.
Enhanced /agent Command
- Automatic checkpoint creation before task execution
- Notifications show checkpoint ID and backend
- Warning if checkpoints disabled
You: /agent refactor auth module to use JWT
๐ Agent Mode enabled with Git checkpoints
โข Changes will be auto-committed before each task
โข Use /undo to revert the last agent task atomically
โ Checkpoint created: f3a7b2c1 (refactor auth module)
๐ค Starting autonomous agent...
3. Enhanced Status Line (TUI)¶
New Checkpoint Status Indicators
[Perplexity | sonar-pro | Tools: ON | Agent: ON | Checkpoints: git]
[Perplexity | sonar-pro | Tools: ON | Agent: ON | Checkpoints: file]
[Perplexity | sonar-pro | Tools: ON | Agent: ON | Checkpoints: OFF]
Color Coding:
- Checkpoints: git - Green (git backend active)
- Checkpoints: file - Yellow (file backend active)
- Checkpoints: OFF - Red (checkpoints disabled, warning)
4. Event-Based Notifications¶
New EventType.STATUS
- Checkpoint created: โ Checkpoint created: abc123de (task description)
- Undo success: โ Changes reverted using git revert (checkpoint: abc123de)
- Notifications shown in both TUI and VSCode (via SSE)
5. Configuration¶
New Agent Configuration Options (ppxai-config.json):
{
"tools": {
"agent": {
"checkpoint_backend": "auto",
"checkpoint_message": "ppxai checkpoint: {task}",
"max_iterations": 10,
"context_char_limit": 2000,
"min_task_words": 3
}
}
}
Checkpoint Backend Options:
- "auto" - Auto-detect (git if available, else file)
- "git" - Git-only (disable if no git repo)
- "file" - Force file backend
- "none" - Disable checkpoints
6. HTTP API Endpoints (VSCode Extension)¶
Enhanced /agent/status
{
"agent_mode": true,
"tools_enabled": true,
"checkpoint": {
"enabled": true,
"backend": "git",
"last_checkpoint": "f3a7b2c1abc...",
"status_description": "Checkpoints: git (atomic)"
}
}
New /checkpoint/status
{
"enabled": true,
"backend": "git",
"last_checkpoint": "f3a7b2c1abc...",
"status_description": "Checkpoints: git (atomic)"
}
New /checkpoint/undo
7. Real-Time Token Usage & Cost Tracking¶
Streaming Usage Extraction
- Both OpenAI-compatible and Perplexity providers now extract token counts from streaming responses
- Uses stream_options={"include_usage": True} parameter for accurate token counts
- Works with all streaming requests (the default mode)
Cost Calculation - Automatic USD cost estimation based on per-model pricing in config - Pricing data for all built-in providers (Perplexity, Gemini) - Configurable pricing for custom providers
TUI Status Line
-1.2Kโ - Prompt tokens (input)
- 0.5Kโ - Completion tokens (output)
- $0.0045 - Estimated cost for session
VSCode Extension - Usage badge in header with live updates after each response - Tooltip shows total tokens and cost details - Green color when cost > $0
/usage Command
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Current Session Usage โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโค
โ Metric โ Value โ
โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโค
โ Total Tokens โ 1,750 โ
โ Prompt Tokens โ 1,200 โ
โ Completion Tokens โ 550 โ
โ Estimated Cost โ $0.0045 โ
โโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโ
HTTP Endpoint: /usage
8. Documentation¶
New User Guides: - docs/CHECKPOINT_GUIDE.md - Comprehensive 550+ line user guide - Quick start and configuration - Git vs file backend comparison - Workflow examples and troubleshooting - Advanced usage and FAQ
New Specifications: - docs/VSCODE-CHECKPOINT-UI-SPEC.md - VSCode extension UI spec - Enhanced agent toggle button (๐/โ ๏ธ indicators) - Undo button with confirmation modal - System notifications and status polling - Visual mockups and implementation checklist
Updated Documentation:
- Help text includes Agent Mode section with /undo command
- Autocomplete includes /undo command
๐งช Testing¶
New Test Suite¶
tests/test_checkpoint.py - 28 New Tests (All Passing)
GitCheckpointBackend Tests (8 tests):
- โ
test_is_available_with_git_repo - Detects git repository
- โ
test_is_available_without_git_repo - Detects absence of git
- โ
test_create_checkpoint_with_changes - Creates git commit checkpoint
- โ
test_create_checkpoint_without_changes - Returns empty string when no changes
- โ
test_restore_checkpoint - Reverts checkpoint commit
- โ
test_restore_nonexistent_checkpoint - Fails gracefully for invalid hash
- โ
test_list_checkpoints - Lists ppxai checkpoint commits
- โ
test_get_backend_name - Returns "git"
FileCheckpointBackend Tests (9 tests):
- โ
test_is_available - Always available
- โ
test_create_checkpoint - Creates snapshot directory
- โ
test_create_checkpoint_without_files - Returns empty string when no files
- โ
test_restore_checkpoint - Restores files from snapshot
- โ
test_restore_nonexistent_checkpoint - Fails gracefully for missing snapshot
- โ
test_list_checkpoints - Lists file-based checkpoints
- โ
test_cleanup_old_checkpoints - Removes old checkpoints (keeps last N)
- โ
test_get_backend_name - Returns "file"
- โ
test_preserve_directory_structure - Maintains directory structure in snapshots
CheckpointManager Tests (11 tests):
- โ
test_auto_backend_selects_git - Auto mode prefers git
- โ
test_auto_backend_falls_back_to_file - Auto mode falls back to file
- โ
test_explicit_git_backend - Explicit git selection
- โ
test_explicit_git_backend_fails_without_git - Git-only mode fails without repo
- โ
test_explicit_file_backend - Force file backend
- โ
test_none_backend - Disable checkpoints
- โ
test_create_checkpoint - Create checkpoint via manager
- โ
test_undo_checkpoint - Undo via manager
- โ
test_get_status_description_git - Git status message
- โ
test_get_status_description_file - File status message
- โ
test_get_status_description_none - Disabled status message
Test Coverage Summary¶
Total Tests: 365 (337 existing + 28 new) - โ 365 passing - โ 0 failing - โ ๏ธ 0 warnings
Test Isolation: - All checkpoint tests use temporary directories - Git tests create isolated git repositories - File backend tests use unique session IDs - Cleanup ensures no cross-test interference
๐ง Technical Changes¶
Core Implementation¶
New Module: ppxai/checkpoint.py (381 lines)
- CheckpointBackend - Abstract base class
- GitCheckpointBackend - Git-based implementation
- FileCheckpointBackend - File snapshot implementation
- CheckpointManager - Facade with auto-detection
Engine Integration:
- EngineClient._checkpoint_manager - Checkpoint manager instance
- EngineClient._last_checkpoint_id - Track last checkpoint for undo
- EngineClient.create_checkpoint() - Create checkpoint before agent task
- EngineClient.undo_last_checkpoint() - Revert last checkpoint
- EngineClient.get_checkpoint_status() - Status for UI/API
Event System:
- New EventType.STATUS for checkpoint notifications
- Events emitted via _consent_event_queue
- TUIEventHandler handles STATUS events (cyan display)
- HTTP SSE automatically streams STATUS events to VSCode
Command Handling:
- CommandHandler.handle_undo() - /undo command with confirmation
- Enhanced CommandHandler.handle_agent() - Automatic checkpointing
- Warnings when checkpoints disabled
UI/UX:
- Status line shows checkpoint backend and status
- Autocomplete includes /undo command
- Help text includes Agent Mode section
Modified Files¶
- ppxai/checkpoint.py (NEW - 381 lines)
- ppxai/engine/client.py - Checkpoint manager integration
- ppxai/engine/types.py - Added EventType.STATUS
- ppxai/commands.py -
/undocommand, enhanced/agent - ppxai/server/http.py - New checkpoint endpoints
- ppxai/main.py - Status line integration, autocomplete
- ppxai/ui.py - Help text updates
- ppxai/common/event_handler.py - STATUS event handling
- ppxai-config.example.json - Checkpoint configuration examples
- tests/test_checkpoint.py (NEW - 464 lines, 28 tests)
- tests/test_commands.py - Fixed coroutine warnings
- docs/CHECKPOINT_GUIDE.md (NEW - 558 lines)
- docs/VSCODE-CHECKPOINT-UI-SPEC.md (NEW - 216 lines)
Commits on Feature Branch¶
5043df2 fix(v1.12.0): Fix auto-commit timing in async generator flow
3d96cf6 fix(v1.12.0): Initialize checkpoint manager on TUI startup
fd28a70 fix(v1.12.0): Align TUI /undo with VSCode extension behavior
0930961 feat(v1.12.0): Fix checkpoint undo with auto-commit after agent tasks
5fb5a82 docs(v1.12.0): Document interrupt handling improvements
2fc374e feat(v1.12.0): Add robust interrupt handling with automatic rollback
7548620 docs: Add comprehensive v1.12.0 release notes
619184a feat: Add STATUS event type for checkpoint notifications
349f9b8 docs: Add comprehensive checkpoint system user guide
b592837 docs: Add /undo command to help text and autocomplete
... (earlier commits)
๐ Usage Examples¶
Example 1: Git Project Workflow¶
# Check status (git backend auto-detected)
You: /status
[Perplexity | sonar-pro | Tools: ON | Agent: ON | Checkpoints: git]
# Run agent task
You: /agent add user registration endpoint
๐ Agent Mode enabled with Git checkpoints
โข Changes will be auto-committed before each task
โข Use /undo to revert the last agent task atomically
โ Checkpoint created: f3a7b2c1 (add user registration endpoint)
๐ค Starting autonomous agent...
[Agent creates files, edits code...]
# Review changes
You: git diff HEAD~1
# Decide to undo
You: /undo
โ ๏ธ Undo Last Agent Task
Backend: git
Checkpoint: f3a7b2c1
Confirm undo? (y/n): y
โ Changes reverted using git revert (checkpoint: f3a7b2c1)
# Verify
You: git log -2
# Shows checkpoint commit + revert commit
Example 2: Non-Git Project¶
# No git repo, file backend active
[Perplexity | sonar-pro | Tools: ON | Agent: ON | Checkpoints: file]
You: /agent refactor config.py to use environment variables
โ ๏ธ Agent Mode enabled with File checkpoints
โข Snapshots will be saved to ~/.ppxai/checkpoints
โข Use /undo to restore from snapshot
โข Tip: Initialize git repo for atomic commits
โ Snapshot saved: cp-20251227-143022 (refactor config.py)
# Later, undo the changes
You: /undo
โ Files restored from snapshot: cp-20251227-143022
Example 3: Disable Checkpoints¶
[Perplexity | sonar-pro | Tools: ON | Agent: ON | Checkpoints: OFF]
You: /agent update dependencies
โ ๏ธ Agent Mode enabled WITHOUT checkpoints
โข Changes CANNOT be undone
โข Initialize git repo or enable file backend for safety
๐ค Starting autonomous agent...
[Runs without checkpoint - /undo not available]
๐ Security & Safety¶
Safeguards¶
- User Confirmation Required
/undoshows confirmation prompt before reverting- Backend and checkpoint ID displayed
-
Cancel with 'n' or Ctrl-C
-
Git Safety
- No
git push --forceor destructive operations - Standard
git revertcreates new commit (preserves history) -
Compatible with git hooks and workflows
-
File Backend Safety
- Read-only snapshots in
~/.ppxai/checkpoints/ - Auto-cleanup prevents disk space issues
-
Preserves original file permissions
-
Validation
- Checkpoint verification before undo
- Graceful failure for invalid checkpoints
- Clear error messages
Limitations¶
- Single Undo Level
- Only last checkpoint can be undone via
/undo -
Use git commands directly for multiple undos
-
Agent Mode Only
- Checkpoints only created for
/agenttasks -
Regular chat and file editing tools don't auto-checkpoint
-
File Backend Not Atomic
- File backend restores files individually
- Partial restores possible if errors occur
- Git backend recommended for critical tasks
๐ Migration Guide¶
From v1.11.x to v1.12.0¶
Backward Compatible - No Breaking Changes
- Auto-enabled by default:
- Git projects: Checkpoints enabled automatically
- Non-git projects: File backend enabled automatically
-
No configuration required
-
Optional: Customize checkpoint behavior
-
New commands available:
/undo- Revert last agent task-
Enhanced
/agent- Shows checkpoint notifications -
VSCode Extension:
- Checkpoint status visible in agent toggle button
- Undo button appears when checkpoint exists
- System notifications in chat
- (UI implementation pending, API ready)
๐ Performance¶
Overhead¶
Git Backend: - Checkpoint creation: ~50-100ms (git commit) - Undo operation: ~50-100ms (git revert) - Storage: 0 bytes (uses git DAG)
File Backend: - Checkpoint creation: ~10-50ms per file (file copy) - Undo operation: ~10-50ms per file (file restore) - Storage: ~1x file size per checkpoint (compressed possible in future)
Scalability¶
Tested With: - Projects up to 1000 files - Checkpoints with 50+ modified files - Git repositories with 10,000+ commits - File backend with 100+ snapshots
Recommendations:
- Use git backend for large projects (better performance)
- Clean old file snapshots periodically if disk space limited
- Consider "none" backend for read-only tasks
๐ Known Issues¶
Current Limitations¶
- VSCode UI Not Implemented
- HTTP API endpoints functional
- TypeScript UI implementation pending
-
Spec available:
docs/VSCODE-CHECKPOINT-UI-SPEC.md -
File Backend Cleanup
- Auto-cleanup keeps last 10 by default
-
No UI for manual cleanup (use
rm -rf ~/.ppxai/checkpoints/*) -
Checkpoint Message Customization
{task}variable truncated to 100 characters- No other variables supported yet
โ Addressed in v1.12.0¶
- Interrupt Handling (FIXED)
- โ Ctrl-C now prompts for automatic rollback
- โ Git backend offers working directory cleanup
- โ Clear user feedback throughout process
-
โ No more dirty state after interrupts
-
TUI/VSCode Parity (FIXED)
- โ
TUI
/undoworks regardless of agent mode (same as VSCode) - โ
TUI
/undochecks for dirty working tree before undo - โ Checkpoint manager initialized on startup (not just on set_working_dir)
- โ Auto-commit happens correctly in async generator flow
๐ฎ Future Enhancements (v1.13+)¶
Planned Features¶
- Multi-level Undo (v1.13.0)
- Undo multiple checkpoints sequentially
- Checkpoint history UI
-
Selective checkpoint restoration
-
File Editing Checkpoints (v1.13.0)
- Auto-checkpoint for file editing tools
- Per-tool checkpoint configuration
-
Checkpoint before each
apply_patch,replace_block, etc. -
Checkpoint Compression (v1.13.1)
- Compress file backend snapshots
- Differential snapshots (only changed files)
-
Configurable retention policy
-
VSCode Extension UI (v1.12.1)
- Enhanced agent toggle button with ๐/โ ๏ธ indicators
- Undo button with confirmation modal
-
Checkpoint history panel
-
Advanced Git Integration (v1.14.0)
- Branch-per-task workflow
- Automatic git stash before checkpoints
- Checkpoint tags and annotations
๐ Documentation¶
User Guides¶
- Checkpoint System User Guide - Comprehensive guide (558 lines)
- Quick start, configuration, troubleshooting
- Git vs file backend comparison
- Workflow examples and FAQ
Specifications¶
- VSCode Checkpoint UI Spec - Implementation spec (216 lines)
- UI mockups and component design
- API endpoint usage
- Event handling and status polling
Updated Docs¶
- README.md - Updated feature list
- CLAUDE.md - Updated version and feature summary
- Help text (
/help) - Added Agent Mode section
๐ Acknowledgments¶
Key Contributors: - Checkpoint system design and implementation - Comprehensive test coverage (28 new tests) - User guide and documentation - Event system integration
Technologies:
- Git for version control integration
- Python subprocess for git operations
- Rich console for TUI notifications
- FastAPI SSE for VSCode events
๐ Release Checklist¶
- [x] All tests passing (365/365)
- [x] Zero warnings in test output
- [x] User guide completed (558 lines)
- [x] VSCode UI spec completed (216 lines)
- [x] Help text updated
- [x] Autocomplete updated
- [x] Event handling verified (TUI + VSCode SSE)
- [x] HTTP API endpoints functional
- [x] Example configuration provided
- [x] Release notes completed
- [ ] Merge feature branch to master
- [ ] Tag release v1.12.0
- [ ] Update version in all files
- [ ] Create GitHub release
- [ ] Update ROADMAP.md with next steps
๐ Links¶
- Release Tag: v1.12.0 (pending)
- Feature Branch:
feature/agent-multi-file-atomic-edit - Previous Release: v1.11.9
- Roadmap: ROADMAP.md
- User Guide: CHECKPOINT_GUIDE.md
Version: v1.12.0 Release Date: 2025-12-29 Type: Major Feature Release Status: Ready for Merge