Skip to main content

scan_model_switch

Function scan_model_switch 

Source
pub fn scan_model_switch(
    diff: &str,
    harness: &str,
    model_config: &ModelConfig,
) -> ModelSwitchScan
Expand description

Scan a unified diff for an inline /model <x> command in user-added lines.

Behavior:

  • Only matches + lines (user additions), excluding +++ headers.
  • Skips lines inside fenced code blocks (``` or ~~~).
  • Skips blockquote lines (+>).
  • Pattern: line content matches /model <arg> (whitespace allowed).
  • On match, the line is removed from the returned diff so it does not propagate to classification or response generation.
  • Only the first match is captured; subsequent /model lines are still stripped.

The arg is parsed via parse_model_arg, which accepts both tier names (low|med|high) and concrete model names (opus|sonnet|...).