The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(chat): prevent snapshot polling from cancelling rows of a newer turn
Steven Enamakelaaba084c8c32
diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsxindex 1825bee57f..dbde30ee9b 100644--- a/app/src/providers/ChatRuntimeProvider.tsx+++ b/app/src/providers/ChatRuntimeProvider.tsx@@ -640,6 +640,12 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {await flushQueuedFollowups(event.thread_id);dispatch(endInferenceTurn({ threadId: event.thread_id }));dispatch(clearThreadInferenceActive(event.thread_id));+ // Snapshot polling can outlive this completed turn. Capture the rows it+ // owns before awaiting it so a newer turn on the same thread is never+ // cancelled by this recovery path.+ const unresolvedRowIds = (store.getState().chatRuntime.toolTimelineByThread[event.thread_id] ?? [])+ .filter(entry => entry.status === 'running' && entry.subagent?.mode !== 'async')+ .map(entry => entry.id);// Socket reducers keep only the current iteration's prose in the live// buffer. Once the turn settles, replace that partial projection with// the core's completed snapshot, whose ordered transcript contains every@@ -650,7 +656,7 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {fetchAndHydrateCompletedTurnState(event.thread_id)).unwrap();if (!completedSnapshot) {- dispatch(cancelUnresolvedTurnTimeline({ threadId: event.thread_id }));+ dispatch(cancelUnresolvedTurnTimeline({ threadId: event.thread_id, rowIds: unresolvedRowIds }));}};diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.tsindex a95431f12c..551474a966 100644--- a/app/src/store/chatRuntimeSlice.ts+++ b/app/src/store/chatRuntimeSlice.ts@@ -1318,7 +1318,8 @@ const chatRuntimeSlice = createSlice({// A settled row stays settled. A replayed/late `tool_call` for a call// whose result already landed used to flip it back to `running`, and// nothing would ever settle it again.- const settled = prev.status === 'success' || prev.status === 'error';+ const settled =+ prev.status === 'success' || prev.status === 'error' || prev.status === 'cancelled';entries[existingIdx] = decorateEntry({...prev,name: toolName,@@ -1791,11 +1792,17 @@ const chatRuntimeSlice = createSlice({* complete it, while detached sub-agents intentionally outlive the parent* turn and must remain owned by their run ledger.*/- cancelUnresolvedTurnTimeline: (state, action: PayloadAction<{ threadId: string }>) => {- const { threadId } = action.payload;+ cancelUnresolvedTurnTimeline: (+ state,+ action: PayloadAction<{ threadId: string; rowIds?: string[] }>+ ) => {+ const { threadId, rowIds } = action.payload;const entries = state.toolTimelineByThread[threadId];if (!entries) return;- state.toolTimelineByThread[threadId] = entries.map(settleOrphanedTimelineEntry);+ const eligible = rowIds && new Set(rowIds);+ state.toolTimelineByThread[threadId] = entries.map(entry =>+ !eligible || eligible.has(entry.id) ? settleOrphanedTimelineEntry(entry) : entry+ );},/*** Append a streamed `subagent_text_delta` / `subagent_thinking_delta`diff --git a/crates/openhuman-core/src/threads/transcript_view/project.rs b/crates/openhuman-core/src/threads/transcript_view/project.rsindex ac863c3fb1..3aa9924a3d 100644--- a/crates/openhuman-core/src/threads/transcript_view/project.rs+++ b/crates/openhuman-core/src/threads/transcript_view/project.rs@@ -189,6 +189,7 @@ impl Projector {});self.last_request_id = Some(rid.to_string());self.step = 0;+ self.seen_call_ids.clear();}}@@ -211,6 +212,7 @@ impl Projector {// A legacy turn without request ids still restarts the step// count at its prompt.self.step = 0;+ self.seen_call_ids.clear();let raw = msg.message.content.clone();let sanitized = sanitize_user_content(&raw);if sanitized.is_some() {