feat(markdown): thinking blocks between hidden tool calls collapse to the first one
This commit is contained in:
@@ -48,14 +48,19 @@ def render_assistant_text(text: str) -> str:
|
||||
def render_assistant_message(message: Message) -> str:
|
||||
"""Render an assistant ``Message`` into a turn block.
|
||||
|
||||
Tool-use blocks render to nothing; only text and thinking content reach
|
||||
the file (see :mod:`.parser` for how the reverse strip works).
|
||||
Tool-use blocks render to nothing; of the thinking blocks between two
|
||||
texts only the first one reaches the file.
|
||||
"""
|
||||
parts: list[str] = ["### Assistant:", ""]
|
||||
after_thinking = False
|
||||
for block in message.content:
|
||||
thinking = isinstance(block, ThinkingBlock)
|
||||
if thinking and after_thinking:
|
||||
continue
|
||||
lines = list(_render_block(block))
|
||||
if not lines:
|
||||
continue
|
||||
after_thinking = thinking
|
||||
parts.extend(lines)
|
||||
parts.append("")
|
||||
return "\n".join(parts).rstrip() + "\n"
|
||||
|
||||
Reference in New Issue
Block a user