fix(codex): cap approval gateway timeouts · openclaw/openclaw@032945a
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
File tree
extensions/codex/src/app-server
| Original file line number | Diff line number | Diff line change |
|---|
@@ -7,6 +7,7 @@ import {
|
7 | 7 | CODEX_TURN_COMPLETION_IDLE_TIMEOUT_MS, |
8 | 8 | CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS, |
9 | 9 | resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs, |
| 10 | +resolveCodexGatewayTimeoutWithGraceMs, |
10 | 11 | resolveCodexStartupTimeoutMs, |
11 | 12 | resolveCodexTurnAssistantCompletionIdleTimeoutMs, |
12 | 13 | resolveCodexTurnCompletionIdleTimeoutMs, |
@@ -110,6 +111,17 @@ describe("Codex app-server attempt timeouts", () => {
|
110 | 111 | ); |
111 | 112 | }); |
112 | 113 | |
| 114 | +it("caps gateway timeout grace", () => { |
| 115 | +expect(resolveCodexGatewayTimeoutWithGraceMs(120_000)).toBe(130_000); |
| 116 | +expect(resolveCodexGatewayTimeoutWithGraceMs(120_000, 500)).toBe(120_500); |
| 117 | +expect(resolveCodexGatewayTimeoutWithGraceMs(Number.MAX_SAFE_INTEGER)).toBe( |
| 118 | +MAX_TIMER_TIMEOUT_MS, |
| 119 | +); |
| 120 | +expect(resolveCodexGatewayTimeoutWithGraceMs(MAX_TIMER_TIMEOUT_MS - 100, 500)).toBe( |
| 121 | +MAX_TIMER_TIMEOUT_MS, |
| 122 | +); |
| 123 | +}); |
| 124 | + |
113 | 125 | it("returns the startup operation result before timeout", async () => { |
114 | 126 | await expect( |
115 | 127 | withCodexStartupTimeout({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -104,3 +104,9 @@ export function resolveCodexPostToolRawAssistantCompletionIdleTimeoutMs(
|
104 | 104 | export function resolveCodexTurnTerminalIdleTimeoutMs(value: number | undefined): number { |
105 | 105 | return resolvePositiveIntegerTimeoutMs(value, CODEX_TURN_TERMINAL_IDLE_TIMEOUT_MS); |
106 | 106 | } |
| 107 | + |
| 108 | +export function resolveCodexGatewayTimeoutWithGraceMs(timeoutMs: number, graceMs = 10_000): number { |
| 109 | +const timeout = resolvePositiveIntegerTimeoutMs(timeoutMs, 1); |
| 110 | +const grace = resolveTimerTimeoutMs(graceMs, 0, 0); |
| 111 | +return resolveTimerTimeoutMs(timeout + grace, timeout); |
| 112 | +} |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ import {
|
2 | 2 | callGatewayTool, |
3 | 3 | type EmbeddedRunAttemptParams, |
4 | 4 | } from "openclaw/plugin-sdk/agent-harness-runtime"; |
| 5 | +import { resolveCodexGatewayTimeoutWithGraceMs } from "./attempt-timeouts.js"; |
5 | 6 | |
6 | 7 | const DEFAULT_CODEX_APPROVAL_TIMEOUT_MS = 120_000; |
7 | 8 | const MAX_PLUGIN_APPROVAL_TITLE_LENGTH = 80; |
@@ -37,7 +38,7 @@ export async function requestPluginApproval(params: {
|
37 | 38 | const timeoutMs = DEFAULT_CODEX_APPROVAL_TIMEOUT_MS; |
38 | 39 | return callGatewayTool( |
39 | 40 | "plugin.approval.request", |
40 | | -{ timeoutMs: timeoutMs + 10_000 }, |
| 41 | +{ timeoutMs: resolveCodexGatewayTimeoutWithGraceMs(timeoutMs) }, |
41 | 42 | { |
42 | 43 | pluginId: "openclaw-codex-app-server", |
43 | 44 | title: truncateForGateway(params.title, MAX_PLUGIN_APPROVAL_TITLE_LENGTH), |
@@ -78,7 +79,7 @@ export async function waitForPluginApprovalDecision(params: {
|
78 | 79 | const timeoutMs = DEFAULT_CODEX_APPROVAL_TIMEOUT_MS; |
79 | 80 | const waitPromise: Promise<ApprovalWaitResult | undefined> = callGatewayTool( |
80 | 81 | "plugin.approval.waitDecision", |
81 | | -{ timeoutMs: timeoutMs + 10_000 }, |
| 82 | +{ timeoutMs: resolveCodexGatewayTimeoutWithGraceMs(timeoutMs) }, |
82 | 83 | { id: params.approvalId }, |
83 | 84 | ); |
84 | 85 | if (!params.signal) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。