[3/3] app-server: configure environment connection timeout (#29025)

## Why

Remote environments registered through `environment/add` currently use
the fixed 10-second WebSocket connection timeout. Slow-starting
executors need a caller-selected connection window, but this should not
add retry policy or couple exec-server behavior to Core’s
`deferred_executor` feature.

Make the timeout an optional part of the existing experimental request.
Existing clients continue using the current default, while callers that
know an executor may take longer can request a larger window explicitly.

Depends on #28683.

## What changed

- Add optional `connectTimeoutMs` to `EnvironmentAddParams` and document
it in the app-server README.
- Pass the optional timeout through `EnvironmentRequestProcessor` into
one `EnvironmentManager::upsert_environment()` path; the manager applies
the existing default when it is omitted.
- Preserve the existing single-attempt lifecycle. The configured value
controls WebSocket connection and handshake time for both initial
connection and later reconnects; initialization retains its separate
timeout.
- Add an app-server integration test that sends the real JSON-RPC
request and verifies a stalled handshake observes the requested timeout.

## Test plan

- `just test -p codex-app-server-protocol`
- `just test -p codex-exec-server`
- `just test -p codex-app-server
environment_add_applies_connect_timeout`

## Rollout

This is additive and does not enable `deferred_executor`. Callers should
send a non-default timeout only after a compatible app-server is
deployed; omitted or `null` values retain the existing 10-second
default.
This commit is contained in:
sayan-oai
2026-06-18 22:27:45 -07:00
committed by GitHub
Unverified
parent 45a133bae0
commit f886e33e5a
10 changed files with 110 additions and 13 deletions
@@ -2011,6 +2011,7 @@ mod tests {
params: v2::EnvironmentAddParams {
environment_id: "remote-a".to_string(),
exec_server_url: "ws://127.0.0.1:8765".to_string(),
connect_timeout_ms: None,
},
};
assert_eq!(
@@ -2958,6 +2959,7 @@ mod tests {
params: v2::EnvironmentAddParams {
environment_id: "remote-a".to_string(),
exec_server_url: "ws://127.0.0.1:8765".to_string(),
connect_timeout_ms: Some(300_000),
},
};
assert_eq!(
@@ -2966,7 +2968,8 @@ mod tests {
"id": 9,
"params": {
"environmentId": "remote-a",
"execServerUrl": "ws://127.0.0.1:8765"
"execServerUrl": "ws://127.0.0.1:8765",
"connectTimeoutMs": 300000
}
}),
serde_json::to_value(&request)?,
@@ -3392,6 +3395,7 @@ mod tests {
params: v2::EnvironmentAddParams {
environment_id: "remote-a".to_string(),
exec_server_url: "ws://127.0.0.1:8765".to_string(),
connect_timeout_ms: None,
},
};
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);