Skip to content

Self-improving AI Employees for everyone

fix(ws): size the execute_node budget from the node's own declaration

trohitg1bf403ead8d2
diff --git a/client/src/contexts/WebSocketContext.tsx b/client/src/contexts/WebSocketContext.tsx
index d700abc9..058b2024 100644
--- a/client/src/contexts/WebSocketContext.tsx
+++ b/client/src/contexts/WebSocketContext.tsx
@@ -31,6 +31,10 @@ import {
} from '../types/cloudEvents';
import { WS_CLOSE, WS_RECONNECT } from '../lib/connectionConfig';
import { todoQueryKeyFromEvent } from '../lib/todoQuery';
+// Cycle note: lib/nodeSpec imports useWebSocket from this module. Safe in
+// both evaluation orders because neither side calls the other's binding at
+// module top level — `executionBudgetFor` only references it inside a body.
+import { getCachedNodeSpec } from '../lib/nodeSpec';
import {
useNodeStatusStore,
useNodeStatusForId,
@@ -71,16 +75,29 @@ export const WORKFLOW_CONTROL_REQUEST_TIMEOUT = 5 * 60 * 1000;
// Maximum queued sends before backpressure kicks in (FIFO eviction of oldest)
const QUEUE_MAX_SIZE = 200;
-// Trigger node types that wait indefinitely for events
-const TRIGGER_NODE_TYPES = ['whatsappReceive', 'webhookTrigger', 'cronScheduler', 'chatTrigger', 'telegramReceive'];
-
-// Agent node types that can run for minutes (no timeout)
-const LONG_RUNNING_NODE_TYPES = [
- 'aiAgent', 'chatAgent', 'rlm_agent',
- 'android_agent', 'coding_agent', 'web_agent', 'task_agent', 'social_agent',
- 'travel_agent', 'tool_agent', 'productivity_agent', 'payments_agent', 'consumer_agent',
- 'autonomous_agent', 'orchestrator_agent', 'ai_employee',
-];
+/**
+ * How long to let an `execute_node` request stay in flight.
+ *
+ * Read from the node's own spec rather than a local list. The two hardcoded
+ * arrays this replaced had drifted to 5-of-10 triggers and 16-of-21 agents,
+ * so eight node types — emailReceive, googleGmailReceive, stripeReceive,
+ * taskTrigger, twitterReceive, claude_code_agent, codex_agent,
+ * vertex_managed_agent — hit the 30 s default and produced a phantom
+ * "Request timeout: execute_node" entry while the backend kept running.
+ *
+ * Spec unknown (cold cache, or the revision-bust window in nodeSpec.ts)
+ * falls back to a FINITE 5 minutes, never to "no timeout": an unsettleable
+ * promise leaves the Run spinner stuck with no error until a reconnect,
+ * whereas a rejection is visible and retryable. It must not fall back to the
+ * 30 s default either — that is the value that was cutting healthy triggers
+ * off in the first place.
+ */
+const executionBudgetFor = (nodeType: string): number => {
+ const declared = getCachedNodeSpec(nodeType)?.uiHints?.executionTimeoutMs;
+ return typeof declared === 'number' && declared > 0
+ ? declared
+ : WORKFLOW_CONTROL_REQUEST_TIMEOUT;
+};
// Status types
export interface AndroidStatus {
@@ -2546,9 +2563,12 @@ export const WebSocketProvider: React.FC<{ children: React.ReactNode }> = ({ chi
edges?: any[]
): Promise<any> => {
try {
- // Trigger nodes and long-running agents wait indefinitely - no timeout
- const noTimeout = TRIGGER_NODE_TYPES.includes(nodeType) || LONG_RUNNING_NODE_TYPES.includes(nodeType);
- const timeoutMs = noTimeout ? -1 : undefined; // -1 = no timeout
+ // The request budget is the node's OWN declared execution budget,
+ // served on its spec as `uiHints.executionTimeoutMs` (the backend's
+ // BaseNode.start_to_close_timeout). Matching it exactly is the point:
+ // waiting longer than the server will run the activity is pointless,
+ // and waiting less produces the phantom failure this replaced.
+ const timeoutMs = executionBudgetFor(nodeType);
const response = await sendRequest<any>('execute_node', {
node_id: nodeId,
diff --git a/client/src/types/INodeProperties.ts b/client/src/types/INodeProperties.ts
index 8d15b751..5b0ba74f 100644
--- a/client/src/types/INodeProperties.ts
+++ b/client/src/types/INodeProperties.ts
@@ -233,6 +233,15 @@ export interface INodeUIHints {
* the backend's `test_ui_hints_only_carry_known_flags` — that
* invariant checks flag *names*, not values. */
outputMode?: 'terminal' | 'audio';
+ /** How long this node may legitimately run, in milliseconds — the backend's
+ * own `BaseNode.start_to_close_timeout`, serialized. The WebSocket layer
+ * sizes its request budget from this instead of keeping a list of "slow"
+ * node types, which had drifted to 5-of-10 triggers and 16-of-21 agents.
+ *
+ * Read it off the RAW spec (`getCachedNodeSpec`), never through
+ * `resolveNodeDescription` — the adapter drops uiHints' siblings and this
+ * value must match what the server will actually allow. */
+ executionTimeoutMs?: number;
}
export interface INodeTypeDescription {
diff --git a/server/nodes/scheduler/cron_scheduler/__init__.py b/server/nodes/scheduler/cron_scheduler/__init__.py
index b70bf820..4eb2cff6 100644
--- a/server/nodes/scheduler/cron_scheduler/__init__.py
+++ b/server/nodes/scheduler/cron_scheduler/__init__.py
@@ -33,6 +33,7 @@ from temporalio.plugin import SimplePlugin
from core.logging import get_logger
from services.deployment.canary_registry import register_canary_trigger_type
from services.plugin import ActionNode, NodeContext, Operation, TaskQueue
+from services.plugin.scaling import TRIGGER_START_TO_CLOSE
from services.temporal.plugin_registry import register_temporal_plugin
from ._workflow import CronTriggerWorkflow
@@ -251,6 +252,12 @@ class CronSchedulerNode(ActionNode):
handles = ({"name": "output-main", "kind": "output", "position": "right", "label": "Output", "role": "main"},)
annotations = {"destructive": False, "readonly": True, "open_world": False}
task_queue = TaskQueue.TRIGGERS_POLL
+ # This node sleeps until the next tick (see `trigger` below), and the
+ # frequency options go up to monthly — so the ActionNode default of ten
+ # minutes was simply untrue, and would truncate any interval longer than
+ # that. It declares the same budget as a TriggerNode because it behaves
+ # like one; it only extends ActionNode to reuse the operation plumbing.
+ start_to_close_timeout = TRIGGER_START_TO_CLOSE
usable_as_tool = True
Params = CronSchedulerParams
diff --git a/server/services/plugin/base.py b/server/services/plugin/base.py
index d1ae8612..9c591722 100644
--- a/server/services/plugin/base.py
+++ b/server/services/plugin/base.py
@@ -312,6 +312,23 @@ class BaseNode:
meta["visibility"] = cls.visibility
ui_hints = _derive_auto_ui_hints(cls.group)
ui_hints.update(cls.ui_hints)
+ # How long this node may legitimately run, so the client can size its
+ # request budget instead of keeping its own list of "slow" node types.
+ #
+ # This is the ONLY honest signal for it. ``componentKind`` is a
+ # rendering key -- socialSend/socialReceive declare "agent" purely to
+ # get the multi-handle layout while being plain ActionNodes -- and
+ # ``group`` disagrees the other way (vertex_agent_admin is group
+ # "agent" but a REST-API square). The declared timeout is exactly the
+ # 19 genuinely long-running nodes, with no heuristic.
+ #
+ # Rides uiHints deliberately: ``node_spec.get_node_spec`` copies a
+ # fixed tuple of top-level keys, so a new top-level field would need a
+ # second edit there to reach the wire.
+ ui_hints.setdefault(
+ "executionTimeoutMs",
+ int(cls.start_to_close_timeout.total_seconds() * 1000),
+ )
if ui_hints:
meta["uiHints"] = ui_hints
return meta
diff --git a/server/tests/test_node_spec.py b/server/tests/test_node_spec.py
index cae627c3..d358146b 100644
--- a/server/tests/test_node_spec.py
+++ b/server/tests/test_node_spec.py
@@ -931,6 +931,10 @@ class TestNodeSpecContractInvariants:
"isProcessManagerPanel",
# gallery: workspace file browser with drag-to-parameter.
"isGalleryPanel",
+ # Auto-derived on every node from BaseNode.start_to_close_timeout:
+ # how long it may legitimately run. Lets the client size its
+ # request budget instead of keeping its own list of slow types.
+ "executionTimeoutMs",
"showLocationPanel",
"isAndroidToolkit",
"isChatTrigger",