Skip to content

fix(flows): drop unpairable trailing FRs in rearrange - #6752

Open
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/rearrange-orphan-fr-followup
Open

fix(flows): drop unpairable trailing FRs in rearrange#6752
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/rearrange-orphan-fr-followup

Conversation

@a2105z

@a2105z a2105z commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the orphan-FR prune that landed in 73e8625 / discussion on #6587.

_drop_orphaned_function_responses only removes responses that carry an id. Trailing id-less / empty-id FRs, and rearrange itself when the prune is bypassed, could still raise during contents assembly and permanently poison the session.

This change:

  • Makes _rearrange_events_for_latest_function_response drop unpairable trailing FRs instead of raising (defense in depth requested on fix(flows): Drop orphaned FRs instead of poisoning sessions #6587)
  • Strips unmatched FR parts when a call event is found but the trailing event also carries extras (same poisoning ValueError)
  • Leaves true id-less FC/FR adjacent pairs alone (model families that strip ids)

Fixes #6751
Related: #6582, #6587

Test plan

The id-based orphan prune left rearrange raising on id-less/empty-id
trailing responses and on unmatched extras, which still poisoned sessions.
@a2105z

a2105z commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

Hi @GWeale @DeanChensj @llalitkumarrr — this is the follow-up from #6587.

After 73e8625 pruned id'd orphans, rearrange could still raise on id-less/empty-id trailing FRs (and on unmatched extras). This makes rearrange drop those instead of poisoning the session, as you suggested.

Ready for review whenever you have a chance — thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contents rearrange still raises on id-less / unmatched trailing function responses (follow-up to orphan FR prune)

2 participants