Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix(providers): carry the API key through the batched readiness probe (#4716)

[._.]/ Adam Eivya6d967f03941
diff --git a/server/lib/aiToolkit/validation.test.js b/server/lib/aiToolkit/validation.test.js
index ef04b1a228..0bf7ea2b60 100644
--- a/server/lib/aiToolkit/validation.test.js
+++ b/server/lib/aiToolkit/validation.test.js
@@ -74,6 +74,8 @@ describe('providerSchema', () => {
it('accepts the explicit MTPLX marker and rejects a non-boolean value', () => {
expect(providerSchema.safeParse({ ...minimalProvider, mtplxBacked: true }).success).toBe(true);
expect(providerSchema.safeParse({ ...minimalProvider, mtplxBacked: 'true' }).success).toBe(false);
+ expect(providerSchema.safeParse({ ...minimalProvider, vllmBacked: true }).success).toBe(true);
+ expect(providerSchema.safeParse({ ...minimalProvider, vllmBacked: 'true' }).success).toBe(false);
});
it('accepts the explicit OrcaRouter marker and rejects a non-boolean value', () => {
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 04ea4da2a9..bc3a957c8d 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -643,6 +643,11 @@ describe('validation.js', () => {
const result = providerSchema.safeParse({ name: 'MTPLX', type: 'cli', mtplxBacked: true });
expect(result.success).toBe(true);
});
+
+ it('should allow the explicit vLLM provider marker', () => {
+ expect(providerSchema.safeParse({ name: 'vLLM', type: 'tui', vllmBacked: true }).success).toBe(true);
+ expect(providerSchema.safeParse({ name: 'vLLM', type: 'tui', vllmBacked: 'true' }).success).toBe(false);
+ });
});
describe('runSchema', () => {
diff --git a/server/services/providerReadiness.js b/server/services/providerReadiness.js
index 4b62cb6737..0c9a6d1e6c 100644
--- a/server/services/providerReadiness.js
+++ b/server/services/providerReadiness.js
@@ -316,12 +316,19 @@ export async function getProviderReadinessMap(providers, deps = {}) {
return Object.fromEntries(entries.filter(Boolean));
}
-/** Per-batch single-argument memo (the returned promise is shared, not awaited). */
+/**
+ * Per-batch memo (the returned promise is shared, not awaited). EVERY argument
+ * is forwarded and folded into the key — a memo that keyed on the first argument
+ * alone silently dropped the probe's API key, so the batch path (which is what
+ * `GET /api/providers/readiness` uses) probed a key-gated container
+ * unauthenticated while the single-provider path authenticated fine.
+ */
function memoize(fn) {
const seen = new Map();
- return (arg) => {
- if (!seen.has(arg)) seen.set(arg, fn(arg));
- return seen.get(arg);
+ return (...args) => {
+ const key = args.join('\n');
+ if (!seen.has(key)) seen.set(key, fn(...args));
+ return seen.get(key);
};
}
diff --git a/server/services/providerReadiness.test.js b/server/services/providerReadiness.test.js
index 670be4b7a5..f803aef9cd 100644
--- a/server/services/providerReadiness.test.js
+++ b/server/services/providerReadiness.test.js
@@ -291,3 +291,40 @@ describe('vLLM — a key-gated container', () => {
expect(model.detail).toMatch(/paste the server's key/);
});
});
+
+describe('getProviderReadinessMap batching', () => {
+ it(`carries each provider's API key into the batched probe`, async () => {
+ // The batch memo used to key on the endpoint alone and forward only that
+ // argument, so a key-gated container was probed unauthenticated here while
+ // the single-provider path authenticated fine.
+ const calls = [];
+ const providers = [
+ { id: 'a', type: 'tui', command: 'opencode', vllmBacked: true, endpoint: 'http://127.0.0.1:18020/v1', apiKey: 'key-a' },
+ { id: 'b', type: 'tui', command: 'opencode', vllmBacked: true, endpoint: 'http://127.0.0.1:18020/v1', apiKey: 'key-b' },
+ ];
+
+ await getProviderReadinessMap(providers, {
+ findCommand: () => '/usr/bin/docker',
+ probe: async (endpoint, apiKey) => { calls.push([endpoint, apiKey]); return { reachable: true, models: ['qwen3.8-27b'], error: null }; },
+ });
+
+ expect(calls).toEqual([
+ ['http://127.0.0.1:18020/v1', 'key-a'],
+ ['http://127.0.0.1:18020/v1', 'key-b'],
+ ]);
+ });
+
+ it('still collapses two providers sharing one endpoint AND one key into a single probe', async () => {
+ let probes = 0;
+ const providers = ['a', 'b'].map((id) => ({
+ id, type: 'tui', command: 'opencode', llamaBacked: true, endpoint: 'http://127.0.0.1:5568/v1',
+ }));
+
+ await getProviderReadinessMap(providers, {
+ findCommand: () => '/usr/bin/llama-server',
+ probe: async () => { probes += 1; return { reachable: true, models: ['dflash'], error: null }; },
+ });
+
+ expect(probes).toBe(1);
+ });
+});