mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-01 18:35:00 -05:00
fix(copilot): use messages_dict in fallback context compaction
The fallback path in _stream_chat_chunks was passing recent_messages (already sliced) instead of messages_dict (full conversation) to _ensure_tool_pairs_intact. This caused the function to fail to find assistant messages that exist in the original conversation but were outside the sliced window. Fix: Pass messages_dict and slice_start (relative to messages_dict) instead of recent_messages and reduced_slice_start. Fixes SECRT-1861 Related: SECRT-1839
This commit is contained in:
@@ -1184,11 +1184,11 @@ async def _stream_chat_chunks(
|
||||
else recent_messages
|
||||
)
|
||||
# Ensure tool pairs stay intact in the reduced slice
|
||||
reduced_slice_start = max(
|
||||
0, len(recent_messages) - keep_count
|
||||
)
|
||||
# Note: Search in messages_dict (full conversation) not recent_messages
|
||||
# (already sliced), so we can find assistants outside the current slice.
|
||||
# Use slice_start (relative to messages_dict) for correct search range.
|
||||
reduced_recent = _ensure_tool_pairs_intact(
|
||||
reduced_recent, recent_messages, reduced_slice_start
|
||||
reduced_recent, messages_dict, slice_start
|
||||
)
|
||||
if has_system_prompt:
|
||||
messages = [
|
||||
|
||||
Reference in New Issue
Block a user