From 9d09d3fa149bf98134d12098b46f8a11ae0b8f0f Mon Sep 17 00:00:00 2001 From: Aaron Nelson Date: Wed, 20 May 2026 22:41:02 +0000 Subject: [PATCH] api.py: flush=True on graphiti-push log lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The background daemon thread that pushes chat turns to Graphiti was using default-buffered print(), so the success/failure lines never reached the systemd journal — buffer never flushed because the thread keeps the interpreter alive. The push itself worked (verified by Episodic nodes appearing in the graph), just the log was silent. Surgical fix: pass flush=True on the four print() calls inside _push_chat_turn_ to_graphiti's background worker. Now every push result lands in the journal as it happens, giving real-time visibility into whether pushes are succeeding, failing on non-200, hitting a network error, or raising unexpectedly. If we add more background-thread logging later, PYTHONUNBUFFERED=1 in the service environment would solve it globally — but that's overkill for this one site. --- scripts/api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/api.py b/scripts/api.py index d64eed1..8d059d0 100644 --- a/scripts/api.py +++ b/scripts/api.py @@ -518,13 +518,13 @@ def _push_chat_turn_to_graphiti(conversation_id, user_message, assistant_message # is empirically ~20 min wall-clock. We're patient; chat isn't. r = requests.post(f"{GRAPHITI_URL}/episodes", json=payload, timeout=1800) if r.status_code == 200: - print(f"[graphiti-push] turn ingested: {episode_name}") + print(f"[graphiti-push] turn ingested: {episode_name}", flush=True) else: - print(f"[graphiti-push] non-200 ({r.status_code}) for {episode_name}: {r.text[:200]}") + print(f"[graphiti-push] non-200 ({r.status_code}) for {episode_name}: {r.text[:200]}", flush=True) except requests.RequestException as e: - print(f"[graphiti-push] request failed: {e}") + print(f"[graphiti-push] request failed: {e}", flush=True) except Exception as e: - print(f"[graphiti-push] unexpected error: {e}") + print(f"[graphiti-push] unexpected error: {e}", flush=True) threading.Thread(target=_work, daemon=True).start()