Release persisted MCP tool results from active-turn memory (#62641)

## Why

Active turns in paginated threads retain completed MCP tool results in
memory even when history can supply the same payloads. History can also
store a truncated preview, so dropping a result requires checking that
the full payload is recoverable.

## What changed

For persisted paginated threads, check successful MCP calls in batches
and release an active-turn result only when the stored result matches
it exactly. When resuming with full history, fetch released results by
item ID so a stale history page cannot supply an older result.

## Testing

Add a regression test that restores the latest result despite a stale
page and checks that truncated, metadata-mismatched, missing, and failed
results remain in memory.

GitOrigin-RevId: 49f6f1414201e4327433043050d65a1f4adc9720
This commit is contained in:
Brent Traut
2026-11-20 01:49:15 +00:00
committed by copyberry
parent e720e6c80b
commit 7642e80723
9 changed files with 281 additions and 27 deletions
@@ -580,6 +580,7 @@ impl MessageProcessor {
);
let turn_processor = TurnRequestProcessor::new(
Arc::clone(&thread_manager),
Arc::clone(&thread_store),
outgoing.clone(),
analytics_events_client.clone(),
Arc::clone(&config),