Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hooks/langfuse_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ def get_user_or_assistant_role_from_row(row: Dict[str, Any]) -> Optional[str]:
# Claude Code transcript row format is internal. Prefer top-level row.type
# when it marks a chat row, then fall back to nested message.role.
row_type = row.get("type")
# Request snapshots are internal records, not conversation messages.
if row_type == "api-request-blob":
return None
if row_type in ("user", "assistant"):
return row_type

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_state_lock_contention.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_entry_of_another_session_survives_the_emit(
def other_session_saves() -> None:
with hook_module.FileLock(hook_module.LOCK_FILE):
state = hook_module.load_hook_state()
state["other-session-key"] = {"offset": 42, "updated": "2026-09-10T00:00:00+00:00"}
state["other-session-key"] = {"offset": 42, "updated": _now_iso()}
hook_module.save_hook_state(state)

_during_emit(hook_module, monkeypatch, other_session_saves)
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_turn_assembly.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
from __future__ import annotations

import pytest


@pytest.mark.parametrize("role", ["user", "assistant"])
def test_api_request_snapshots_are_not_conversation_rows(hook_module, role):
row = {"type": "api-request-blob", "message": {"role": role}}
assert hook_module.get_user_or_assistant_role_from_row(row) is None


def test_build_turns_merges_split_assistant_rows(
hook_module,
Expand Down