Skip to content

Commit 117e59c

Browse files
jigelangliuyuchao.tick
andauthored
fix s06:some model textblock may not be the first element (#156)
Co-authored-by: liuyuchao.tick <liuyuchao.tick@bytedance.com>
1 parent 92b50e5 commit 117e59c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

agents/s06_context_compact.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def auto_compact(messages: list) -> list:
118118
"Be concise but preserve critical details.\n\n" + conversation_text}],
119119
max_tokens=2000,
120120
)
121-
summary = response.content[0].text
121+
summary = next((block.text for block in response.content if hasattr(block, "text")), "")
122+
if not summary:
123+
summary = "No summary generated."
122124
# Replace all messages with compressed summary
123125
return [
124126
{"role": "user", "content": f"[Conversation compressed. Transcript: {transcript_path}]\n\n{summary}"},

0 commit comments

Comments
 (0)