-
Notifications
You must be signed in to change notification settings - Fork 4
feat: LLM-25394 support Codex persist approval #129
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
4936513
42e82c6
1f97ebe
9f1fbfd
08fec23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,7 @@ export interface SessionState { | |
| cwd: string; | ||
| fastModeEnabled: boolean; | ||
| currentModelSupportsFast: boolean; | ||
| sessionMcpServers?: Array<string>; | ||
| sessionMcpServers: Map<string, acp.McpServer>; | ||
|
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. Wouldn't change to map to simplify .get() in single place where performance issue is not expected. |
||
| } | ||
|
|
||
| interface PendingMcpStartupSession { | ||
|
|
@@ -171,7 +171,6 @@ export class CodexAcpServer implements acp.Agent { | |
|
|
||
| const account = await this.getActiveAccount(); | ||
| const {sessionId, currentModelId, models} = sessionMetadata; | ||
| const sessionMcpServers = this.resolveSessionMcpServers(requestedMcpServers, "sessionId" in request); | ||
| const currentModel = this.findCurrentModel(models, currentModelId); | ||
| const currentModelSupportsFast = modelSupportsFast(currentModel); | ||
| const sessionState: SessionState = { | ||
|
|
@@ -189,7 +188,7 @@ export class CodexAcpServer implements acp.Agent { | |
| cwd: request.cwd, | ||
| fastModeEnabled: sessionMetadata.currentServiceTier === "fast", | ||
| currentModelSupportsFast: currentModelSupportsFast, | ||
| sessionMcpServers: sessionMcpServers, | ||
| sessionMcpServers: this.createSessionMcpServers(requestedMcpServers, "sessionId" in request), | ||
| } | ||
| this.sessions.set(sessionId, sessionState); | ||
|
|
||
|
|
@@ -431,7 +430,6 @@ export class CodexAcpServer implements acp.Agent { | |
|
|
||
| const account = await this.getActiveAccount(); | ||
| const {sessionId, currentModelId, models, thread} = sessionMetadata; | ||
| const sessionMcpServers = this.resolveSessionMcpServers(requestedMcpServers, true); | ||
|
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. I'm not against, but is there a reason to mix these such refactorings with changes (inline constant)? |
||
| const currentModel = this.findCurrentModel(models, currentModelId); | ||
| const currentModelSupportsFast = modelSupportsFast(currentModel); | ||
| const sessionState: SessionState = { | ||
|
|
@@ -449,7 +447,7 @@ export class CodexAcpServer implements acp.Agent { | |
| cwd: request.cwd, | ||
| fastModeEnabled: sessionMetadata.currentServiceTier === "fast", | ||
| currentModelSupportsFast: currentModelSupportsFast, | ||
| sessionMcpServers: sessionMcpServers, | ||
| sessionMcpServers: this.createSessionMcpServers(requestedMcpServers, true), | ||
| }; | ||
| this.sessions.set(sessionId, sessionState); | ||
|
|
||
|
|
@@ -703,24 +701,23 @@ export class CodexAcpServer implements acp.Agent { | |
| return sessionState; | ||
| } | ||
|
|
||
| private resolveSessionMcpServers( | ||
| private createSessionMcpServers( | ||
| mcpServers: Array<acp.McpServer>, | ||
| recoverFromStartup: boolean, | ||
| ): Array<string> { | ||
| ): Map<string, acp.McpServer> { | ||
| // Explicit MCP servers from the request are the primary source of truth for the session. | ||
| const requestedServerNames = getRequestedMcpServerNames(mcpServers); | ||
| if (requestedServerNames.length > 0) { | ||
| return requestedServerNames; | ||
| if (mcpServers.length > 0) { | ||
| return new Map(mcpServers.map(server => [server.name, server])); | ||
| } | ||
| // Fresh sessions without MCP config should not inherit any session MCP state. | ||
| if (!recoverFromStartup) { | ||
| return []; | ||
| return new Map(); | ||
| } | ||
| // Without a thread-scoped startup completion event, loadSession/resumeSession can no longer | ||
| // recover omitted session MCP server names. Treat the session set as unknown unless ACP | ||
| // explicitly provided mcpServers in the request. | ||
| logger.log("Skipping MCP server recovery for load/resume without explicit mcpServers"); | ||
| return []; | ||
| return new Map(); | ||
| } | ||
|
|
||
| private publishMcpStartupStatusAsync(sessionId: string): void { | ||
|
|
@@ -781,7 +778,7 @@ export class CodexAcpServer implements acp.Agent { | |
| try { | ||
| const eventHandler = new CodexEventHandler(this.connection, sessionState); | ||
| const approvalHandler = new CodexApprovalHandler(this.connection, sessionState); | ||
| const elicitationHandler = new CodexElicitationHandler(this.connection, sessionState); | ||
| const elicitationHandler = new CodexElicitationHandler(this.connection, sessionState, this.codexAcpClient); | ||
| await this.codexAcpClient.subscribeToSessionEvents(params.sessionId, | ||
| (event) => { | ||
| elicitationHandler.handleNotification(event); | ||
|
|
@@ -934,7 +931,3 @@ export class CodexAcpServer implements acp.Agent { | |
| } | ||
| } | ||
| } | ||
|
|
||
| function getRequestedMcpServerNames(mcpServers: Array<acp.McpServer>): Array<string> { | ||
| return Array.from(new Set(mcpServers.map(server => server.name))); | ||
| } | ||
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.
Do we also save mcp servers in global config?
How exactly this affect cli agent?