Skip to content

Commit b497d12

Browse files
fix(server): disabled providers no longer report missing executables (pingdotgg#18109)
1 parent 96d354a commit b497d12

2 files changed

Lines changed: 167 additions & 22 deletions

File tree

‎apps/server/src/mcp/OrchestratorMcpService.test.ts‎

Lines changed: 160 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,11 @@ describe("OrchestratorMcpService provider resolution", () => {
798798
instanceId: input.instanceId,
799799
driver: input.driver,
800800
enabled: input.enabled ?? true,
801-
installed: true,
802-
version: "test",
803-
status: "ready",
804-
auth: { status: "authenticated" },
801+
installed: input.enabled !== false,
802+
version: input.enabled === false ? null : "test",
803+
status: input.enabled === false ? "disabled" : "ready",
804+
auth: { status: input.enabled === false ? "unknown" : "authenticated" },
805+
...(input.enabled === false ? { message: "Provider is disabled in T3 Code settings." } : {}),
805806
checkedAt: "2026-09-13T00:00:00.000Z",
806807
models:
807808
input.model === undefined
@@ -882,6 +883,7 @@ describe("OrchestratorMcpService provider resolution", () => {
882883
() =>
883884
Effect.gen(function* () {
884885
const disabledAntigravityInstanceId = ProviderInstanceId.make("antigravity-alt");
886+
const disabledWithoutAdapterInstanceId = ProviderInstanceId.make("codex-without-adapter");
885887
const forkOnlyInstanceId = ProviderInstanceId.make("forkOnly");
886888
const forkShadow = yield* buildUnavailableProviderSnapshot({
887889
driverKind: "forkOnly",
@@ -921,6 +923,12 @@ describe("OrchestratorMcpService provider resolution", () => {
921923
model: "ant-model",
922924
enabled: false,
923925
}),
926+
providerSnapshot({
927+
instanceId: disabledWithoutAdapterInstanceId,
928+
driver: ProviderDriverKind.make("codex"),
929+
model: "gpt-5.4",
930+
enabled: false,
931+
}),
924932
forkShadow,
925933
];
926934
const layerDependencies = Layer.mergeAll(
@@ -1000,18 +1008,27 @@ describe("OrchestratorMcpService provider resolution", () => {
10001008
const disabled = byId.get(disabledAntigravityInstanceId);
10011009
assert.isDefined(disabled);
10021010
assert.isFalse(disabled!.canRunChildTask);
1011+
assert.isFalse(disabled!.canRunCrossProviderChildTask);
10031012
assert.deepEqual(disabled!.constraints, ["Provider instance is disabled."]);
10041013

1014+
const disabledWithoutAdapter = byId.get(disabledWithoutAdapterInstanceId);
1015+
assert.isDefined(disabledWithoutAdapter);
1016+
assert.isFalse(disabledWithoutAdapter!.canRunChildTask);
1017+
assert.isFalse(disabledWithoutAdapter!.canRunCrossProviderChildTask);
1018+
assert.deepEqual(disabledWithoutAdapter!.constraints, [
1019+
"No V2 provider adapter is registered.",
1020+
"Provider instance is disabled.",
1021+
]);
1022+
10051023
const fork = byId.get(forkOnlyInstanceId);
10061024
assert.isDefined(fork);
10071025
assert.isFalse(fork!.canRunChildTask);
1008-
assert.isTrue(
1009-
fork!.constraints.includes("No V2 provider adapter is registered."),
1010-
`expected missing-adapter constraint, got ${fork!.constraints.join(" | ")}`,
1011-
);
1012-
assert.isTrue(
1013-
fork!.constraints.includes("Driver 'forkOnly' is not registered in this build."),
1014-
);
1026+
assert.isFalse(fork!.canRunCrossProviderChildTask);
1027+
assert.deepEqual(fork!.constraints, [
1028+
"No V2 provider adapter is registered.",
1029+
"Driver 'forkOnly' is not registered in this build.",
1030+
"Provider instance is disabled.",
1031+
]);
10151032
}).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies))));
10161033
}),
10171034
);
@@ -1060,6 +1077,85 @@ describe("OrchestratorMcpService provider resolution", () => {
10601077
}),
10611078
);
10621079

1080+
it.effect.each([
1081+
{
1082+
name: "installation",
1083+
snapshot: { installed: false, version: null, status: "warning", auth: { status: "unknown" } },
1084+
constraints: ["Provider executable is not installed."],
1085+
},
1086+
{
1087+
name: "health",
1088+
snapshot: { status: "error", message: "Provider health check failed." },
1089+
constraints: ["Provider health check failed."],
1090+
},
1091+
{
1092+
name: "authentication",
1093+
snapshot: { auth: { status: "unauthenticated" } },
1094+
constraints: ["Provider is not authenticated."],
1095+
},
1096+
{
1097+
name: "combined installation and health",
1098+
snapshot: {
1099+
installed: false,
1100+
version: null,
1101+
status: "error",
1102+
message: "Provider executable could not be found.",
1103+
auth: { status: "unknown" },
1104+
},
1105+
constraints: [
1106+
"Provider executable is not installed.",
1107+
"Provider executable could not be found.",
1108+
],
1109+
},
1110+
{
1111+
name: "disabled with stale probe failures",
1112+
snapshot: {
1113+
enabled: false,
1114+
installed: false,
1115+
version: null,
1116+
status: "error",
1117+
message: "Stale provider health failure.",
1118+
auth: { status: "unauthenticated" },
1119+
},
1120+
constraints: ["Provider instance is disabled."],
1121+
},
1122+
] as const)("reports $name provider constraints", (testCase) =>
1123+
Effect.gen(function* () {
1124+
const provider: ServerProvider = {
1125+
...providerSnapshot({
1126+
instanceId: codexInstanceId,
1127+
driver: ProviderDriverKind.make("codex"),
1128+
model: "gpt-5.4",
1129+
}),
1130+
...testCase.snapshot,
1131+
};
1132+
const layerDependencies = Layer.mergeAll(
1133+
NodeServices.layer,
1134+
Layer.mock(ThreadManagementService.ThreadManagementService)({
1135+
getThreadRecords: () => Effect.succeed(parentProjection([])),
1136+
}),
1137+
ServerSettings.layerTest(),
1138+
providerRegistryLayer([provider]),
1139+
adapterRegistryLayer([codexInstanceId]),
1140+
Layer.mock(ProjectService.ProjectService)({}),
1141+
Layer.mock(SecretRequests.SecretRequests)({}),
1142+
Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
1143+
);
1144+
1145+
yield* Effect.gen(function* () {
1146+
const service = yield* OrchestratorMcpService.OrchestratorMcpService;
1147+
const capabilities = yield* service.capabilities(scope);
1148+
const entry = capabilities.providers.find(
1149+
(candidate) => candidate.providerInstanceId === codexInstanceId,
1150+
);
1151+
assert.isDefined(entry);
1152+
assert.isFalse(entry!.canRunChildTask);
1153+
assert.isFalse(entry!.canRunCrossProviderChildTask);
1154+
assert.deepEqual(entry!.constraints, testCase.constraints);
1155+
}).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies))));
1156+
}),
1157+
);
1158+
10631159
it.effect(
10641160
"delegates to an Antigravity instance whose adapter resolves through the registry",
10651161
() =>
@@ -1758,6 +1854,22 @@ describe("OrchestratorMcpService provider resolution", () => {
17581854
selectedInstanceId: null,
17591855
candidateDriver: driver,
17601856
},
1857+
{
1858+
name: "inherited-unavailable",
1859+
inheritedEnabled: false,
1860+
peerEnabled: true,
1861+
explicit: false,
1862+
selectedInstanceId: null,
1863+
candidateDriver: driver,
1864+
},
1865+
{
1866+
name: "explicit-disabled-without-adapter",
1867+
inheritedEnabled: false,
1868+
peerEnabled: true,
1869+
explicit: true,
1870+
selectedInstanceId: null,
1871+
candidateDriver: driver,
1872+
},
17611873
{
17621874
name: "explicit-healthy",
17631875
inheritedEnabled: true,
@@ -1817,22 +1929,29 @@ describe("OrchestratorMcpService provider resolution", () => {
18171929
enabled: testCase.peerEnabled,
18181930
}),
18191931
]),
1820-
adapterRegistryLayer([codexInstanceId, codexAltInstanceId]),
1932+
adapterRegistryLayer(
1933+
testCase.name === "explicit-disabled-without-adapter"
1934+
? [codexAltInstanceId]
1935+
: [codexInstanceId, codexAltInstanceId],
1936+
),
18211937
Layer.mock(ProjectService.ProjectService)({}),
18221938
Layer.mock(SecretRequests.SecretRequests)({}),
18231939
Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
18241940
);
18251941

18261942
yield* Effect.gen(function* () {
18271943
const service = yield* OrchestratorMcpService.OrchestratorMcpService;
1828-
const target = testCase.explicit
1829-
? ({
1830-
providerInstanceId:
1831-
testCase.selectedInstanceId === null
1832-
? codexInstanceId
1833-
: testCase.selectedInstanceId,
1834-
} as const)
1835-
: ({ driverKind: testCase.candidateDriver } as const);
1944+
const target =
1945+
testCase.name === "inherited-unavailable"
1946+
? undefined
1947+
: testCase.explicit
1948+
? ({
1949+
providerInstanceId:
1950+
testCase.selectedInstanceId === null
1951+
? codexInstanceId
1952+
: testCase.selectedInstanceId,
1953+
} as const)
1954+
: ({ driverKind: testCase.candidateDriver } as const);
18361955
if (testCase.selectedInstanceId === null) {
18371956
const error = yield* service
18381957
.delegateTask(scope, {
@@ -1843,6 +1962,27 @@ describe("OrchestratorMcpService provider resolution", () => {
18431962
})
18441963
.pipe(Effect.flip);
18451964
assert.equal(error.code, "provider_unavailable", testCase.name);
1965+
if (
1966+
testCase.name === "explicit-unavailable" ||
1967+
testCase.name === "inherited-unavailable" ||
1968+
testCase.name === "explicit-disabled-without-adapter"
1969+
) {
1970+
const expectedMessage =
1971+
`Provider ${codexInstanceId} cannot run a child task: ` +
1972+
(testCase.name === "explicit-disabled-without-adapter"
1973+
? "No V2 provider adapter is registered. "
1974+
: "") +
1975+
"Provider instance is disabled.";
1976+
assert.equal(error.message, expectedMessage);
1977+
const threadError = yield* service
1978+
.createThreads(scope, {
1979+
threads: [{ prompt: "Summarize the diff.", target }],
1980+
clientRequestId: `disabled-threads-${testCase.name}`,
1981+
})
1982+
.pipe(Effect.flip);
1983+
assert.equal(threadError.code, "provider_unavailable");
1984+
assert.equal(threadError.message, expectedMessage);
1985+
}
18461986
if (testCase.name === "cross-driver-no-available-candidate") {
18471987
assert.isTrue(error.message.includes("driver claudeAgent"), testCase.name);
18481988
const threadError = yield* service

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,16 @@ function providerConstraints(
284284
constraints.push("No V2 provider adapter is registered.");
285285
}
286286
if (provider === undefined) return constraints;
287-
if (!provider.enabled) constraints.push("Provider instance is disabled.");
288-
if (!provider.installed) constraints.push("Provider executable is not installed.");
287+
// Driver availability comes from the registry, even when health probes are skipped.
289288
if (!isProviderAvailable(provider)) {
290289
constraints.push(provider.unavailableReason ?? "Provider driver is unavailable.");
291290
}
291+
if (!provider.enabled) {
292+
constraints.push("Provider instance is disabled.");
293+
// Disabled snapshots contain placeholders for installation, health, and auth.
294+
return constraints;
295+
}
296+
if (!provider.installed) constraints.push("Provider executable is not installed.");
292297
if (provider.status === "error" || provider.status === "disabled") {
293298
constraints.push(provider.message ?? `Provider status is ${provider.status}.`);
294299
}

0 commit comments

Comments
 (0)