Skip to content

Commit 27ef1b7

Browse files
fix: skip summary metadata entries in JSONL role fallback path
1 parent 1204d39 commit 27ef1b7

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

tests/test_jsonl_parser.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,25 @@ def test_file_history_snapshot_timestamp(self):
720720
finally:
721721
os.unlink(path)
722722

723+
def test_summary_entry_type_produces_no_message(self, caplog):
724+
path = _write_jsonl(
725+
[
726+
{
727+
"type": "summary",
728+
"timestamp": "2026-01-03T08:00:00Z",
729+
"summary": "Session recap metadata",
730+
},
731+
]
732+
)
733+
try:
734+
with caplog.at_level("WARNING", logger="utils.jsonl_parser"):
735+
s = parse_session(path)
736+
assert len(s["messages"]) == 0
737+
assert s["metadata"]["entry_counts"].get("summary") == 1
738+
assert "Unknown message role" not in caplog.text
739+
finally:
740+
os.unlink(path)
741+
723742
def test_entry_counts_accumulated(self):
724743
assistant_entry = {
725744
"type": "assistant",

utils/jsonl_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
__all__ = ["parse_session", "quick_session_info"]
2626

27-
_SKIP_ENTRY_TYPES = frozenset({"file-history-snapshot"})
27+
# Metadata-only JSONL entry types: contribute timestamps/counts but not messages.
28+
_SKIP_ENTRY_TYPES = frozenset({"file-history-snapshot", "summary"})
2829
_VALID_ROLES = frozenset(get_args(RoleLiteral))
2930
_log = logging.getLogger(__name__)
3031

0 commit comments

Comments
 (0)