@@ -125,10 +125,9 @@ const CODEX_CATALOG_REFRESH_TIMEOUT_MS = 3_000;
125125const CODEX_CONFIG_PROBE_TIMEOUT_MS = 3_000 ;
126126const CODEX_CATALOG_REFRESH_POLL = "100 millis" as const ;
127127const CODEX_CLIENT_NAME = "T3 Code" ;
128- // Old machines can take ~25s to start app-server and answer initialize.
128+ // Old machines can take ~25s to start app-server and answer initialize, before
129+ // account/models/skills discovery runs.
129130export const CODEX_APP_SERVER_PROBE_TIMEOUT_MS = 60_000 ;
130- // Account/models/skills requests after initialize can exceed the shared 10s probe budget.
131- const CODEX_DISCOVERY_BUDGET_MS = 20_000 ;
132131const CODEX_DISCOVERY_MARGIN_MS = 250 ;
133132// `codex-cli 0.159.0`, `codex-cli 0.160.0-alpha.1` or the npm CLI's bare `0.1.4161006`.
134133// Keep a prerelease suffix so compatibility stays unknown for it, as it does for `initialize`.
@@ -536,20 +535,6 @@ const readCodexModelsCacheFetchedAt = Effect.fn("readCodexModelsCacheFetchedAt")
536535 ) ;
537536} ) ;
538537
539- // Discovery gets its own budget from `initialize`, so a slow start still lists models, and must
540- // finish before the outer timeout can discard the account result. A raised probe timeout extends it.
541- export const codexDiscoveryDeadlineMs = (
542- spawnedAtMs : number ,
543- initializedAtMs : number ,
544- probeTimeoutMs : number ,
545- ) =>
546- Math . min (
547- spawnedAtMs + probeTimeoutMs ,
548- initializedAtMs +
549- CODEX_DISCOVERY_BUDGET_MS +
550- Math . max ( 0 , probeTimeoutMs - CODEX_APP_SERVER_PROBE_TIMEOUT_MS ) ,
551- ) - CODEX_DISCOVERY_MARGIN_MS ;
552-
553538const withCodexDiscoveryDeadline = Effect . fnUntraced ( function * < A , E , R > (
554539 effect : Effect . Effect < A , E , R > ,
555540 deadlineMs : number ,
@@ -714,7 +699,6 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
714699} ) {
715700 const spawnedAtMs = DateTime . toEpochMillis ( yield * DateTime . now ) ;
716701 const { client, initialize } = yield * withCodexAppServerClient ( input ) ;
717- const initializedAtMs = DateTime . toEpochMillis ( yield * DateTime . now ) ;
718702
719703 const versionMatch = initialize . userAgent . match ( / \/ ( [ ^ \s ] + ) / ) ;
720704 const version = versionMatch ? versionMatch [ 1 ] : undefined ;
@@ -729,7 +713,8 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
729713 } satisfies CodexAppServerProviderSnapshot ;
730714 }
731715
732- const deadlineMs = codexDiscoveryDeadlineMs ( spawnedAtMs , initializedAtMs , input . probeTimeoutMs ) ;
716+ // Optional discovery must finish before the outer timeout can discard the account result.
717+ const deadlineMs = spawnedAtMs + input . probeTimeoutMs - CODEX_DISCOVERY_MARGIN_MS ;
733718 const [ skillsResponse , models , { config, nativeUsage, rateLimits } ] = yield * Effect . all (
734719 [
735720 withCodexDiscoveryDeadline ( client . request ( "skills/list" , { cwds : [ input . cwd ] } ) , deadlineMs ) ,
0 commit comments