Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ also supports `picker`. Codex review and subagents also support `inherit`.
Native is always the default.

For Codex, Kenari detects whether `codex login` uses ChatGPT or an API key and
keeps native requests on the matching OpenAI upstream.
keeps native requests on the matching OpenAI upstream. The process-scoped
router disables request compression and WebSocket transport so it can inspect
the model ID before selecting the upstream.

Automation must set every role:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kenarihq/cli",
"version": "0.3.1",
"version": "0.3.2",
"description": "Official kenari CLI. Route Claude Code and Codex models per process.",
"license": "MIT",
"type": "module",
Expand Down
18 changes: 17 additions & 1 deletion src/runtime/codex.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ export function codexKenariModels(cache, nativeModels = []) {
export function buildCodexLaunch(options) {
const inputArgs = options.args || [];
for (let index = 0; index < inputArgs.length; index += 1) {
if (inputArgs[index] === '--enable') {
if (inputArgs[index + 1] === 'enable_request_compression') {
throw new KenariError('unsafe Codex routing override: enable_request_compression');
}
index += 1;
continue;
}
if (inputArgs[index] === '--enable=enable_request_compression') {
throw new KenariError('unsafe Codex routing override: enable_request_compression');
}
if (inputArgs[index] === '--oss' || inputArgs[index] === '--local-provider'
|| inputArgs[index].startsWith('--local-provider=')) {
throw new KenariError(`unsafe Codex routing override: ${inputArgs[index]}`);
Expand All @@ -85,7 +95,12 @@ export function buildCodexLaunch(options) {
if (inline === null && !['-c', '--config'].includes(inputArgs[index])) continue;
const value = inline ?? inputArgs[index + 1] ?? '';
const key = value.split('=', 1)[0].trim();
if (['model_provider', 'openai_base_url', 'model_catalog_json'].includes(key)
if ([
'model_provider',
'openai_base_url',
'model_catalog_json',
'features.enable_request_compression',
].includes(key)
|| key.startsWith('model_providers.')) {
throw new KenariError(`unsafe Codex routing override: ${key}`);
}
Expand All @@ -99,6 +114,7 @@ export function buildCodexLaunch(options) {
`model_providers.${CODEX_ROUTER_PROVIDER}.requires_openai_auth=true`,
`model_providers.${CODEX_ROUTER_PROVIDER}.supports_websockets=false`,
`model_providers.${CODEX_ROUTER_PROVIDER}.supports_standalone_web_search=true`,
'features.enable_request_compression=false',
];
if (options.catalogPath) {
overrides.push(`model_catalog_json=${tomlString(options.catalogPath)}`);
Expand Down
13 changes: 13 additions & 0 deletions test/v2-runtime-supervisor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ test('Codex launch injects temporary controls before original args', () => {
));
assert.ok(built.args.includes('model_providers.kenari_router.requires_openai_auth=true'));
assert.ok(built.args.includes('model_providers.kenari_router.supports_websockets=false'));
assert.ok(built.args.includes('features.enable_request_compression=false'));
assert.equal(built.env.OPENAI_API_KEY, 'secret');
assert.equal(built.env.KEEP, 'yes');
const native = [{
Expand All @@ -149,6 +150,18 @@ test('Codex launch injects temporary controls before original args', () => {
routerUrl: 'http://127.0.0.1:2',
args: ['-c', 'openai_base_url="https://bypass.example"'],
}), /unsafe Codex routing override/);
for (const args of [
['-c', 'features.enable_request_compression=true'],
['--config=features.enable_request_compression=true'],
['--enable', 'enable_request_compression'],
['--enable=enable_request_compression'],
]) {
assert.throws(() => buildCodexLaunch({
toolConfig: { roles: {} },
routerUrl: 'http://127.0.0.1:2',
args,
}), /unsafe Codex routing override/, args.join(' '));
}
});

test('Codex native upstream follows the active login method', () => {
Expand Down
Loading