fix s06:some model textblock may not be the first element (#156)

Co-authored-by: liuyuchao.tick <liuyuchao.tick@bytedance.com>
This commit is contained in:
jigelang
2026-04-01 21:00:25 +08:00
committed by GitHub
parent 92b50e5cd2
commit 117e59c541

View File

@@ -118,7 +118,9 @@ def auto_compact(messages: list) -> list:
"Be concise but preserve critical details.\n\n" + conversation_text}], "Be concise but preserve critical details.\n\n" + conversation_text}],
max_tokens=2000, max_tokens=2000,
) )
summary = response.content[0].text summary = next((block.text for block in response.content if hasattr(block, "text")), "")
if not summary:
summary = "No summary generated."
# Replace all messages with compressed summary # Replace all messages with compressed summary
return [ return [
{"role": "user", "content": f"[Conversation compressed. Transcript: {transcript_path}]\n\n{summary}"}, {"role": "user", "content": f"[Conversation compressed. Transcript: {transcript_path}]\n\n{summary}"},