Skip to content

Commit c29e466

Browse files
fix(server): skip probe-based constraints for disabled providers
Disabled provider snapshots short-circuit their health probe and store placeholders: installed:false, version:null, status:"disabled", auth:"unknown". providerConstraints() then evaluated !enabled and !installed as two independent conditions, so it reported "Provider executable is not installed." for a binary it never looked for. Return after the disabled constraint instead, keeping the registry-sourced adapter and driver reasons that do not depend on a probe. This also stops probe-based health and auth constraints from being reported for disabled instances, which is intentional: those fields are placeholders while a provider is off. The providerSnapshot fixture hardcoded installed:true/status:"ready" even for enabled:false, a shape no builder emits, so the existing assertion passed only because the fixture described a state the runtime never produces. Derive those fields from enabled and assert the real behaviour instead.
1 parent 573cec0 commit c29e466

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
@@ -807,10 +807,11 @@ describe("OrchestratorMcpService provider resolution", () => {
807807
instanceId: input.instanceId,
808808
driver: input.driver,
809809
enabled: input.enabled ?? true,
810-
installed: true,
811-
version: "test",
812-
status: "ready",
813-
auth: { status: "authenticated" },
810+
installed: input.enabled !== false,
811+
version: input.enabled === false ? null : "test",
812+
status: input.enabled === false ? "disabled" : "ready",
813+
auth: { status: input.enabled === false ? "unknown" : "authenticated" },
814+
...(input.enabled === false ? { message: "Provider is disabled in T3 Code settings." } : {}),
814815
checkedAt: "2026-09-13T00:00:00.000Z",
815816
models:
816817
input.model === undefined
@@ -891,6 +892,7 @@ describe("OrchestratorMcpService provider resolution", () => {
891892
() =>
892893
Effect.gen(function* () {
893894
const disabledAntigravityInstanceId = ProviderInstanceId.make("antigravity-alt");
895+
const disabledWithoutAdapterInstanceId = ProviderInstanceId.make("codex-without-adapter");
894896
const forkOnlyInstanceId = ProviderInstanceId.make("forkOnly");
895897
const forkShadow = yield* buildUnavailableProviderSnapshot({
896898
driverKind: "forkOnly",
@@ -935,6 +937,12 @@ describe("OrchestratorMcpService provider resolution", () => {
935937
model: "ant-model",
936938
enabled: false,
937939
}),
940+
providerSnapshot({
941+
instanceId: disabledWithoutAdapterInstanceId,
942+
driver: ProviderDriverKind.make("codex"),
943+
model: "gpt-5.4",
944+
enabled: false,
945+
}),
938946
forkShadow,
939947
];
940948
const layerDependencies = Layer.mergeAll(
@@ -1014,18 +1022,27 @@ describe("OrchestratorMcpService provider resolution", () => {
10141022
const disabled = byId.get(disabledAntigravityInstanceId);
10151023
assert.isDefined(disabled);
10161024
assert.isFalse(disabled!.canRunChildTask);
1025+
assert.isFalse(disabled!.canRunCrossProviderChildTask);
10171026
assert.deepEqual(disabled!.constraints, ["Provider instance is disabled."]);
10181027

1028+
const disabledWithoutAdapter = byId.get(disabledWithoutAdapterInstanceId);
1029+
assert.isDefined(disabledWithoutAdapter);
1030+
assert.isFalse(disabledWithoutAdapter!.canRunChildTask);
1031+
assert.isFalse(disabledWithoutAdapter!.canRunCrossProviderChildTask);
1032+
assert.deepEqual(disabledWithoutAdapter!.constraints, [
1033+
"No V2 provider adapter is registered.",
1034+
"Provider instance is disabled.",
1035+
]);
1036+
10191037
const fork = byId.get(forkOnlyInstanceId);
10201038
assert.isDefined(fork);
10211039
assert.isFalse(fork!.canRunChildTask);
1022-
assert.isTrue(
1023-
fork!.constraints.includes("No V2 provider adapter is registered."),
1024-
`expected missing-adapter constraint, got ${fork!.constraints.join(" | ")}`,
1025-
);
1026-
assert.isTrue(
1027-
fork!.constraints.includes("Driver 'forkOnly' is not registered in this build."),
1028-
);
1040+
assert.isFalse(fork!.canRunCrossProviderChildTask);
1041+
assert.deepEqual(fork!.constraints, [
1042+
"No V2 provider adapter is registered.",
1043+
"Driver 'forkOnly' is not registered in this build.",
1044+
"Provider instance is disabled.",
1045+
]);
10291046
}).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies))));
10301047
}),
10311048
);
@@ -1075,6 +1092,85 @@ describe("OrchestratorMcpService provider resolution", () => {
10751092
}),
10761093
);
10771094

1095+
it.effect.each([
1096+
{
1097+
name: "installation",
1098+
snapshot: { installed: false, version: null, status: "warning", auth: { status: "unknown" } },
1099+
constraints: ["Provider executable is not installed."],
1100+
},
1101+
{
1102+
name: "health",
1103+
snapshot: { status: "error", message: "Provider health check failed." },
1104+
constraints: ["Provider health check failed."],
1105+
},
1106+
{
1107+
name: "authentication",
1108+
snapshot: { auth: { status: "unauthenticated" } },
1109+
constraints: ["Provider is not authenticated."],
1110+
},
1111+
{
1112+
name: "combined installation and health",
1113+
snapshot: {
1114+
installed: false,
1115+
version: null,
1116+
status: "error",
1117+
message: "Provider executable could not be found.",
1118+
auth: { status: "unknown" },
1119+
},
1120+
constraints: [
1121+
"Provider executable is not installed.",
1122+
"Provider executable could not be found.",
1123+
],
1124+
},
1125+
{
1126+
name: "disabled with stale probe failures",
1127+
snapshot: {
1128+
enabled: false,
1129+
installed: false,
1130+
version: null,
1131+
status: "error",
1132+
message: "Stale provider health failure.",
1133+
auth: { status: "unauthenticated" },
1134+
},
1135+
constraints: ["Provider instance is disabled."],
1136+
},
1137+
] as const)("reports $name provider constraints", (testCase) =>
1138+
Effect.gen(function* () {
1139+
const provider: ServerProvider = {
1140+
...providerSnapshot({
1141+
instanceId: codexInstanceId,
1142+
driver: ProviderDriverKind.make("codex"),
1143+
model: "gpt-5.4",
1144+
}),
1145+
...testCase.snapshot,
1146+
};
1147+
const layerDependencies = Layer.mergeAll(
1148+
NodeServices.layer,
1149+
Layer.mock(ThreadManagementService.ThreadManagementService)({
1150+
getThreadRecords: () => Effect.succeed(parentProjection([])),
1151+
}),
1152+
ServerSettings.layerTest(),
1153+
providerRegistryLayer([provider]),
1154+
adapterRegistryLayer([codexInstanceId]),
1155+
Layer.mock(ProjectService.ProjectService)({}),
1156+
Layer.mock(SecretRequests.SecretRequests)({}),
1157+
Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
1158+
);
1159+
1160+
yield* Effect.gen(function* () {
1161+
const service = yield* OrchestratorMcpService.OrchestratorMcpService;
1162+
const capabilities = yield* service.capabilities(scope);
1163+
const entry = capabilities.providers.find(
1164+
(candidate) => candidate.providerInstanceId === codexInstanceId,
1165+
);
1166+
assert.isDefined(entry);
1167+
assert.isFalse(entry!.canRunChildTask);
1168+
assert.isFalse(entry!.canRunCrossProviderChildTask);
1169+
assert.deepEqual(entry!.constraints, testCase.constraints);
1170+
}).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(layerDependencies))));
1171+
}),
1172+
);
1173+
10781174
it.effect(
10791175
"delegates to an Antigravity instance whose adapter resolves through the registry",
10801176
() =>
@@ -1784,6 +1880,22 @@ describe("OrchestratorMcpService provider resolution", () => {
17841880
selectedInstanceId: null,
17851881
candidateDriver: driver,
17861882
},
1883+
{
1884+
name: "inherited-unavailable",
1885+
inheritedEnabled: false,
1886+
peerEnabled: true,
1887+
explicit: false,
1888+
selectedInstanceId: null,
1889+
candidateDriver: driver,
1890+
},
1891+
{
1892+
name: "explicit-disabled-without-adapter",
1893+
inheritedEnabled: false,
1894+
peerEnabled: true,
1895+
explicit: true,
1896+
selectedInstanceId: null,
1897+
candidateDriver: driver,
1898+
},
17871899
{
17881900
name: "explicit-healthy",
17891901
inheritedEnabled: true,
@@ -1843,22 +1955,29 @@ describe("OrchestratorMcpService provider resolution", () => {
18431955
enabled: testCase.peerEnabled,
18441956
}),
18451957
]),
1846-
adapterRegistryLayer([codexInstanceId, codexAltInstanceId]),
1958+
adapterRegistryLayer(
1959+
testCase.name === "explicit-disabled-without-adapter"
1960+
? [codexAltInstanceId]
1961+
: [codexInstanceId, codexAltInstanceId],
1962+
),
18471963
Layer.mock(ProjectService.ProjectService)({}),
18481964
Layer.mock(SecretRequests.SecretRequests)({}),
18491965
Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
18501966
);
18511967

18521968
yield* Effect.gen(function* () {
18531969
const service = yield* OrchestratorMcpService.OrchestratorMcpService;
1854-
const target = testCase.explicit
1855-
? ({
1856-
providerInstanceId:
1857-
testCase.selectedInstanceId === null
1858-
? codexInstanceId
1859-
: testCase.selectedInstanceId,
1860-
} as const)
1861-
: ({ driverKind: testCase.candidateDriver } as const);
1970+
const target =
1971+
testCase.name === "inherited-unavailable"
1972+
? undefined
1973+
: testCase.explicit
1974+
? ({
1975+
providerInstanceId:
1976+
testCase.selectedInstanceId === null
1977+
? codexInstanceId
1978+
: testCase.selectedInstanceId,
1979+
} as const)
1980+
: ({ driverKind: testCase.candidateDriver } as const);
18621981
if (testCase.selectedInstanceId === null) {
18631982
const error = yield* service
18641983
.delegateTask(scope, {
@@ -1869,6 +1988,27 @@ describe("OrchestratorMcpService provider resolution", () => {
18691988
})
18701989
.pipe(Effect.flip);
18711990
assert.equal(error.code, "provider_unavailable", testCase.name);
1991+
if (
1992+
testCase.name === "explicit-unavailable" ||
1993+
testCase.name === "inherited-unavailable" ||
1994+
testCase.name === "explicit-disabled-without-adapter"
1995+
) {
1996+
const expectedMessage =
1997+
`Provider ${codexInstanceId} cannot run a child task: ` +
1998+
(testCase.name === "explicit-disabled-without-adapter"
1999+
? "No V2 provider adapter is registered. "
2000+
: "") +
2001+
"Provider instance is disabled.";
2002+
assert.equal(error.message, expectedMessage);
2003+
const threadError = yield* service
2004+
.createThreads(scope, {
2005+
threads: [{ prompt: "Summarize the diff.", target }],
2006+
clientRequestId: `disabled-threads-${testCase.name}`,
2007+
})
2008+
.pipe(Effect.flip);
2009+
assert.equal(threadError.code, "provider_unavailable");
2010+
assert.equal(threadError.message, expectedMessage);
2011+
}
18722012
if (testCase.name === "cross-driver-no-available-candidate") {
18732013
assert.isTrue(error.message.includes("driver claudeAgent"), testCase.name);
18742014
const threadError = yield* service

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,16 @@ function providerConstraints(
273273
constraints.push("No V2 provider adapter is registered.");
274274
}
275275
if (provider === undefined) return constraints;
276-
if (!provider.enabled) constraints.push("Provider instance is disabled.");
277-
if (!provider.installed) constraints.push("Provider executable is not installed.");
276+
// Driver availability comes from the registry, even when health probes are skipped.
278277
if (!isProviderAvailable(provider)) {
279278
constraints.push(provider.unavailableReason ?? "Provider driver is unavailable.");
280279
}
280+
if (!provider.enabled) {
281+
constraints.push("Provider instance is disabled.");
282+
// Disabled snapshots contain placeholders for installation, health, and auth.
283+
return constraints;
284+
}
285+
if (!provider.installed) constraints.push("Provider executable is not installed.");
281286
if (provider.status === "error" || provider.status === "disabled") {
282287
constraints.push(provider.message ?? `Provider status is ${provider.status}.`);
283288
}

0 commit comments

Comments
 (0)