Skip to main content

Module model_change

Module model_change 

Source
Expand description

P4c (COMPOSABLE-HARNESS-DESIGN.md §5.2 “P4” core NEW-significant item, §1.10/§3.1 core.model_switch.allow_switch, D9 row): a persisted, TYPED record of a mid-session model switch — pi’s model_change precedent (design §1.10: “persisted change records … pi’s model_change is the cleanest precedent”). Deliberately flat/typed (not a formatted string), mirroring crate::usage_log::UsageRecord’s exact rationale: a translatable, lossless session-data channel (§1.13), not a lossy notice — so it survives a save/load round trip byte-for-byte in the fields that matter, and a future reader (a translator emitting this same session under another harness’s format, a doctor/inspect stats command) can consume it without re-parsing prose.

Structs§

ModelChangeRecord
One mid-session model switch, as Agent::switch_model records it when Config::model_switch_allow_switch is on (see that field’s doc comment for the exact gate — with the knob off, switch_model never creates one of these at all, matching Agent::set_model’s pre-existing, record-free mechanics byte-for-byte).

Functions§

from_jsonl
Parse a JSONL model-change log back into records — the exact inverse of to_jsonl. Blank lines are skipped; a malformed line is a hard error (like crate::usage_log::from_jsonl — this is accounting/provenance data, corruption should be visible, not silently dropped).
to_jsonl
Serialize records as JSONL (one ModelChangeRecord per line) — the same shape crate::usage_log::to_jsonl and every other append-log in this crate uses. Never fails on an empty slice (produces an empty string).