-
Notifications
You must be signed in to change notification settings - Fork 25
Invalidate Codex model listing after CLI update #945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,15 +176,24 @@ async function installProviderCliOnHost( | |
| const env = providerCliEnvFromShellEnv( | ||
| options.runtimeManager.getShellEnv(), | ||
| ); | ||
| return { | ||
| events: await readProviderCliInstallEvents( | ||
| streamProviderCliInstall({ | ||
| provider: command.provider, | ||
| actionKind: command.actionKind, | ||
| env, | ||
| }), | ||
| ), | ||
| }; | ||
| const streamInstall = | ||
| options.streamProviderCliInstall ?? streamProviderCliInstall; | ||
| const events = await readProviderCliInstallEvents( | ||
| streamInstall({ | ||
| provider: command.provider, | ||
| actionKind: command.actionKind, | ||
| env, | ||
| }), | ||
| ); | ||
| if ( | ||
| shouldInvalidateProviderMaintenanceRuntimeAfterProviderCliInstall({ | ||
| command, | ||
| events, | ||
| }) | ||
| ) { | ||
| await options.runtimeManager.invalidateProviderMaintenanceRuntime(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 This runtime also serves Add a runtime lease. Alternatively, mark the runtime stale and wait for current calls before shutdown. |
||
| } | ||
| return { events }; | ||
| } catch (error) { | ||
| if (error instanceof ProviderCliInstallInProgressError) { | ||
| return { | ||
|
|
@@ -201,6 +210,23 @@ async function installProviderCliOnHost( | |
| } | ||
| } | ||
|
|
||
| function shouldInvalidateProviderMaintenanceRuntimeAfterProviderCliInstall(args: { | ||
| command: CommandOf<"provider_cli.install">; | ||
| events: readonly ProviderCliInstallEvent[]; | ||
| }): boolean { | ||
| return ( | ||
| // Codex model listing goes through the resident provider-maintenance | ||
| // app-server, so a Codex CLI update can leave a stale model catalog alive. | ||
| args.command.provider === "codex" && | ||
| args.events.some( | ||
| (event) => | ||
| event.type === "completed" && | ||
| event.provider === args.command.provider && | ||
| event.success, | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| const commandHandlers: CommandHandlerMap = { | ||
| "thread.start": async (command, options) => { | ||
| const release = options.runtimeManager.retainEnvironmentForThreadCommand( | ||
|
|
@@ -302,15 +328,17 @@ const commandHandlers: CommandHandlerMap = { | |
| return {}; | ||
| }, | ||
| "thread.unarchive": async (command, options) => { | ||
| const runtime = | ||
| await options.runtimeManager.ensureProviderMaintenanceRuntime({ | ||
| await options.runtimeManager.withProviderMaintenanceRuntime( | ||
| { | ||
| dataDir: options.dataDir, | ||
| }); | ||
| await runtime.unarchiveThread({ | ||
| threadId: command.threadId, | ||
| providerId: command.providerId, | ||
| providerThreadId: command.providerThreadId, | ||
| }); | ||
| }, | ||
| (runtime) => | ||
| runtime.unarchiveThread({ | ||
| threadId: command.threadId, | ||
| providerId: command.providerId, | ||
| providerThreadId: command.providerThreadId, | ||
| }), | ||
| ); | ||
| return {}; | ||
| }, | ||
| "interactive.resolve": resolveInteractiveRequest, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨
slopcop/review— Test the negative branchesThis test covers only a successful Codex event. The predicate also contains failure and non-Codex branches.
Add cases that confirm those events do not shut down the runtime.