Skip to content

Commit 230abed

Browse files
committed
Treat custom providers as auth configured
1 parent fe1348f commit 230abed

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

src/CodexAcpServer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ export class CodexAcpServer {
410410
}
411411

412412
private async getActiveAuthState(): Promise<ActiveAuthState> {
413-
if (this.codexAcpClient.hasGatewayAuth()) {
413+
const modelProvider = this.codexAcpClient.getModelProvider();
414+
if (
415+
this.codexAcpClient.hasGatewayAuth() ||
416+
(modelProvider !== null && modelProvider !== "openai")
417+
) {
414418
return {
415419
account: null,
416420
authConfigured: true,

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,47 @@ describe('ACP server test', { timeout: 40_000 }, () => {
14961496
});
14971497
});
14981498

1499+
it('keeps custom provider sessions auth configured without account state', async () => {
1500+
const mockFixture = createCodexMockTestFixture();
1501+
const codexAcpAgent = mockFixture.getCodexAcpAgent();
1502+
const codexAcpClient = mockFixture.getCodexAcpClient();
1503+
const model = createTestModel();
1504+
const currentModelId = ModelId.create(model.id, model.defaultReasoningEffort).toString();
1505+
1506+
vi.spyOn(codexAcpClient, "authRequired").mockResolvedValue(false);
1507+
vi.spyOn(codexAcpClient, "getModelProvider").mockReturnValue("custom-provider");
1508+
const getAccountSpy = vi.spyOn(codexAcpClient, "getAccount")
1509+
.mockResolvedValue({
1510+
account: null,
1511+
requiresOpenaiAuth: true,
1512+
});
1513+
vi.spyOn(codexAcpClient, "newSession").mockResolvedValue({
1514+
sessionId: "custom-provider-session",
1515+
currentModelId,
1516+
models: [model],
1517+
additionalDirectories: [],
1518+
});
1519+
const logoutSpy = vi.spyOn(codexAcpClient, "logout").mockResolvedValue();
1520+
1521+
const session = await codexAcpAgent.newSession({cwd: "/workspace", mcpServers: []});
1522+
expect(codexAcpAgent.getSessionState(session.sessionId)).toMatchObject({
1523+
account: null,
1524+
authConfigured: true,
1525+
});
1526+
1527+
await codexAcpAgent.prompt({
1528+
sessionId: session.sessionId,
1529+
prompt: [{ type: "text", text: "/logout" }],
1530+
});
1531+
1532+
expect(logoutSpy).toHaveBeenCalledOnce();
1533+
expect(getAccountSpy).not.toHaveBeenCalled();
1534+
expect(codexAcpAgent.getSessionState(session.sessionId)).toMatchObject({
1535+
account: null,
1536+
authConfigured: true,
1537+
});
1538+
});
1539+
14991540
it('handles skills command', async () => {
15001541
const codexAcpAgent = fixture.getCodexAcpAgent();
15011542
await codexAcpAgent.initialize({protocolVersion: 1});

0 commit comments

Comments
 (0)