Skip to content

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

fix(chat): handle missing runtime state on reconnect

Steven Enamakel2764c7c55251
diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsx
index f4a989bd04..405cebf845 100644
--- a/app/src/providers/ChatRuntimeProvider.tsx
+++ b/app/src/providers/ChatRuntimeProvider.tsx
@@ -697,6 +697,11 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
success: event.success,
output: event.output,
failure: event.failure,
+ args: event.args,
+ elapsedMs: event.elapsed_ms,
+ structured: event.structured,
+ displayLabel: event.tool_display_label,
+ displayDetail: event.tool_display_detail,
})
);
diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.ts
index 84665acd35..d11557c1d0 100644
--- a/app/src/services/chatService.ts
+++ b/app/src/services/chatService.ts
@@ -59,6 +59,18 @@ export interface ChatToolResultEvent {
* `parseToolFailure` before it reaches the store.
*/
failure?: unknown;
+ /** The call's arguments. The start event may carry none; this is the fallback. */
+ args?: unknown;
+ /** Wall time the call took. */
+ elapsed_ms?: number;
+ /**
+ * Machine-readable result, when the tool produced one (the tool's
+ * `ToolResult.metadata`), e.g. `{ kind: "web_search", results: [...] }`.
+ */
+ structured?: unknown;
+ /** Label / detail recomputed by the core with the call's real arguments. */
+ tool_display_label?: string;
+ tool_display_detail?: string;
}
/** One sub-agent's token/cost contribution within a turn (hover breakdown). */
diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.ts
index f155df6be8..c7468ee182 100644
--- a/app/src/store/chatRuntimeSlice.ts
+++ b/app/src/store/chatRuntimeSlice.ts
@@ -285,6 +285,37 @@ export function parseToolFailure(raw: unknown): ToolFailureExplanation | undefin
};
}
+/**
+ * Fold the optional completion fields of a `tool_result` into its row.
+ *
+ * The core's start event may carry no arguments (the harness reports them at
+ * completion), so `args` backfills an empty `argsBuffer`; without it a row
+ * could never show its target. A recomputed server label replaces the one
+ * sent at start, which was derived without arguments.
+ */
+function applyResultExtras(
+ entry: ToolTimelineEntry,
+ extras: {
+ args?: unknown;
+ elapsedMs?: number;
+ structured?: unknown;
+ displayLabel?: string;
+ displayDetail?: string;
+ }
+): void {
+ if (!entry.argsBuffer && extras.args && typeof extras.args === 'object') {
+ entry.argsBuffer = JSON.stringify(extras.args);
+ }
+ if (typeof extras.elapsedMs === 'number' && Number.isFinite(extras.elapsedMs)) {
+ entry.elapsedMs = extras.elapsedMs;
+ }
+ if (extras.structured && typeof extras.structured === 'object') {
+ entry.structured = extras.structured;
+ }
+ if (extras.displayLabel?.trim()) entry.displayName = extras.displayLabel.trim();
+ if (extras.displayDetail?.trim()) entry.detail = extras.displayDetail.trim();
+}
+
/**
* Attach a human label/detail to a tool-timeline row. The server supplies a
* label/detail for dynamic Composio/MCP/integration tools the client can't know
@@ -293,11 +324,15 @@ export function parseToolFailure(raw: unknown): ToolFailureExplanation | undefin
* caller that materialises a row.
*/
function decorateEntry(entry: ToolTimelineEntry): ToolTimelineEntry {
+ // `displayName` holds only what the server said. Baking the client title in
+ // here froze its tense at call time, so a finished row kept reading
+ // "Reading file"; every surface now resolves the title at render time.
const formatted = formatTimelineEntry(entry);
if (entry.displayName && !isKnownClientTool(entry.name)) {
- return { ...entry, displayName: entry.displayName, detail: entry.detail ?? formatted.detail };
+ return { ...entry, detail: entry.detail ?? formatted.detail };
}
- return { ...entry, displayName: formatted.title, detail: formatted.detail ?? entry.detail };
+ const { displayName: _serverLabel, ...rest } = entry;
+ return { ...rest, detail: entry.detail ?? formatted.detail };
}
/**
@@ -1365,6 +1400,11 @@ const chatRuntimeSlice = createSlice({
success: boolean;
output?: string;
failure?: unknown;
+ args?: unknown;
+ elapsedMs?: number;
+ structured?: unknown;
+ displayLabel?: string;
+ displayDetail?: string;
}>
) => {
const { threadId, round, toolName, success, output, failure } = action.payload;
@@ -1381,12 +1421,16 @@ const chatRuntimeSlice = createSlice({
// The core forwards the (size-capped) tool result text on `output`; accept
// only non-empty payloads so a stub-less row stays `undefined`.
const result = output && output.length > 0 ? output : undefined;
+ const settle = (entry: ToolTimelineEntry) => {
+ entry.status = status;
+ entry.failure = parsedFailure;
+ entry.result = result;
+ applyResultExtras(entry, action.payload);
+ };
if (toolCallId) {
const entry = entries.find(e => e.id === toolCallId);
if (entry) {
- entry.status = status;
- entry.failure = parsedFailure;
- entry.result = result;
+ settle(entry);
return;
}
}
@@ -1400,9 +1444,7 @@ const chatRuntimeSlice = createSlice({
for (let i = 0; i < entries.length; i += 1) {
const entry = entries[i];
if (entry.status === 'running' && entry.name === toolName && entry.round === round) {
- entry.status = status;
- entry.failure = parsedFailure;
- entry.result = result;
+ settle(entry);
return;
}
}