From ecc909de38f2fa8b014060711cb252c096d3f1fb Mon Sep 17 00:00:00 2001 From: sprmn24 Date: Wed, 22 Apr 2026 00:18:04 +0300 Subject: [PATCH] fix(session): serialize JSONL transcript appends under existing lock --- gateway/session.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gateway/session.py b/gateway/session.py index 16de296e0e..be393e48e6 100644 --- a/gateway/session.py +++ b/gateway/session.py @@ -1276,8 +1276,9 @@ class SessionStore: # Also write legacy JSONL (keeps existing tooling working during transition) transcript_path = self.get_transcript_path(session_id) - with open(transcript_path, "a", encoding="utf-8") as f: - f.write(json.dumps(message, ensure_ascii=False) + "\n") + with self._lock: + with open(transcript_path, "a", encoding="utf-8") as f: + f.write(json.dumps(message, ensure_ascii=False) + "\n") def rewrite_transcript(self, session_id: str, messages: List[Dict[str, Any]]) -> None: """Replace the entire transcript for a session with new messages.