Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Overview

Adds support for choosing the compaction model via /compact -m <model> flag. Reuses existing model abbreviation infrastructure for consistency and shows the model name in the streaming barrier during compaction.

Changes

  • Command Parser: Added -m flag parsing to /compact command with model abbreviation resolution
  • Type System: Extended ParsedCommand to include optional model field for compact command
  • Message Preparation: Updated prepareCompactionMessage() to use custom model when specified
  • UI Display: Updated StreamingBarrier to show model name during compaction (e.g., "claude-haiku-4-5 compacting...")
  • Tests: Added 7 new tests for -m flag, updated 27 existing tests

Usage

# Use haiku for fast compaction
/compact -m haiku

# Use opus for detailed summary with token limit
/compact -m opus -t 8000

# Use full model string
/compact -m anthropic:claude-opus-4-1

# Combine with continue message
/compact -m sonnet -t 5000
Continue implementing the auth system

# Default behavior (uses current workspace model)
/compact

Design Notes

  • Reuses model abbreviations: Leverages existing MODEL_ABBREVIATIONS map for consistency with /model command
  • Optional override: Model parameter defaults to workspace model when not specified
  • UI consistency: Compaction barrier now matches streaming barrier format with model name prefix
  • Robust parsing: Handles edge cases (empty flag, unknown abbreviations, etc.)

Testing

✅ All 34 slash command tests passing
✅ All 547 unit tests passing
✅ TypeScript compilation successful
✅ ESLint checks passing

Generated with cmux

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR.

- Add -m <model> flag to /compact command for choosing compaction model
- Reuse MODEL_ABBREVIATIONS for consistent abbreviation handling
- Support both abbreviated (sonnet, haiku, opus) and full model strings
- Update StreamingBarrier to show model name during compaction
- Falls back to workspace model when -m flag not specified
- Add comprehensive tests covering all flag combinations

Examples:
  /compact -m haiku
  /compact -m opus -t 8000
  /compact -m anthropic:claude-opus-4-1

Generated with `cmux`
Move thinking policy enforcement from frontend to backend
(agentSession.streamWithHistory) to ensure it's applied consistently
regardless of where the request originates (compact command, manual
override, etc.). This prevents bugs where custom model overrides might
bypass policy requirements (e.g., gpt-5-pro requiring 'high' thinking).

Single source of truth pattern - no need to remember to call
enforceThinkingPolicy in multiple places.

Generated with `cmux`
Haiku is the fastest good coding model, making it ideal for compaction.

Generated with `cmux`
Replace dynamic import with static import to satisfy linter rules.

Generated with `cmux`
Extract compaction transformation logic into shared utility to ensure
consistency between initial send (ChatInput) and resume (useResumeManager).

This eliminates the architectural fragility where custom model/token
overrides could be lost during stream resumption. Now both code paths
call the same applyCompactionOverrides() function.

Key changes:
- Add CompactionRequestData shared type (includes model field)
- Create applyCompactionOverrides(baseOptions, compactData) utility
- Update prepareCompactionMessage to use shared function
- Update useResumeManager to detect compaction and apply overrides
- Add comprehensive tests for transformation logic

Benefits:
- Single source of truth for option transformation
- Impossible to have divergent behavior between paths
- Custom model preserved across interruption/resume
- Works retroactively (user message metadata already persisted)

Generated with `cmux`
Check if cached shfmt binary works before using it. If the cache
contains a broken binary, reinstall it.

Fixes CI failure where cache hit but binary was unusable.

Generated with `cmux`
@ammario ammario enabled auto-merge October 16, 2025 03:36
@ammario ammario added this pull request to the merge queue Oct 16, 2025
Merged via the queue into main with commit 9ed91d6 Oct 16, 2025
10 checks passed
@ammario ammario deleted the compact-model branch October 16, 2025 03:50
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.

2 participants