Name each clause of typed for the entry kind it drops

This commit is contained in:
2026-09-27 16:59:41 +02:00
parent 1f99088145
commit 82cd7cbd8e
2 changed files with 8 additions and 9 deletions
+8 -5
View File
@@ -410,14 +410,17 @@ def human_turns(entries):
def typed(entry):
"""A human turn: a "user" entry, not isMeta, not promptSource "sdk" (the loop's own prompts), whose message.content is a string not starting with "<" (<command-name> and its kind) or one or more text parts, none starting with "[Request interrupted"."""
if entry.get("type") != "user" or entry.get("isMeta") or entry.get("promptSource") == "sdk":
if entry.get("type") != "user":
return False
content = entry.get("message", {}).get("content")
if isinstance(content, str):
return not content.startswith("<")
parts = content if isinstance(content, list) else []
return bool(parts) and all(isinstance(part, dict) and part.get("type") == "text" and not part.get("text", "").startswith("[Request interrupted") for part in parts)
meta = entry.get("isMeta")
loop_prompt = entry.get("promptSource") == "sdk"
command = isinstance(content, str) and content.startswith("<")
no_content = not isinstance(content, str) and not parts
non_text = any(not isinstance(part, dict) or part.get("type") != "text" for part in parts)
interruption = any(isinstance(part, dict) and part.get("type") == "text" and part.get("text", "").startswith("[Request interrupted") for part in parts)
return not (meta or loop_prompt or command or no_content or non_text or interruption)
# "assistant" entries and stream-json