Skip to content

fix: improve context debug command with error handling and performance#184

Merged
laynepenney merged 7 commits intomainfrom
fix/context-debug-clean
Jan 26, 2026
Merged

fix: improve context debug command with error handling and performance#184
laynepenney merged 7 commits intomainfrom
fix/context-debug-clean

Conversation

@laynepenney
Copy link
Copy Markdown
Collaborator

This PR improves the context debug command with critical error handling and performance optimizations.

Fixes Applied

Error Handling

  • Add try-catch wrapper to prevent command crashes
  • Proper error messages for different failure scenarios

Code Quality

  • Rename 'messages' property to 'messagePreviews' for clarity
  • Add input validation for null/undefined messages array

Performance

  • Optimize contentLength calculation (remove expensive reduce operation)
  • Simple array length check for complex content

Documentation

  • Update error message to include all valid subcommands

Testing

  • All 16 compact-command tests pass
  • TypeScript compilation succeeds
  • No regressions in existing functionality

Risk Assessment

  • Low Risk: Only improvements and error handling
  • No Breaking Changes: API compatibility maintained
  • Performance: Optimized, not degraded
  • Security: No new attack vectors

Wingman: Codi codi@layne.pro

- Remove duplicate paragraph in Codi's Capabilities section
- Remove duplicate non-interactive mode examples from Quick Reference
- Fix chaotic feature numbering in Lower Priority section (reordered to 12-31)
- Remove redundant security vulnerability paragraph

Wingman: Codi <codi@layne.pro>
- Renumbered features from chaotic sequence to clean 1-24 numbering
- Removed gap between features 13 and 21 by integrating implemented features
- Fixed duplicate entries by properly organizing Lower Priority section
- Updated Implementation Priority Recommendation to match feature order
- No content removed - only organizational improvements

Wingman: Codi <codi@layne.pro>
Adds a new /compact debug subcommand that provides detailed information about
the current context window contents including:

- Token counts by category (messages, system prompt, tool definitions)
- Message breakdown by role (user, assistant, tool results)
- Current limits and budget information
- Compression status and statistics
- Working set file count
- Message previews with content length information

This helps developers understand what's consuming context space and
troubleshoot context-related issues.

Wingman: Codi <codi@layne.pro>
- Add error handling around debug subcommand with proper error messages
- Rename 'messages' property to 'messagePreviews' for clarity
- Add validation for null/undefined messages array
- Optimize contentLength calculation for complex content
- Fix error message to include 'memory' subcommand

Wingman: Codi <codi@layne.pro>
- Add try-catch wrapper for proper error handling
- Rename 'messages' property to 'messagePreviews' for clarity
- Add input validation for null/undefined messages array
- Optimize contentLength calculation for complex content
- Update error message to include 'memory' subcommand

Wingman: Codi <codi@layne.pro>
@laynepenney laynepenney merged commit c0941c9 into main Jan 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant