Skip to content

fix(compaction): recover the correct occurrence of reused tool calls - #7583

Open
LingYi-Liang wants to merge 1 commit into
google:mainfrom
LingYi-Liang:fix/compaction-call-occurrences
Open

LingYi-Liang wants to merge 1 commit into
google:mainfrom
LingYi-Liang:fix/compaction-call-occurrences

Conversation

@LingYi-Liang

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

Compaction recovery can pair a resumed result with an older call when IDs are reused, or recover a sibling's result from another call. Match responses to their original call occurrence before restoring events; preserve full call events and thought signatures.

Testing Plan

20 compaction tests pass on Python 3.11–3.14; seven fail on the baseline. Includes four-turn Runner replays with in-memory and SQLite sessions using MockModel.

Full tox is not green. Failures also occur on the baseline or in independent flaky checks; details below.

Full matrix results
Python Passed Failed Skipped Xfailed Xpassed
3.11.16 19708 102 92 19 2
3.12.14 19698 103 93 19 2
3.13.15 19699 102 93 19 2
3.14.7 19698 103 93 19 2

Linux, base cb47e7b, full tests/unittests through tox. Used the same --no-install-package lancedb exception as upstream CI. Failed nodes were rerun against the unchanged baseline implementation in each environment.

The random sample fails on both trees with tracing enabled. The packaged-skill assertion is intermittent on both trees; the changed helper is never called in these probes. Telemetry and localhost HTTP failures also reproduce on the baseline.

pytest tests/unittests/flows/llm_flows/context/test_content_compaction.py

Checklist

  • Read the contribution guide and reviewed the diff.
  • Added regression tests and ownership comments.
  • Tested the Runner flow end-to-end with a model double.
  • Full unit suite is green; baseline failures are documented above.
  • No dependent downstream changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the _recover_compacted_function_calls function in _compaction.py to correctly handle cases where function call IDs are reused. It resolves ownership of responses to the latest preceding call with the same ID in source order, utilizing object IDs and composite keys to track events and prevent incorrect associations or duplicate reinjections. Additionally, comprehensive unit tests have been added to verify this behavior under various scenarios, including resumed responses and parallel calls. I have no feedback to provide as there are no review comments to address and the implementation looks solid.

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.

2 participants