Fix first-turn model switching and rollback (#37260)

## Why

A model switch on the first turn has no prior turn settings to compare, and rolling that turn back could leave its model instructions in history.

## What changed

- Track the model that supplied the session's base instructions so first-turn switches inject the target model's instructions, including the selected personality.
- Preserve inherited custom base instructions when starting from an empty fork.
- Remove first-turn model-switch developer content during rollback so retries and cold resumes do not retain or duplicate stale instructions.

## Testing

Add integration coverage for first-turn switches, personality changes, empty-prefix forks, rollback retries, and cold resume.

GitOrigin-RevId: 9df532e9e337521ad3b315b77f8c98e039fb384e
This commit is contained in:
jif authored and copyberry committed 2026-08-06 11:03:31 +00:00
1 parent 82b17bc724
commit a17da5e6e4
7 files changed
+273 -13

No files matched your search

+1
View File
@@ -729,6 +729,7 @@ impl Session {
installation_id,
auth_manager.clone(),
models_manager.clone(),
model_info,
exec_policy,
tx_event.clone(),
agent_status_tx.clone(),