Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chatRuntime): preserve streamed messages when runtime resets

Steven Enamakel01baeba79ac1
diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.ts
index 7d37f72897..7d7da4e981 100644
--- a/app/src/store/chatRuntimeSlice.ts
+++ b/app/src/store/chatRuntimeSlice.ts
@@ -557,6 +557,13 @@ interface ChatTurnUsagePayload {
cachedTokens?: number;
costUsd?: number;
contextWindow?: number;
+ /**
+ * Tokens the orchestrator's context held after the turn's final model call
+ * (`chat_done.usage.context_tokens`). `inputTokens` sums every call of the
+ * turn, so it is spend, not occupancy. Absent from an older core; the gauge
+ * then falls back to the turn totals.
+ */
+ contextTokens?: number;
/** Thread the turn belongs to; routes the delta to that thread's bucket. */
threadId?: string;
subAgents?: Array<{