pub fn filter_reasoning_artifacts(history: &mut [ChatMessage]) -> usizeExpand description
Mid-session model switch (§1.10, dep 8): strip every reasoning artifact
out of history in place — both the metadata keys
(REASONING_METADATA_KEYS) and any content_parts blocks whose
"type" is in REASONING_CONTENT_PART_TYPES — so model-A’s reasoning
never reaches model-B’s context on the next request built from this
history. Returns the count of MESSAGES actually touched (had at least
one metadata key removed and/or at least one content part removed) —
Agent::switch_model records this in the persisted model_change
entry (ModelChangeRecord::reasoning_artifacts_filtered).
Pure and total: never panics, a message with nothing to filter is left
byte-identical (down to content_parts ordering of the parts that
survive), and calling this with nothing to filter (the common case —
supercode’s own live loop never populates these keys) is a cheap no-op
scan, not a rebuild.