Skip to content

fix(context-compact): fix L1 truncation bug on consecutive tool results#465

Open
lelewang520 wants to merge 1 commit into
shareAI-lab:mainfrom
lelewang520:patch-1
Open

fix(context-compact): fix L1 truncation bug on consecutive tool results#465
lelewang520 wants to merge 1 commit into
shareAI-lab:mainfrom
lelewang520:patch-1

Conversation

@lelewang520

Copy link
Copy Markdown

Summary

Fixes a hidden context truncation bug in the L1 snip_compact pipeline where consecutive tool_result messages (often generated by parallel tool execution) would cause a validation failure, leading to broken tool/result pairings and API crashes.

The Problem

In the original snip_compact implementation, the tail boundary alignment (tail_start) was guarded by a single if statement:

if (tail_start > 0 and tail_start < len(messages)
        and _is_tool_result_message(messages[tail_start])
        and _message_has_tool_use(messages[tail_start - 1])):
    tail_start -= 1

### Summary
Fixes a hidden context truncation bug in the L1 `snip_compact` pipeline where consecutive `tool_result` messages (often generated by parallel tool execution) would cause a validation failure, leading to broken tool/result pairings and API crashes.

### The Problem
In the original `snip_compact` implementation, the tail boundary alignment (`tail_start`) was guarded by a single `if` statement:
```python
if (tail_start > 0 and tail_start < len(messages)
        and _is_tool_result_message(messages[tail_start])
        and _message_has_tool_use(messages[tail_start - 1])):
    tail_start -= 1
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.

1 participant