Skip to content

Commit 1004977

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 e688034 commit 1004977

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
@@ -800,10 +800,11 @@ describe("OrchestratorMcpService provider resolution", () => {
800800
instanceId: input.instanceId,
801801
driver: input.driver,
802802
enabled: input.enabled ?? true,
803-
installed: true,
804-
version: "test",
805-
status: "ready",
806-
auth: { status: "authenticated" },
803+
installed: input.enabled !== false,
804+
version: input.enabled === false ? null : "test",
805+
status: input.enabled === false ? "disabled" : "ready",
806+
auth: { status: input.enabled === false ? "unknown" : "authenticated" },
807+
...(input.enabled === false ? { message: "Provider is disabled in T3 Code settings." } : {}),
807808
checkedAt: "2026-09-13T00:00:00.000Z",
808809
models:
809810
input.model === undefined
@@ -884,6 +885,7 @@ describe("OrchestratorMcpService provider resolution", () => {
884885
() =>
885886
Effect.gen(function* () {
886887
const disabledAntigravityInstanceId = ProviderInstanceId.make("antigravity-alt");
888+
const disabledWithoutAdapterInstanceId = ProviderInstanceId.make("codex-without-adapter");
887889
const forkOnlyInstanceId = ProviderInstanceId.make("forkOnly");
888890
const forkShadow = yield* buildUnavailableProviderSnapshot({
889891
driverKind: "forkOnly",
@@ -928,6 +930,12 @@ describe("OrchestratorMcpService provider resolution", () => {
928930
model: "ant-model",
929931
enabled: false,
930932
}),
933+
providerSnapshot({
934+
instanceId: disabledWithoutAdapterInstanceId,
935+
driver: ProviderDriverKind.make("codex"),
936+
model: "gpt-5.4",
937+
enabled: false,
938+
}),
931939
forkShadow,
932940
];
933941
const layerDependencies = Layer.mergeAll(
@@ -1007,18 +1015,27 @@ describe("OrchestratorMcpService provider resolution", () => {
10071015
const disabled = byId.get(disabledAntigravityInstanceId);
10081016
assert.isDefined(disabled);
10091017
assert.isFalse(disabled!.canRunChildTask);
1018+
assert.isFalse(disabled!.canRunCrossProviderChildTask);
10101019
assert.deepEqual(disabled!.constraints, ["Provider instance is disabled."]);
10111020

1021+
const disabledWithoutAdapter = byId.get(disabledWithoutAdapterInstanceId);
1022+
assert.isDefined(disabledWithoutAdapter);
1023+
assert.isFalse(disabledWithoutAdapter!.canRunChildTask);
1024+
assert.isFalse(disabledWithoutAdapter!.canRunCrossProviderChildTask);
1025+
assert.deepEqual(disabledWithoutAdapter!.constraints, [
1026+
"No V2 provider adapter is registered.",
1027+
"Provider instance is disabled.",
1028+
]);
1029+
10121030
const fork = byId.get(forkOnlyInstanceId);
10131031
assert.isDefined(fork);
10141032
assert.isFalse(fork!.canRunChildTask);
1015-
assert.isTrue(
1016-
fork!.constraints.includes("No V2 provider adapter is registered."),
1017-
`expected missing-adapter constraint, got ${fork!.constraints.join(" | ")}`,
1018-
);
1019-
assert.isTrue(
1020-
fork!.constraints.includes("Driver 'forkOnly' is not registered in this build."),
1021-
);
1033+
assert.isFalse(fork!.canRunCrossProviderChildTask);
1034+
assert.deepEqual(fork!.constraints, [
1035+
"No V2 provider adapter is registered.",
1036+
"Driver 'forkOnly' is not registered in this build.",
1037+
"Provider instance is disabled.",
1038+
]);
10221039
}).pipe(
10231040
Effect.provide(OrchestratorMcpService.layer.pipe(Layer.provide(layerDependencies))),
10241041
);
@@ -1070,6 +1087,85 @@ describe("OrchestratorMcpService provider resolution", () => {
10701087
}),
10711088
);
10721089

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

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

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,16 @@ function providerConstraints(
270270
constraints.push("No V2 provider adapter is registered.");
271271
}
272272
if (provider === undefined) return constraints;
273-
if (!provider.enabled) constraints.push("Provider instance is disabled.");
274-
if (!provider.installed) constraints.push("Provider executable is not installed.");
273+
// Driver availability comes from the registry, even when health probes are skipped.
275274
if (!isProviderAvailable(provider)) {
276275
constraints.push(provider.unavailableReason ?? "Provider driver is unavailable.");
277276
}
277+
if (!provider.enabled) {
278+
constraints.push("Provider instance is disabled.");
279+
// Disabled snapshots contain placeholders for installation, health, and auth.
280+
return constraints;
281+
}
282+
if (!provider.installed) constraints.push("Provider executable is not installed.");
278283
if (provider.status === "error" || provider.status === "disabled") {
279284
constraints.push(provider.message ?? `Provider status is ${provider.status}.`);
280285
}

0 commit comments

Comments
 (0)