Skip to content

fix(autogen-core): report the true skipped message count in head and tail context - #8370

Open
Aniket Kumar (aniketkrs) wants to merge 1 commit into
microsoft:mainfrom
aniketkrs:fix/head-tail-skipped-count
Open

Aniket Kumar (aniketkrs) wants to merge 1 commit into
microsoft:mainfrom
aniketkrs:fix/head-tail-skipped-count

Conversation

@aniketkrs

Copy link
Copy Markdown

Fixes #8328

User impact: when a transcript is trimmed with HeadAndTailChatCompletionContext, the injected marker reports the wrong number of dropped messages. With head_size 2 and tail_size 2 on an 8 message transcript where both boundary trims fire, the marker prints Skipped 4 messages while 6 were actually dropped. Anyone relying on that count for token budget UIs or debugging gets a misleading number.

Cause: get_messages trims the head and tail lists at the tool call boundaries, but num_skipped is computed from the configured head_size and tail_size, ignoring the messages the trims removed.

Fix: compute num_skipped from the lengths of the actually retained head and tail lists. The not enough messages short circuit is unchanged, and the count can no longer drift from the messages that are really kept.

Before: Skipped 4 on the issue example. After: Skipped 6, matching the messages actually omitted. Branch file re fetched and patch confirmed present.

Copilot AI balanced review requested due to automatic review settings October 18, 2026 04:20

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

HeadAndTailChatCompletionContext undercounts omitted tool boundary messages

2 participants