mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-08-06 12:03:37 +08:00
docs: align reactive_compact README guard with code
The reactive_compact README snippets (en/zh/ja) used a shortened tail boundary check, while code.py guards with `tail_start > 0 and tail_start < len(messages)` before reading messages[tail_start]. Match the snippets to the actual code so the teaching example stays consistent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UJumwVeBXSGYh8nSzoVTF
This commit is contained in:
@@ -140,7 +140,9 @@ This triggers **reactive_compact**: more aggressive than compact_history, it ret
|
||||
def reactive_compact(messages):
|
||||
transcript = write_transcript(messages)
|
||||
tail_start = max(0, len(messages) - 5)
|
||||
if _is_tool_result_message(messages[tail_start]) and _message_has_tool_use(messages[tail_start - 1]):
|
||||
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",
|
||||
|
||||
@@ -140,7 +140,9 @@ API がまだ `prompt_too_long`(413)を返すことがある。コンテキ
|
||||
def reactive_compact(messages):
|
||||
transcript = write_transcript(messages)
|
||||
tail_start = max(0, len(messages) - 5)
|
||||
if _is_tool_result_message(messages[tail_start]) and _message_has_tool_use(messages[tail_start - 1]):
|
||||
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",
|
||||
|
||||
@@ -140,7 +140,9 @@ def compact_history(messages):
|
||||
def reactive_compact(messages):
|
||||
transcript = write_transcript(messages)
|
||||
tail_start = max(0, len(messages) - 5)
|
||||
if _is_tool_result_message(messages[tail_start]) and _message_has_tool_use(messages[tail_start - 1]):
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user