Skip to content

Commit b57c160

Browse files
authored
Merge pull request MemPalace#373 from RhettOP/fix/issue-347-codex-hook-message-counting
fix: count Codex user_message turns in _count_human_messages (MemPalace#347)
2 parents 2e8a5a7 + a9aaa45 commit b57c160

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

mempalace/hooks_cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ def _count_human_messages(transcript_path: str) -> int:
6363
if "<command-message>" in text:
6464
continue
6565
count += 1
66+
# Also handle Codex CLI transcript format
67+
# {"type": "event_msg", "payload": {"type": "user_message", "message": "..."}}
68+
elif entry.get("type") == "event_msg":
69+
payload = entry.get("payload", {})
70+
if isinstance(payload, dict) and payload.get("type") == "user_message":
71+
msg_text = payload.get("message", "")
72+
if isinstance(msg_text, str) and "<command-message>" not in msg_text:
73+
count += 1
6674
except (json.JSONDecodeError, AttributeError):
6775
pass
6876
except OSError:

0 commit comments

Comments
 (0)