Skip to content

feat(compact): add debug subcommand for context window inspection#179

Merged
laynepenney merged 4 commits intomainfrom
feature/context-debug-command
Jan 26, 2026
Merged

feat(compact): add debug subcommand for context window inspection#179
laynepenney merged 4 commits intomainfrom
feature/context-debug-command

Conversation

@laynepenney
Copy link
Copy Markdown
Collaborator

Summary

Adds a new /compact debug subcommand that provides comprehensive debugging information about the current context window contents.

Features

  • Detailed token counts by category (messages, system prompt, tool definitions)
  • Message breakdown by role (user, assistant, tool results)
  • Current limits and budget information (context window, reserves, tiers)
  • Compression status and statistics
  • Working set file count
  • Message previews with content length information

Usage

/compact debug

Benefits

This feature helps developers and users understand:

  • What's consuming context space
  • Whether they're approaching token limits
  • How compression is affecting message content
  • The composition of their conversation history

Example Output

The command returns a structured JSON response prefixed with CONTEXT_DEBUG: containing all relevant context information for troubleshooting.

Testing

Built successfully with no TypeScript errors. Follows existing command patterns in the codebase.

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>
@laynepenney
Copy link
Copy Markdown
Collaborator Author

Thorough Review Complete ✅\n\n### Code Review Findings\n\n#### ✅ Code Quality\n- Structure: Follows existing command patterns correctly\n- TypeScript: Compiles without errors\n- Formatting: Consistent with codebase style\n- Error Handling: Uses existing command error patterns\n\n#### ✅ Functionality\n- Command Logic: All methods called exist on Agent class\n- JSON Output: Properly structured with formatting\n- Unused Variable: FIXED - removed unused variable\n- Content Preview: Safe truncation logic for message content\n\n#### ✅ Testing\n- Build Validation: ✅ Compiled successfully\n- Test Suite: ✅ All tests pass (no regressions)\n- Integration: ✅ Fits seamlessly into existing command\n\n### Implementation Review\n\n#### Information Provided\n- Token counts by category (messages, system prompt, tool definitions)\n- Message breakdown by role (user, assistant, tool results)\n- Current limits and budget (context window, reserves, tiers)\n- Compression status and statistics\n- Working set file count\n- Message previews with content length\n\n#### Missing Information\n- Conversation summary content (marked as placeholder due to private access)\n- This is correct - agent.conversationSummary is private\n\n### Risk Assessment\n- Low Risk: Read-only operation, no side effects\n- Performance: Minimal overhead (already cached stats)\n- Backwards Compatible: New subcommand, no breaking changes\n\n### Security Assessment\n- Read-Only: Only calls public methods\n- No Data Leaks: Sensitive data is properly filtered\n- Scope Limited: Only exposes aggregated statistics\n\n### Recommendations\n- ✅ Ready for merge\n- Consider adding unit tests in future PR (not blocking)\n- The placeholder for conversation summary is appropriate\n\nVerdict: ✅ Approved

@laynepenney laynepenney merged commit 10537f6 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