Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion apps/server/src/mcp/OrchestratorMcpService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ describe("OrchestratorMcpService provider resolution", () => {
Effect.gen(function* () {
const disabledAntigravityInstanceId = ProviderInstanceId.make("antigravity-alt");
const disabledWithoutAdapterInstanceId = ProviderInstanceId.make("codex-without-adapter");
const projectDisabledInstanceId = ProviderInstanceId.make("codex-project-off");
const forkOnlyInstanceId = ProviderInstanceId.make("forkOnly");
const forkShadow = yield* buildUnavailableProviderSnapshot({
driverKind: "forkOnly",
Expand Down Expand Up @@ -1437,6 +1438,11 @@ describe("OrchestratorMcpService provider resolution", () => {
model: "gpt-5.4",
enabled: false,
}),
providerSnapshot({
instanceId: projectDisabledInstanceId,
driver: ProviderDriverKind.make("codex"),
model: "gpt-5.4",
}),
forkShadow,
];
const layerDependencies = Layer.mergeAll(
Expand All @@ -1445,12 +1451,34 @@ describe("OrchestratorMcpService provider resolution", () => {
Layer.mock(ThreadManagementService.ThreadManagementService)({
getThreadRecords: () => Effect.succeed(parentProjection([])),
}),
ServerSettings.layerTest(),
ServerSettings.layerTest({
providerInstances: {
[ProviderInstanceId.make("pi")]: {
driver: ProviderDriverKind.make("pi"),
enabled: true,
},
[ProviderInstanceId.make("acpRegistry")]: {
driver: ProviderDriverKind.make("acpRegistry"),
enabled: true,
},
[antigravityInstanceId]: {
driver: ProviderDriverKind.make("antigravity"),
enabled: true,
},
[projectDisabledInstanceId]: { driver: ProviderDriverKind.make("codex") },
},
projectSettingsOverrides: {
[projectId]: {
providerInstances: { [projectDisabledInstanceId]: { enabled: false } },
},
},
}),
Layer.mock(ProviderRegistry.ProviderRegistry)({
getProviders: Effect.sync(() => providers),
}),
adapterRegistryLayer([
codexInstanceId,
projectDisabledInstanceId,
ProviderInstanceId.make("claudeAgent"),
ProviderInstanceId.make("pi"),
ProviderInstanceId.make("acpRegistry"),
Expand Down Expand Up @@ -1521,6 +1549,11 @@ describe("OrchestratorMcpService provider resolution", () => {
assert.isFalse(disabled!.canRunCrossProviderChildTask);
assert.deepEqual(disabled!.constraints, ["Provider instance is disabled."]);

const projectDisabled = byId.get(projectDisabledInstanceId);
assert.isDefined(projectDisabled);
assert.isFalse(projectDisabled!.canRunChildTask);
assert.deepEqual(projectDisabled!.constraints, ["Provider instance is disabled."]);

const disabledWithoutAdapter = byId.get(disabledWithoutAdapterInstanceId);
assert.isDefined(disabledWithoutAdapter);
assert.isFalse(disabledWithoutAdapter!.canRunChildTask);
Expand Down
11 changes: 10 additions & 1 deletion apps/server/src/mcp/OrchestratorMcpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
type ServerProviderModel,
ThreadId,
isOrchestrationV2WorkActive,
resolveProjectProviderInstanceEnabled,
} from "@t3tools/contracts";
import { getProviderOptionCurrentValue } from "@t3tools/shared/model";
import { runRanAfter } from "@t3tools/shared/orchestrationV2ThreadError";
Expand Down Expand Up @@ -2275,8 +2276,16 @@ const make = Effect.gen(function* () {
runtimeMode: limits.runtimeMode,
interactionMode: limits.interactionMode,
providers: providers.map((provider) => {
// Snapshots list instances any project enables; delegate_task checks the caller's project.
const enabledForCaller =
parent === undefined ||
resolveProjectProviderInstanceEnabled(
settings,
parent.thread.projectId,
provider.instanceId,
);
const constraints = providerConstraints(
provider,
enabledForCaller ? provider : { ...provider, enabled: false },
orchestrationCapableInstanceIds.has(provider.instanceId),
);
const { listed, omitted } = listCapabilityModels({
Expand Down
Loading