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: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Active tickets

- [ ] [`ticket-089`](project/ticket-089/README.md) — route semantic requests
through public SubLLM with direct Z.AI GLM 5.3 by default. Current state:
`IN_PROGRESS / PUBLICATION`; workstream: `llm`.

- [ ] [`ticket-090`](project/ticket-090/README.md) — make the default offline
test command independent of ambient SubLLM credentials. Current state:
`IN_PROGRESS / PUBLICATION`; workstream: `integration`.
Expand Down
1 change: 1 addition & 0 deletions project/TICKETS.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions project/ticket-089/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
31 changes: 31 additions & 0 deletions project/ticket-089/ai-codex.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions project/ticket-089/changelog.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions project/ticket-089/intent.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions project/ticket-089/preprompt.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/llm/subllm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function lastResolvedSubllmRoute(): SubllmPublicRoute | null {

export function shouldUseSubllm(
environment: NodeJS.ProcessEnv = process.env,
cwd = process.cwd(),
_cwd = process.cwd(),
): boolean {
const explicit = environment.T2C_USE_SUBLLM?.trim().toLowerCase();
if (explicit && FALSE_VALUES.has(explicit)) return false;
Expand All @@ -49,7 +49,7 @@ export function shouldUseSubllm(
if (environment.SUBLLM_ENV_FILE || environment.SUBLLM_POLICY_FILE || environment.SUBLLM_PYTHONPATH) {
return true;
}
return Boolean(localSubllmPythonPath(cwd));
return true;
}

export async function resolveSubllmRoute(
Expand Down
30 changes: 18 additions & 12 deletions test/subllm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ if args[:3] == ["resolve", "todo2code", "semantic"]:
print(json.dumps({
"application": "todo2code",
"application_name": "todo2code",
"application_url": "https://github.com/semcod/todo2code",
"application_url": "https://github.com/autogrammar/todo2code",
"function": "semantic",
"provider": "zai",
"model": "glm-5.2",
"priority": 10,
"model": "glm-5.3",
"priority": 0,
"api_base": "https://api.z.ai/api/coding/paas/v4",
"api_key_env": "ZAI_API_KEY",
"litellm_model": "zai/glm-5.2",
"wire_model": "glm-5.2",
"litellm_model": "zai/glm-5.3",
"wire_model": "glm-5.3",
"extra_headers": {},
}))
elif args == ["env", "path"]:
Expand Down Expand Up @@ -92,7 +92,7 @@ test('SubLLM bridge resolves the selected central route without command-shell in
assert.equal(shouldUseSubllm(), true);
const resolved = await resolveSubllmRoute();
assert.equal(resolved.route.provider, 'zai');
assert.equal(resolved.route.wire_model, 'glm-5.2');
assert.equal(resolved.route.wire_model, 'glm-5.3');
assert.equal(resolved.route.application, 'todo2code');
assert.equal(resolved.credential, FIXTURE_CREDENTIAL);
assert.equal(JSON.stringify(resolved.route).includes('fixture-value'), false);
Expand All @@ -116,7 +116,7 @@ test('todo2code sends structured semantic requests through direct Z.AI resolved
return new Response(JSON.stringify({
id: 'zai-fixture-response',
request_id: body.request_id,
model: 'glm-5.2',
model: 'glm-5.3',
usage: { prompt_tokens: 12, completion_tokens: 4, total_tokens: 16 },
choices: [{ message: { content: responseContent } }],
}), { status: 200, headers: { 'Content-Type': 'application/json' } });
Expand All @@ -131,13 +131,13 @@ test('todo2code sends structured semantic requests through direct Z.AI resolved
);

assert.deepEqual(result.value, { ok: true });
assert.equal(result.metadata.model, 'glm-5.2');
assert.equal(result.metadata.model, 'glm-5.3');
assert.equal(result.metadata.provider, 'zai');
assert.equal(url, 'https://api.z.ai/api/coding/paas/v4/chat/completions');
assert.equal(headers.Authorization, `Bearer ${FIXTURE_CREDENTIAL}`);
assert.equal(headers['X-OpenRouter-Title'], undefined);
assert.equal(headers['HTTP-Referer'], undefined);
assert.equal(body.model, 'glm-5.2');
assert.equal(body.model, 'glm-5.3');
assert.equal(body.user_id, 'todo2code');
assert.match(String(body.request_id), /^todo2code-semantic-[0-9a-f]{32}$/u);
assert.deepEqual(body.response_format, { type: 'json_object' });
Expand All @@ -154,9 +154,9 @@ test('todo2code sends structured semantic requests through direct Z.AI resolved
application: 'todo2code',
function: 'semantic',
provider: 'zai',
model: 'glm-5.2',
wireModel: 'glm-5.2',
priority: 10,
model: 'glm-5.3',
wireModel: 'glm-5.3',
priority: 0,
apiBase: 'https://api.z.ai/api/coding/paas/v4',
});
assert.equal(JSON.stringify(audit).includes('fixture-value'), false);
Expand All @@ -174,6 +174,12 @@ test('todo2code sends structured semantic requests through direct Z.AI resolved
}
});

test('SubLLM is the default semantic route and legacy OpenRouter requires an explicit opt-out', () => {
assert.equal(shouldUseSubllm({}), true);
assert.equal(shouldUseSubllm({ T2C_USE_SUBLLM: 'true' }), true);
assert.equal(shouldUseSubllm({ T2C_USE_SUBLLM: 'false' }), false);
});

test('explicitly requested SubLLM fails closed when its package is unavailable', async () => {
const previousUse = process.env.T2C_USE_SUBLLM;
const previousPath = process.env.SUBLLM_PYTHONPATH;
Expand Down
Loading