From ceafe4580d4b57c0011504d6b4916013b4124650 Mon Sep 17 00:00:00 2001 From: Khaled Mansour Date: Mon, 6 Jul 2026 21:18:58 -0400 Subject: [PATCH] feat(runtime-core): env-override the native sidecar frame timeout NATIVE_SIDECAR_FRAME_TIMEOUT_MS is hardcoded to 120_000 and is the value both sidecar spawn sites pass as `frameTimeoutMs`. A single long-running host request maps to one protocol frame, so workloads with legitimately long turns (an agent turn with many tool calls, media generation, etc.) exceed 120s and get killed mid-turn with "timed out waiting for sidecar protocol frame". There is currently no way to raise it without editing the source. Make the const resolve from AGENTOS_SIDECAR_FRAME_TIMEOUT_MS (validated: finite, positive), falling back to 120_000. The native sidecar is process-global (spawned once and multiplexed), so an env override is the right surface rather than a per-AgentOs.create option. Behavior is unchanged when the env var is unset. --- packages/runtime-core/src/sidecar-process.ts | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/sidecar-process.ts b/packages/runtime-core/src/sidecar-process.ts index 08b18cefb..5e10425a1 100644 --- a/packages/runtime-core/src/sidecar-process.ts +++ b/packages/runtime-core/src/sidecar-process.ts @@ -56,7 +56,27 @@ export { SidecarProcess as Sidecar }; const BRIDGE_CONTRACT_VERSION = 1; -export const NATIVE_SIDECAR_FRAME_TIMEOUT_MS = 120_000; +const DEFAULT_NATIVE_SIDECAR_FRAME_TIMEOUT_MS = 120_000; + +// Per-frame timeout for the native sidecar protocol: how long the host waits for +// a sidecar response frame before treating the sidecar as unresponsive. A single +// long host request maps to one frame, so workloads with legitimately long turns +// (an agent turn with many tool calls, media generation, etc.) can exceed the +// default and be killed mid-turn with "timed out waiting for sidecar protocol +// frame". The native sidecar is process-global (spawned once and multiplexed), +// so this is an env override rather than a per-instance option. +function resolveNativeSidecarFrameTimeoutMs(): number { + const raw = process.env.AGENTOS_SIDECAR_FRAME_TIMEOUT_MS; + if (raw !== undefined) { + const parsed = Number(raw); + if (Number.isFinite(parsed) && parsed > 0) { + return parsed; + } + } + return DEFAULT_NATIVE_SIDECAR_FRAME_TIMEOUT_MS; +} + +export const NATIVE_SIDECAR_FRAME_TIMEOUT_MS = resolveNativeSidecarFrameTimeoutMs(); const DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY = 4_096; const DEFAULT_SIDECAR_GRACEFUL_EXIT_MS = 5_000; const DEFAULT_SIDECAR_FORCE_EXIT_MS = 2_000;