feat(server): turn the LiteLLM proxy off by default (P1.1)
Every sidecar start outside the desktop app looked for Python, probed
each interpreter for litellm and, when it found one, started a LiteLLM
child. The community edition must not need Python, so LiteLLM is now
opt-in: startService starts it only when config.json contains
"litellm": { "enabled": true } (WaggleConfig.isLiteLLMEnabled). Otherwise
there is no Python lookup, no LiteLLM health probe and no child process,
and the built-in provider proxy serves every request, as it already did
in the desktop app. --skip-litellm and WAGGLE_SKIP_LITELLM=1 still force
it off.
The lookup for a bundled resources/python/python.exe is removed: no
build ships one. When LiteLLM is enabled it runs on the user's own
Python from PATH.
This commit is contained in:
@@ -315,6 +315,59 @@ describe('Agent Service', () => {
|
||||
}]);
|
||||
});
|
||||
|
||||
it('leaves LiteLLM off and uses the built-in proxy unless config.json enables it', async () => {
|
||||
const dataDir = makeTmpDir();
|
||||
tmpDirs.push(dataDir);
|
||||
const port = randomPort();
|
||||
const litellmPort = randomPort();
|
||||
|
||||
clearProviderEnv();
|
||||
vi.stubEnv('OPENAI_API_KEY', 'openai-solo-test-key');
|
||||
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockImplementation(
|
||||
async () => new Response('{}', { status: 503 }),
|
||||
);
|
||||
|
||||
const { server, litellm } = await startService({ dataDir, port, litellmPort });
|
||||
cleanups.push(async () => { await server.close(); });
|
||||
|
||||
expect(litellm).toEqual({ status: 'error', port: litellmPort, error: 'Not enabled in config.json' });
|
||||
expect(server.localConfig.manageLiteLLM).toBe(false);
|
||||
expect(server.localConfig.useBuiltInProxy).toBe(true);
|
||||
expect(server.localConfig.litellmUrl).toBe(`http://127.0.0.1:${port}/v1`);
|
||||
expect(server.agentState.llmProvider.provider).toBe('anthropic-proxy');
|
||||
expect(fetchSpy.mock.calls.some(([input]) => (
|
||||
String(input) === `http://localhost:${litellmPort}/health/liveliness`
|
||||
))).toBe(false);
|
||||
});
|
||||
|
||||
it('manages LiteLLM when config.json enables it', async () => {
|
||||
const dataDir = makeTmpDir();
|
||||
tmpDirs.push(dataDir);
|
||||
const port = randomPort();
|
||||
const litellmPort = randomPort();
|
||||
fs.writeFileSync(
|
||||
path.join(dataDir, 'config.json'),
|
||||
JSON.stringify({ defaultModel: 'claude-sonnet-4-6', providers: {}, litellm: { enabled: true } }),
|
||||
);
|
||||
|
||||
// No provider key: the runtime catalog is empty, so no Python is spawned.
|
||||
clearProviderEnv();
|
||||
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockImplementation(
|
||||
async () => new Response('{}', { status: 503 }),
|
||||
);
|
||||
|
||||
const { server, litellm } = await startService({ dataDir, port, litellmPort });
|
||||
cleanups.push(async () => { await server.close(); });
|
||||
|
||||
expect(litellm).toEqual({ status: 'error', port: litellmPort, error: 'No provider models available' });
|
||||
expect(server.localConfig.manageLiteLLM).toBe(true);
|
||||
expect(server.localConfig.managedLiteLLMPort).toBe(litellmPort);
|
||||
expect(server.localConfig.useBuiltInProxy).toBe(true);
|
||||
expect(fetchSpy.mock.calls.some(([input]) => (
|
||||
String(input) === `http://localhost:${litellmPort}/health/liveliness`
|
||||
))).toBe(true);
|
||||
});
|
||||
|
||||
it('atomically falls back from an occupied desktop port and routes spawned agents to it', async () => {
|
||||
const base = makeTmpDir();
|
||||
tmpDirs.push(base);
|
||||
|
||||
Reference in New Issue
Block a user