From 81c4f23226e55de50ce90fab0cc1352289a15f90 Mon Sep 17 00:00:00 2001 From: Evgeny Shurakov Date: Tue, 22 Sep 2026 16:59:25 +0200 Subject: [PATCH] feat(cloud-agent-next): open Cloudflare containers selection under enforced billing --- .../src/sandbox-selection.test.ts | 20 ++++++++++++------- .../cloud-agent-next/src/sandbox-selection.ts | 3 --- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/services/cloud-agent-next/src/sandbox-selection.test.ts b/services/cloud-agent-next/src/sandbox-selection.test.ts index 5c86a7b67f..5237dbbf12 100644 --- a/services/cloud-agent-next/src/sandbox-selection.test.ts +++ b/services/cloud-agent-next/src/sandbox-selection.test.ts @@ -320,19 +320,25 @@ describe('sandbox selection policy', () => { ).not.toContainEqual(getSandboxAllocationRequest('cloudflare-containers-standard-4')); }); - it('fails Cloudflare containers closed for enforced organization billing', () => { + it('offers Cloudflare containers to an enrolled owner under enforced organization billing', () => { const env = { ...configured, + PER_SESSION_SANDBOX_ORG_IDS: owner.orgId, CLOUDFLARE_CONTAINERS_ORG_IDS: owner.orgId, CLOUD_AGENT_CONTAINER_BILLING_ENABLED: 'true', CLOUD_AGENT_CONTAINER_BILLING_ORG_IDS: owner.orgId, } as Env; - expect( - getSandboxSelectionCapabilities(env, owner).options.map(option => option.allocation) - ).not.toContainEqual(getSandboxAllocationRequest('cloudflare-containers-standard-4')); - expect(() => - assertSandboxAllocationAvailable(env, owner, 'cloudflare-containers-standard-4') - ).toThrow('enforced compute billing'); + const capabilities = getSandboxSelectionCapabilities(env, owner); + const options = capabilities.options.map(option => option.allocation); + expect(options).toContainEqual(getSandboxAllocationRequest('cloudflare-containers-standard-3')); + expect(options).toContainEqual(getSandboxAllocationRequest('cloudflare-containers-standard-4')); + expect(capabilities.defaultDestination).toEqual( + getSandboxAllocationRequest('cloudflare-containers-standard-4') + ); + expect(options).toContainEqual(capabilities.defaultDestination); + expect(isSandboxAllocationAvailable(capabilities, 'cloudflare-containers-standard-4')).toBe( + true + ); }); it('admits the trigger-only allocation without listing it', () => { diff --git a/services/cloud-agent-next/src/sandbox-selection.ts b/services/cloud-agent-next/src/sandbox-selection.ts index cff16754df..d8e4c1e841 100644 --- a/services/cloud-agent-next/src/sandbox-selection.ts +++ b/services/cloud-agent-next/src/sandbox-selection.ts @@ -32,9 +32,6 @@ function sandboxAllocationUnavailableReason( if (!isCloudflareContainersEnrolled(env, { orgId: owner.orgId })) { return 'Cloudflare containers are not enabled for this account'; } - if (isCloudAgentContainerBillingEnabled(env, owner)) { - return 'Cloudflare containers do not support enforced compute billing'; - } return undefined; }