mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-08-06 12:03:37 +08:00
Merge pull request #364 from costajohnt/refactor/reactive-compact-summarize-old-history
refactor: summarize only trimmed history in reactive_compact
This commit is contained in:
@@ -382,12 +382,12 @@ def compact_history(messages):
|
||||
# Emergency: reactiveCompact — on API error
|
||||
def reactive_compact(messages):
|
||||
transcript = write_transcript(messages)
|
||||
summary = summarize_history(messages)
|
||||
tail_start = max(0, len(messages) - 5)
|
||||
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 = summarize_history(messages[:tail_start])
|
||||
return [{"role": "user", "content": f"[Reactive compact]\n\n{summary}"}, *messages[tail_start:]]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user