cortex qm / cortex mqm

The Model Quartermaster is an adaptive model-selection engine that observes LLM calls across sessions, computes six weighted signal scores, and fuses them to predict the optimal model for each task. cortex mqm provides model-level analysis across all sessions; the legacy cortex qm tool-prediction variant is also available for tool-level analysis.

Usage

cortex qm <subcommand> [options]
cortex mqm <subcommand> [options]

Six Prediction Signals (MQM)

SignalDescription
TrajectoryRecent model usage patterns and sequences
EpisodicSimilar conversation context matching
HistoricalPast performance data for task categories
CostCost efficiency optimization across models
QualityExpected quality based on model capabilities
ReflectionPer-turn reflection feedback integration

cortex qm Subcommands

SubcommandDescription
patternsList learned patterns
weightsShow current signal weights
statsDisplay usage statistics
decisionsShow prediction decisions for a session
traceTrace the prediction chain for a turn
dashboardRich visual dashboard with accuracy bars and top predictions
accuracyShow prediction accuracy metrics
resetReset quartermaster state for a session
reset-allReset all quartermaster data

Options

OptionSubcommandDescription
--limit, -npatternsLimit number of patterns shown
--session, -sdecisions, dashboard, accuracyFilter by session ID
--limit, -ndecisionsLimit number of decisions shown

cortex mqm Subcommands

SubcommandDescription
statsModel-level usage statistics
decisionsModel-level prediction decisions
weightsModel-level signal weights
accuracyAccuracy metrics across all sessions
dashboardModel-level dashboard
resetReset model-level quartermaster
reset-allReset all model-level data

Options

OptionSubcommandDescription
--limit, -ndecisionsLimit number of decisions
--hours, -haccuracyTime window for accuracy calculation

Prediction Confidence Levels

ConfidenceAction
≥ 85%Enforce — Override model selection (safe operations only)
65–84%Suggest — Recommend model to the agent
< 65%Defer — Let the agent decide

Active Mode

The Quartermaster requires 50 observations before entering active prediction mode. Before this threshold, it operates in learning-only mode, collecting data without making predictions.

Reinforcement Learning

After each prediction, the Quartermaster evaluates correctness:

  • Reward (EMA α = 0.15): Increase signal weights for correct predictions
  • Punishment (EMA α = 0.25): Decrease weights for incorrect predictions
  • Convergence: Weights stabilize after ~200–500 observations

Dashboard Output

The dashboard subcommand provides the richest output:

  • Accuracy bars per signal
  • Current signal weights visualization
  • Top models by prediction accuracy
  • Session and model-level trends
  • Confidence distribution histograms

Examples

# View prediction dashboard for a session
cortex qm dashboard -s sess_abc123

# Show learned patterns
cortex qm patterns --limit 20

# Display signal weights
cortex qm weights

# Trace prediction for a specific turn
cortex qm trace 42

# Show accuracy metrics
cortex qm accuracy -s sess_abc123

# Model-level accuracy over last 24 hours
cortex mqm accuracy -h 24

# Reset all quartermaster data
cortex mqm reset-all