mirror of
https://github.com/RightNow-AI/openfang.git
synced 2026-07-30 15:01:15 +00:00
* fix: use async save_session to avoid blocking tokio runtime save_session() was synchronous, holding a Mutex<Connection> on the tokio worker thread during SQLite writes. On pods with 1 CPU core (1 tokio worker thread), this starved the entire runtime — including health check endpoints — causing K8s to mark the pod not-ready and return 504 on all subsequent requests. Add save_session_async() that wraps the SQLite write in spawn_blocking, matching the pattern already used by other memory operations (recall, remember, etc.). Update all 12 call sites in the agent loop. * fix: move health check DB query to spawn_blocking and add SSE keep_alive The health endpoint called structured_get() synchronously on the tokio async runtime, acquiring the shared std::sync::Mutex<Connection> on a worker thread. When the agent loop held this mutex during session saves, the health check blocked the tokio thread, starving the SSE stream and causing Kubernetes probe timeouts. - Health and health_detail now run the DB check via spawn_blocking - SSE message/stream endpoint now includes keep_alive to flush periodic heartbeats even during contention * feat: add hands upsert API for idempotent hand definition updates Add upsert_from_content() to HandRegistry that overwrites existing definitions instead of rejecting duplicates. Exposed as POST /api/hands/upsert for use by the shard manager to keep hand definitions up to date across pod restarts. * fix: websocket streaming delays * fix: get response immediately