Skip to content

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

fix(assistant): prevent crash when pausing agent with no active capability

Steven Enamakelb2ada9b9c12b
diff --git a/app/src/providers/assistantUiMessages.ts b/app/src/providers/assistantUiMessages.ts
index 64cc9fd88c..6ae1b9d002 100644
--- a/app/src/providers/assistantUiMessages.ts
+++ b/app/src/providers/assistantUiMessages.ts
@@ -123,6 +123,41 @@ function toolResultPayload(entry: ToolTimelineEntry): unknown {
};
}
+/**
+ * Presentation data that rides a tool part's `artifact`.
+ *
+ * assistant-ui's tool-call part has no slot for a display label, a duration
+ * or a structured result, and this adapter used to drop all three, so the
+ * chat card fell back to guessing a label from the tool name and arguments.
+ * `artifact` is the part's UI-only field, which is exactly this.
+ */
+export interface OpenHumanToolArtifact {
+ kind: 'openhuman-tool';
+ /** Server label, for dynamic tools the client registry cannot describe. */
+ displayName?: string;
+ detail?: string;
+ elapsedMs?: number;
+ structured?: unknown;
+}
+
+export function readOpenHumanToolArtifact(value: unknown): OpenHumanToolArtifact | undefined {
+ if (!value || typeof value !== 'object') return undefined;
+ return (value as { kind?: unknown }).kind === 'openhuman-tool'
+ ? (value as OpenHumanToolArtifact)
+ : undefined;
+}
+
+function toolArtifact(entry: ToolTimelineEntry): OpenHumanToolArtifact | undefined {
+ const artifact: OpenHumanToolArtifact = {
+ kind: 'openhuman-tool',
+ ...(entry.displayName ? { displayName: entry.displayName } : {}),
+ ...(entry.detail ? { detail: entry.detail } : {}),
+ ...(entry.elapsedMs !== undefined ? { elapsedMs: entry.elapsedMs } : {}),
+ ...(entry.structured !== undefined ? { structured: entry.structured } : {}),
+ };
+ return Object.keys(artifact).length > 1 ? artifact : undefined;
+}
+
function toolPart(entry: ToolTimelineEntry): ThreadAssistantMessagePart {
const running = isActiveTimelineStatus(entry.status);
const isSubagent = entry.name.startsWith('subagent:') || entry.subagent !== undefined;
@@ -140,6 +175,7 @@ function toolPart(entry: ToolTimelineEntry): ThreadAssistantMessagePart {
toolName: isSubagent ? 'task' : entry.name,
args,
argsText: JSON.stringify(args, null, 2),
+ ...(!isSubagent && toolArtifact(entry) ? { artifact: toolArtifact(entry) } : {}),
...(!running
? {
result: isSubagent
diff --git a/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs b/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs
index d5dfeb368b..6bd6db2726 100644
--- a/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/observability/cap_pauser.rs
@@ -39,17 +39,21 @@ pub(crate) type IterationCursor = Arc<AtomicU32>;
/// `tool_name` contract without the forwarder emitting those fragments itself.
pub(crate) type ToolNameMap = Arc<Mutex<std::collections::HashMap<String, String>>>;
-/// Shared `call_id → (success, classified failure, elapsed_ms, output_chars)`
-/// side-channel. The crate's `AgentEvent::ToolCompleted` carries only `call_id`
-/// + `tool_name` (no success/error, duration, or output size), so
+/// Shared `call_id → (success, classified failure, elapsed_ms, output_chars,
+/// structured metadata)` side-channel. The crate's `AgentEvent::ToolCompleted`
+/// carries only `call_id` + `tool_name` (no success/error, duration, output
+/// size, or `ToolResult.metadata`), so
///
/// `ToolOutcomeCaptureMiddleware::after_tool` — which does see the `ToolResult`
-/// (including the executor-measured `elapsed_ms` and the rendered content) —
-/// classifies each outcome and writes it here; the bridge reads it when
-/// projecting the live `ToolCallCompleted` event, so a failed tool surfaces real
-/// `success: false` + a user-facing `failure`, and a completed tool surfaces its
-/// real duration + output size instead of `0`/`0` (#4467, item 4). Absent entry
-/// (event projected before the middleware ran) falls back to `(true, None, 0, 0)`.
+/// (including the executor-measured `elapsed_ms`, the rendered content, and
+/// its host-only `metadata`) — classifies each outcome and writes it here; the
+/// bridge reads it when projecting the live `ToolCallCompleted` event, so a
+/// failed tool surfaces real `success: false` + a user-facing `failure`, a
+/// completed tool surfaces its real duration + output size instead of `0`/`0`
+/// (#4467, item 4), and a tool that populated `ToolResult.metadata` with a
+/// `{"kind": ...}` object (e.g. web search) surfaces it as
+/// `ToolCallCompleted::structured`. Absent entry (event projected before the
+/// middleware ran) falls back to `(true, None, 0, 0, None)`.
pub(crate) type ToolFailureMap = Arc<
Mutex<
std::collections::HashMap<
@@ -59,6 +63,7 @@ pub(crate) type ToolFailureMap = Arc<
Option<crate::tools::status::ClassifiedFailure>,
u64,
usize,
+ Option<serde_json::Value>,
),
>,
>,