Skip to content

Commit 6dfa4c2

Browse files
Glucksbergobviyus
authored andcommitted
fix(outbound): cap initial gateway send wait
1 parent f9eeedb commit 6dfa4c2

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/infra/outbound/message-action-runner.plugin-dispatch.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ describe("runMessageAction plugin dispatch", () => {
12451245
gateway: {
12461246
clientName: "cli",
12471247
mode: "cli",
1248-
timeoutMs: 30_000,
1248+
timeoutMs: 120_000,
12491249
},
12501250
dryRun: false,
12511251
} satisfies Parameters<typeof runMessageAction>[0];
@@ -1261,6 +1261,7 @@ describe("runMessageAction plugin dispatch", () => {
12611261
"second gateway least privilege call",
12621262
1,
12631263
);
1264+
expect(firstCall.timeoutMs).toBe(30_000);
12641265
expect(secondCall).toMatchObject({
12651266
...firstCall,
12661267
timeoutMs: null,

src/infra/outbound/message-action-runner.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ function resolveGatewayActionOptions(gateway?: MessageActionRunnerGateway) {
221221

222222
const MESSAGE_ACTION_RECONCILIATION_TIMEOUT_MS = 60_000;
223223
const MESSAGE_ACTION_RECONCILIATION_MAX_MS = 9 * 60_000;
224+
const MESSAGE_ACTION_INITIAL_SEND_TIMEOUT_MAX_MS = 30_000;
224225

225226
async function callGatewayMessageAction<T>(params: {
226227
gateway?: MessageActionRunnerGateway;
@@ -231,12 +232,18 @@ async function callGatewayMessageAction<T>(params: {
231232
await loadMessageActionGatewayRuntime();
232233
const gateway = resolveGatewayActionOptions(params.gateway);
233234
const agentRuntimeIdentityToken = await params.gateway?.resolveAgentRuntimeIdentityToken?.();
235+
// A timed-out send is reattached with the same idempotency key. Cap only the
236+
// initial wait so the 9-minute join remains inside Codex's 10-minute tool envelope.
237+
const timeoutMs =
238+
params.actionParams.action === "send"
239+
? Math.min(gateway.timeoutMs, MESSAGE_ACTION_INITIAL_SEND_TIMEOUT_MAX_MS)
240+
: gateway.timeoutMs;
234241
const call = {
235242
url: gateway.url,
236243
token: gateway.token,
237244
method: "message.action",
238245
params: params.actionParams,
239-
timeoutMs: gateway.timeoutMs,
246+
timeoutMs,
240247
signal: params.abortSignal,
241248
clientName: gateway.clientName,
242249
clientDisplayName: gateway.clientDisplayName,

0 commit comments

Comments
 (0)