Preserve fork runtime versions without loading full model context (#43545)

## Why

A fork cutoff can exclude the `TurnContext` that records the source's multi-agent runtime version. Recovering that version should not require loading the source's full model context.

## What changed

- Preserve `multi_agent_version` in fork session metadata before applying the cutoff. If absent, scan backward for the newest version-bearing `TurnContext`, respecting inherited segment boundaries and stopping once resolved.
- Load the latest model context for paginated forks only when approval or permission settings need to be restored.

## Testing

Add regression tests covering stored-version precedence, early termination without reading older segments, and version recovery within inherited segment cutoffs.

GitOrigin-RevId: 00e66bcce6f4092805e273cde99bd50f304fb39e
This commit is contained in:
jif
2026-09-07 18:34:49 +00:00
committed by copyberry
parent 7d8e2dd6c5
commit 4f1a2bb5ff
3 changed files with 162 additions and 1 deletions
@@ -4944,6 +4944,7 @@ impl ThreadRequestProcessor {
None
};
let latest_context = if paginated_source
&& needs_latest_settings
&& loaded_parent.is_none()
&& (last_turn_id.is_some() || before_turn_id.is_some())
{