The open-source agent harness - the runtime layer that turns an LLM into a working agent.
fix: fail Redis request-reply when the executor dies while waiting (#763)
Bhavesh Patelbf5233d6311f
diff --git a/.changeset/recheck-request-reply-heartbeat.md b/.changeset/recheck-request-reply-heartbeat.mdnew file mode 100644index 000000000..dffb41db2--- /dev/null+++ b/.changeset/recheck-request-reply-heartbeat.md@@ -0,0 +1,5 @@+---+"@truefoundry/trueforge-core": patch+---++Fail Redis request-reply waits when the executor heartbeat expires during polling instead of waiting until replyTimeoutMs.diff --git a/packages/trueforge-core/src/request-reply/client.ts b/packages/trueforge-core/src/request-reply/client.tsindex 213d4d76c..99d9fee5b 100644--- a/packages/trueforge-core/src/request-reply/client.ts+++ b/packages/trueforge-core/src/request-reply/client.ts@@ -38,8 +38,8 @@ async function getDelReply(redisClient: RedisClientType, rKey: string): Promise</*** Publishes the request (JSON) on the worker channel, then polls the reply key with GETDEL- * (see https://redis.io/docs/latest/commands/getdel/ ) until a result arrives or the wait- * budget is exceeded.+ * (see https://redis.io/docs/latest/commands/getdel/ ) until a result arrives, the executor+ * heartbeat expires, or the wait budget is exceeded.*/export async function redisRequest<T extends JSONValue>({redis: redisClient,@@ -82,6 +82,11 @@ export async function redisRequest<T extends JSONValue>({if (replyPayload) {return replyPayload;}+ // We already checked that the executor was alive before sending, but it may have+ // died while we wait. Recheck here so we fail soon instead of waiting until the timeout.+ if ((await redisClient.exists(aliveK)) === 0) {+ throw new NoResponderError(executorId);+ }if (performance.now() >= replyDeadline) {throw new RequestTimeoutError(replyTimeoutMs);}