Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Fixes janky /compact slash-command behavior where commands with invalid model formats would show up in chat history even though the request failed.

Changes

  • Backend validation (agentSession.ts): Validate model format before persisting user message to history. Invalid model strings (missing provider prefix) are now rejected before the message is saved, preventing orphaned compaction request messages.

  • Frontend validation (chatCommands.ts): Fail fast in /compact handler when model format is invalid, showing a clear toast error with example format.

  • Helper function: Add isValidModelFormat() to check for provider:model-id format (supports colons in model ID for ollama-style names).

  • Preference poisoning fix: Stop eagerly saving compaction model to localStorage, preventing invalid model values from affecting future /compact commands.

Testing

  • Added unit tests for isValidModelFormat()
  • Updated integration test for invalid model format error handling

Generated with mux

@ammar-agent ammar-agent force-pushed the chat-gjyz branch 2 times, most recently from 8343191 to ee0de0d Compare December 12, 2025 15:50
- Add early model format validation in backend (agentSession.ts) to reject
  invalid model strings before persisting user message to history
- Add frontend validation in /compact handler to fail fast with clear error
- Add isValidModelFormat() helper in shared location (common/utils/ai/models.ts)
- Remove eager localStorage save of compaction model preference to prevent
  poisoning future /compact commands with invalid model values

This fixes the issue where /compact -m badmodel would show the command in
chat history even though the request failed due to invalid model format.
@ammario ammario merged commit 59286b9 into main Dec 12, 2025
20 checks passed
@ammario ammario deleted the chat-gjyz branch December 12, 2025 17:57
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