feat: feature-flag Codex SDK runner (#218)
Add optional @openai/codex-sdk exec-backed runner mode behind CODEX_RUNTIME=sdk, with CODEX_RUNTIME_SDK_ROLES canary limiting and app-server fallback for unsupported flows.
This commit is contained in:
64
runners/codex-runner/test/runtime-mode.test.ts
Normal file
64
runners/codex-runner/test/runtime-mode.test.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { resolveCodexRuntimeMode } from '../src/runtime-mode.js';
|
||||
|
||||
describe('codex runner runtime mode selection', () => {
|
||||
it('keeps app-server as the default runtime', () => {
|
||||
expect(
|
||||
resolveCodexRuntimeMode({}, { codexGoals: false }, 'do work'),
|
||||
).toEqual({
|
||||
mode: 'app-server',
|
||||
reason: 'default',
|
||||
});
|
||||
});
|
||||
|
||||
it('selects SDK mode when CODEX_RUNTIME=sdk', () => {
|
||||
expect(
|
||||
resolveCodexRuntimeMode(
|
||||
{ CODEX_RUNTIME: 'sdk' },
|
||||
{ codexGoals: false },
|
||||
'do work',
|
||||
),
|
||||
).toEqual({ mode: 'sdk', reason: 'CODEX_RUNTIME=sdk' });
|
||||
});
|
||||
|
||||
it('canary-limits SDK mode to configured paired roles', () => {
|
||||
expect(
|
||||
resolveCodexRuntimeMode(
|
||||
{ CODEX_RUNTIME: 'sdk', CODEX_RUNTIME_SDK_ROLES: 'owner,arbiter' },
|
||||
{ codexGoals: false, roomRole: 'owner' },
|
||||
'do work',
|
||||
),
|
||||
).toEqual({ mode: 'sdk', reason: 'CODEX_RUNTIME=sdk' });
|
||||
expect(
|
||||
resolveCodexRuntimeMode(
|
||||
{ CODEX_RUNTIME: 'sdk', CODEX_RUNTIME_SDK_ROLES: 'owner,arbiter' },
|
||||
{ codexGoals: false, roomRole: 'reviewer' },
|
||||
'do work',
|
||||
),
|
||||
).toEqual({ mode: 'app-server', reason: 'sdk-role-not-enabled' });
|
||||
});
|
||||
|
||||
it('falls back to app-server for /compact because SDK lacks compaction', () => {
|
||||
expect(
|
||||
resolveCodexRuntimeMode(
|
||||
{ CODEX_RUNTIME: 'sdk' },
|
||||
{ codexGoals: false },
|
||||
'/compact',
|
||||
),
|
||||
).toEqual({
|
||||
mode: 'app-server',
|
||||
reason: 'sdk-unsupported-session-command',
|
||||
});
|
||||
});
|
||||
|
||||
it('falls back to app-server when Codex goals are enabled', () => {
|
||||
expect(
|
||||
resolveCodexRuntimeMode(
|
||||
{ CODEX_RUNTIME: 'sdk' },
|
||||
{ codexGoals: true },
|
||||
'do work',
|
||||
),
|
||||
).toEqual({ mode: 'app-server', reason: 'sdk-unsupported-goals' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user