The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): let bot_relay.deliver outlive the generic 30s request deadline
Max Hsu10f1c3076855
diff --git a/apps/desktop/src/plugins/hermes-bots/relay.ts b/apps/desktop/src/plugins/hermes-bots/relay.tsindex 47ac5aa4d8c..a529aa2979e 100644--- a/apps/desktop/src/plugins/hermes-bots/relay.ts+++ b/apps/desktop/src/plugins/hermes-bots/relay.ts@@ -33,6 +33,13 @@ const RELAY_ROSTER_INTERVAL_MS = 60_000// poll WAS the delivery path, which (before route retention) also meant a// fresh WebSocket dial + teardown per registered connection every 4s.const RELAY_DRAIN_INTERVAL_MS = 30_000+// #93911: a delivered turn runs on the target gateway, so the client must+// outlive the backend's own bound — worst case is the turn lock wait+// (bot_mode.turn_wait_seconds, default 120s) plus a 600s turn, doubled when+// the retry policy grants one bounded re-run (methods_bot_relay.py). Without+// this the call fell to the pool's generic 30s deadline and every long turn+// (Computer Use, deep research) came back as an unclassified failure.+const RELAY_DELIVER_TIMEOUT_MS = 1_320_000// Push path (#93091): the gateway broadcasts `bot_relay.outbox.pending` when// an envelope lands on disk; a burst of signals inside this window collapses// to ONE drain. The interval poll above stays as the backstop for older@@ -365,10 +372,15 @@ async function drainRelayOutboxes() {const attentionKey = `${target.id}::${String(envelope?.target_profile || '')}`try {- const res = await host.requestProfile<{ reply?: string }>(target.route, 'bot_relay.deliver', {- profile: String(envelope?.target_profile || ''),- message: String(envelope?.message || '')- })+ const res = await host.requestProfile<{ reply?: string }>(+ target.route,+ 'bot_relay.deliver',+ {+ profile: String(envelope?.target_profile || ''),+ message: String(envelope?.message || '')+ },+ RELAY_DELIVER_TIMEOUT_MS+ )clearBotAttention(attentionKey)await postReply({diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.tsindex ac05825fc72..12cbac2d102 100644--- a/apps/desktop/src/sdk/index.ts+++ b/apps/desktop/src/sdk/index.ts@@ -231,20 +231,26 @@ const $viewport = atom<ViewportRect>(readViewport())async function requestPluginProfile<T>(route: PluginProfileRoute | string,method: string,- params: Record<string, unknown>+ params: Record<string, unknown>,+ timeoutMs?: number): Promise<T> {if (typeof route !== 'string') {if (!route.connectionId.trim() || !route.profile.trim() || !route.targetProfile.trim()) {throw new Error('Profile route must include connectionId, profile, and targetProfile')}- return requestGatewayForAgent<T>(route.connectionId, route.profile, method, params)+ // Omit the bound entirely when unset so callers stay on the pool default.+ return timeoutMs === undefined+ ? requestGatewayForAgent<T>(route.connectionId, route.profile, method, params)+ : requestGatewayForAgent<T>(route.connectionId, route.profile, method, params, timeoutMs)}const getAgentRoster = window.hermesDesktop?.getAgentRosterif (!getAgentRoster) {- return requestGatewayForProfile<T>(route, method, params)+ return timeoutMs === undefined+ ? requestGatewayForProfile<T>(route, method, params)+ : requestGatewayForProfile<T>(route, method, params, timeoutMs)}const roster = await getAgentRoster()@@ -256,7 +262,9 @@ async function requestPluginProfile<T>(// its live enumeration transiently failed. Any additional source requires a// descriptor because an undialed/unreachable source may expose the same name.if (soleLocalSource) {- return requestGatewayForProfile<T>(profile, method, params)+ return timeoutMs === undefined+ ? requestGatewayForProfile<T>(profile, method, params)+ : requestGatewayForProfile<T>(profile, method, params, timeoutMs)}throw new Error(@@ -1247,12 +1255,18 @@ export const host = {/** Gateway JSON-RPC through a credential-free route descriptor without* foregrounding it. Passing a bare profile is the v1/local compatibility* overload; registry callers must pass the descriptor so duplicate names- * remain unambiguous. */+ * remain unambiguous.+ *+ * `timeoutMs` opts one call out of the pool's generic deadline (#93911: a+ * method whose backend contract is minutes long, such as `bot_relay.deliver`,+ * otherwise dies at 30s and reports an unclassified failure). Leave it unset+ * to keep the default. */requestProfile: async <T>(route: PluginProfileRoute | string,method: string,- params: Record<string, unknown> = {}- ): Promise<T> => requestPluginProfile<T>(route, method, params),+ params: Record<string, unknown> = {},+ timeoutMs?: number+ ): Promise<T> => requestPluginProfile<T>(route, method, params, timeoutMs),/** Pin a route's pooled gateway socket open across repeated `requestProfile`* calls (#93594: the bot-relay drain loop was dialing and tearing down adiff --git a/apps/desktop/src/sdk/profile-routing.test.ts b/apps/desktop/src/sdk/profile-routing.test.tsindex 07f670b9100..c61127f5f67 100644--- a/apps/desktop/src/sdk/profile-routing.test.ts+++ b/apps/desktop/src/sdk/profile-routing.test.ts@@ -339,6 +339,42 @@ describe('connection-aware plugin host APIs', () => {expect(requestGatewayForProfile).not.toHaveBeenCalled()})+ it('forwards an explicit timeout so long-running methods outlive the generic deadline', async () => {+ // #93911: bot_relay.deliver's backend contract tolerates ~1320s (120s turn+ // lock + a 600s turn, doubled by the bounded retry). Without a way to pass+ // that bound through, every such call died at the pool's generic 30s+ // deadline and surfaced as an unclassified failure.+ const route = {+ connectionId: 'source-a',+ mode: 'remote' as const,+ profile: 'remote-worker',+ targetProfile: 'backend-worker'+ }++ await host.requestProfile(route, 'bot_relay.deliver', { message: 'hi', profile: 'backend-worker' }, 1_320_000)++ expect(requestGatewayForAgent).toHaveBeenCalledWith(+ 'source-a',+ 'remote-worker',+ 'bot_relay.deliver',+ { message: 'hi', profile: 'backend-worker' },+ 1_320_000+ )+ })++ it('leaves callers that pass no timeout on the pool default', async () => {+ const route = {+ connectionId: 'source-a',+ mode: 'remote' as const,+ profile: 'remote-worker',+ targetProfile: 'backend-worker'+ }++ await host.requestProfile(route, 'profiles.list', {})++ expect(requestGatewayForAgent).toHaveBeenCalledWith('source-a', 'remote-worker', 'profiles.list', {})+ })+it('fails closed when a descriptor omits connection or target profile identity', async () => {await expect(host.requestProfile(