AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
feat(platform): add MAX tier + LD-configurable pricing + hide unconfigured tiers (#12903)
Zamil Majdycc1f692fec06
diff --git a/autogpt_platform/backend/backend/api/features/admin/rate_limit_admin_routes_test.py b/autogpt_platform/backend/backend/api/features/admin/rate_limit_admin_routes_test.pyindex c6c920829d..95c3e589cb 100644--- a/autogpt_platform/backend/backend/api/features/admin/rate_limit_admin_routes_test.py+++ b/autogpt_platform/backend/backend/api/features/admin/rate_limit_admin_routes_test.py@@ -57,7 +57,7 @@ def _patch_rate_limit_deps(mocker.patch(f"{_MOCK_MODULE}.get_global_rate_limits",new_callable=AsyncMock,- return_value=(2_500_000, 12_500_000, SubscriptionTier.FREE),+ return_value=(2_500_000, 12_500_000, SubscriptionTier.BASIC),)mocker.patch(f"{_MOCK_MODULE}.get_usage_status",@@ -89,7 +89,7 @@ def test_get_rate_limit(assert data["weekly_cost_limit_microdollars"] == 12_500_000assert data["daily_cost_used_microdollars"] == 500_000assert data["weekly_cost_used_microdollars"] == 3_000_000- assert data["tier"] == "FREE"+ assert data["tier"] == "BASIC"configured_snapshot.assert_match(json.dumps(data, indent=2, sort_keys=True) + "\n",@@ -163,7 +163,7 @@ def test_reset_user_usage_daily_only(assert data["daily_cost_used_microdollars"] == 0# Weekly is untouchedassert data["weekly_cost_used_microdollars"] == 3_000_000- assert data["tier"] == "FREE"+ assert data["tier"] == "BASIC"mock_reset.assert_awaited_once_with(target_user_id, reset_weekly=False)@@ -194,7 +194,7 @@ def test_reset_user_usage_daily_and_weekly(data = response.json()assert data["daily_cost_used_microdollars"] == 0assert data["weekly_cost_used_microdollars"] == 0- assert data["tier"] == "FREE"+ assert data["tier"] == "BASIC"mock_reset.assert_awaited_once_with(target_user_id, reset_weekly=True)@@ -231,7 +231,7 @@ def test_get_rate_limit_email_lookup_failure(mocker.patch(f"{_MOCK_MODULE}.get_global_rate_limits",new_callable=AsyncMock,- return_value=(2_500_000, 12_500_000, SubscriptionTier.FREE),+ return_value=(2_500_000, 12_500_000, SubscriptionTier.BASIC),)mocker.patch(f"{_MOCK_MODULE}.get_usage_status",@@ -324,7 +324,7 @@ def test_set_user_tier(mocker.patch(f"{_MOCK_MODULE}.get_user_tier",new_callable=AsyncMock,- return_value=SubscriptionTier.FREE,+ return_value=SubscriptionTier.BASIC,)mock_set = mocker.patch(f"{_MOCK_MODULE}.set_user_tier",@@ -347,7 +347,7 @@ def test_set_user_tier_downgrade(mocker: pytest_mock.MockerFixture,target_user_id: str,) -> None:- """Test downgrading a user's tier from PRO to FREE."""+ """Test downgrading a user's tier from PRO to BASIC."""mocker.patch(f"{_MOCK_MODULE}.get_user_email_by_id",new_callable=AsyncMock,@@ -365,14 +365,14 @@ def test_set_user_tier_downgrade(response = client.post("/admin/rate_limit/tier",- json={"user_id": target_user_id, "tier": "FREE"},+ json={"user_id": target_user_id, "tier": "BASIC"},)assert response.status_code == 200data = response.json()assert data["user_id"] == target_user_id- assert data["tier"] == "FREE"- mock_set.assert_awaited_once_with(target_user_id, SubscriptionTier.FREE)+ assert data["tier"] == "BASIC"+ mock_set.assert_awaited_once_with(target_user_id, SubscriptionTier.BASIC)def test_set_user_tier_invalid_tier(@@ -456,7 +456,7 @@ def test_set_user_tier_db_failure(mocker.patch(f"{_MOCK_MODULE}.get_user_tier",new_callable=AsyncMock,- return_value=SubscriptionTier.FREE,+ return_value=SubscriptionTier.BASIC,)mocker.patch(f"{_MOCK_MODULE}.set_user_tier",diff --git a/autogpt_platform/backend/backend/api/features/chat/routes_test.py b/autogpt_platform/backend/backend/api/features/chat/routes_test.pyindex 11dac08084..1f692ab299 100644--- a/autogpt_platform/backend/backend/api/features/chat/routes_test.py+++ b/autogpt_platform/backend/backend/api/features/chat/routes_test.py@@ -380,7 +380,7 @@ def _mock_usage(weekly_used: int = 2000,daily_limit: int = 10000,weekly_limit: int = 50000,- tier: "SubscriptionTier" = SubscriptionTier.FREE,+ tier: "SubscriptionTier" = SubscriptionTier.BASIC,) -> AsyncMock:"""Mock get_usage_status and get_global_rate_limits for usage endpoint tests.@@ -440,7 +440,7 @@ def test_usage_returns_daily_and_weekly(daily_cost_limit=10000,weekly_cost_limit=50000,rate_limit_reset_cost=chat_routes.config.rate_limit_reset_cost,- tier=SubscriptionTier.FREE,+ tier=SubscriptionTier.BASIC,)@@ -461,7 +461,7 @@ def test_usage_uses_config_limits(daily_cost_limit=99999,weekly_cost_limit=77777,rate_limit_reset_cost=500,- tier=SubscriptionTier.FREE,+ tier=SubscriptionTier.BASIC,)@@ -996,7 +996,7 @@ def test_stream_chat_accepts_exactly_max_length_message(mocker.patch("backend.api.features.chat.routes.get_global_rate_limits",new_callable=AsyncMock,- return_value=(0, 0, SubscriptionTier.FREE),+ return_value=(0, 0, SubscriptionTier.BASIC),)response = client.post(@@ -1267,7 +1267,7 @@ def _mock_reset_internals(enable_credit: bool = True,daily_limit: int = 10_000,weekly_limit: int = 50_000,- tier: "SubscriptionTier" = SubscriptionTier.FREE,+ tier: "SubscriptionTier" = SubscriptionTier.BASIC,daily_used: int = 10_001,weekly_used: int = 1_000,reset_count: int | None = 0,@@ -1366,7 +1366,7 @@ def test_reset_usage_returns_400_when_no_daily_limit(mocker.patch("backend.api.features.chat.routes.get_global_rate_limits",new_callable=AsyncMock,- return_value=(0, 50_000, SubscriptionTier.FREE),+ return_value=(0, 50_000, SubscriptionTier.BASIC),)mocker.patch("backend.api.features.chat.routes.get_daily_reset_count",@@ -1389,7 +1389,7 @@ def test_reset_usage_returns_503_when_redis_unavailable(mocker.patch("backend.api.features.chat.routes.get_global_rate_limits",new_callable=AsyncMock,- return_value=(10_000, 50_000, SubscriptionTier.FREE),+ return_value=(10_000, 50_000, SubscriptionTier.BASIC),)mocker.patch("backend.api.features.chat.routes.get_daily_reset_count",@@ -1412,7 +1412,7 @@ def test_reset_usage_returns_429_when_max_resets_reached(mocker.patch("backend.api.features.chat.routes.get_global_rate_limits",new_callable=AsyncMock,- return_value=(10_000, 50_000, SubscriptionTier.FREE),+ return_value=(10_000, 50_000, SubscriptionTier.BASIC),)mocker.patch("backend.api.features.chat.routes.get_daily_reset_count",@@ -1436,7 +1436,7 @@ def test_reset_usage_returns_429_when_lock_not_acquired(mocker.patch("backend.api.features.chat.routes.get_global_rate_limits",new_callable=AsyncMock,- return_value=(10_000, 50_000, SubscriptionTier.FREE),+ return_value=(10_000, 50_000, SubscriptionTier.BASIC),)mocker.patch("backend.api.features.chat.routes.get_daily_reset_count",diff --git a/autogpt_platform/backend/backend/api/features/store/db_test.py b/autogpt_platform/backend/backend/api/features/store/db_test.pyindex f3acd867d3..6d8cde4299 100644--- a/autogpt_platform/backend/backend/api/features/store/db_test.py+++ b/autogpt_platform/backend/backend/api/features/store/db_test.py@@ -189,7 +189,7 @@ async def test_create_store_submission(mocker):notifyOnAgentApproved=True,notifyOnAgentRejected=True,timezone="Europe/Delft",- subscriptionTier=prisma.enums.SubscriptionTier.FREE, # type: ignore[reportCallIssue,reportAttributeAccessIssue]+ subscriptionTier=prisma.enums.SubscriptionTier.BASIC, # type: ignore[reportCallIssue,reportAttributeAccessIssue])mock_agent = prisma.models.AgentGraph(id="agent-id",diff --git a/autogpt_platform/backend/backend/api/features/subscription_routes_test.py b/autogpt_platform/backend/backend/api/features/subscription_routes_test.pyindex 96fd8763eb..5f13f8fd22 100644--- a/autogpt_platform/backend/backend/api/features/subscription_routes_test.py+++ b/autogpt_platform/backend/backend/api/features/subscription_routes_test.py@@ -60,19 +60,30 @@ def _stub_pending_subscription_change(mocker: pytest_mock.MockFixture) -> None:)+_DEFAULT_TIER_PRICES: dict[SubscriptionTier, str | None] = {+ SubscriptionTier.BASIC: None, # Legacy: stripe-price-id-basic unset by default.+ SubscriptionTier.PRO: "price_pro",+ SubscriptionTier.MAX: "price_max",+ SubscriptionTier.BUSINESS: None, # Reserved: Business card hidden by default.+}++@pytest.fixture(autouse=True)def _stub_subscription_status_lookups(mocker: pytest_mock.MockFixture) -> None:"""Stub Stripe price + proration lookups used by get_subscription_status.The POST /credits/subscription handler now returns the full subscription- status payload from every branch (same-tier, FREE downgrade, paid→paid+ status payload from every branch (same-tier, BASIC downgrade, paid→paidmodify, checkout creation), so every POST test implicitly hits thesehelpers. Individual tests can override via their own mocker.patch call."""++ async def default_price_id(tier: SubscriptionTier) -> str | None:+ return _DEFAULT_TIER_PRICES.get(tier)+mocker.patch("backend.api.features.v1.get_subscription_price_id",- new_callable=AsyncMock,- return_value=None,+ side_effect=default_price_id,)mocker.patch("backend.api.features.v1.get_proration_credit_cents",@@ -122,15 +133,28 @@ def test_get_subscription_status_pro(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,) -> None:- """GET /credits/subscription returns PRO tier with Stripe price for a PRO user."""+ """GET /credits/subscription returns PRO tier with Stripe prices for all priced tiers."""mock_user = Mock()mock_user.subscription_tier = SubscriptionTier.PRO+ prices = {+ SubscriptionTier.BASIC: "price_basic",+ SubscriptionTier.PRO: "price_pro",+ SubscriptionTier.MAX: "price_max",+ SubscriptionTier.BUSINESS: "price_business",+ }+ amounts = {+ "price_basic": 0,+ "price_pro": 1999,+ "price_max": 4999,+ "price_business": 14999,+ }+async def mock_price_id(tier: SubscriptionTier) -> str | None:- return "price_pro" if tier == SubscriptionTier.PRO else None+ return prices.get(tier)async def mock_stripe_price_amount(price_id: str) -> int:- return 1999 if price_id == "price_pro" else 0+ return amounts.get(price_id, 0)mocker.patch("backend.api.features.v1.get_user_by_id",@@ -158,16 +182,18 @@ def test_get_subscription_status_pro(assert data["tier"] == "PRO"assert data["monthly_cost"] == 1999assert data["tier_costs"]["PRO"] == 1999- assert data["tier_costs"]["BUSINESS"] == 0- assert data["tier_costs"]["FREE"] == 0+ assert data["tier_costs"]["MAX"] == 4999+ assert data["tier_costs"]["BUSINESS"] == 14999+ assert data["tier_costs"]["BASIC"] == 0+ assert "ENTERPRISE" not in data["tier_costs"]assert data["proration_credit_cents"] == 500-def test_get_subscription_status_defaults_to_free(+def test_get_subscription_status_defaults_to_basic(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,) -> None:- """GET /credits/subscription when subscription_tier is None defaults to FREE."""+ """When all LD price IDs are unset, tier_costs is empty and the caller sees cost=0."""mock_user = Mock()mock_user.subscription_tier = None@@ -191,14 +217,9 @@ def test_get_subscription_status_defaults_to_free(assert response.status_code == 200data = response.json()- assert data["tier"] == SubscriptionTier.FREE.value+ assert data["tier"] == SubscriptionTier.BASIC.valueassert data["monthly_cost"] == 0- assert data["tier_costs"] == {- "FREE": 0,- "PRO": 0,- "BUSINESS": 0,- "ENTERPRISE": 0,- }+ assert data["tier_costs"] == {}assert data["proration_credit_cents"] == 0@@ -249,11 +270,11 @@ def test_get_subscription_status_stripe_error_falls_back_to_zero(assert data["tier_costs"]["PRO"] == 0-def test_update_subscription_tier_free_no_payment(+def test_update_subscription_tier_basic_no_payment(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,) -> None:- """POST /credits/subscription to FREE tier when payment disabled skips Stripe."""+ """POST /credits/subscription to BASIC tier when payment disabled skips Stripe."""mock_user = Mock()mock_user.subscription_tier = SubscriptionTier.PRO@@ -274,7 +295,7 @@ def test_update_subscription_tier_free_no_payment(new_callable=AsyncMock,)- response = client.post("/credits/subscription", json={"tier": "FREE"})+ response = client.post("/credits/subscription", json={"tier": "BASIC"})assert response.status_code == 200assert response.json()["url"] == ""@@ -286,7 +307,7 @@ def test_update_subscription_tier_paid_beta_user() -> None:"""POST /credits/subscription for paid tier when payment disabled returns 422."""mock_user = Mock()- mock_user.subscription_tier = SubscriptionTier.FREE+ mock_user.subscription_tier = SubscriptionTier.BASICasync def mock_feature_disabled(*args, **kwargs):return False@@ -313,7 +334,7 @@ def test_update_subscription_tier_paid_requires_urls() -> None:"""POST /credits/subscription for paid tier without success/cancel URLs returns 422."""mock_user = Mock()- mock_user.subscription_tier = SubscriptionTier.FREE+ mock_user.subscription_tier = SubscriptionTier.BASICasync def mock_feature_enabled(*args, **kwargs):return True@@ -339,7 +360,7 @@ def test_update_subscription_tier_creates_checkout() -> None:"""POST /credits/subscription creates Stripe Checkout Session for paid upgrade."""mock_user = Mock()- mock_user.subscription_tier = SubscriptionTier.FREE+ mock_user.subscription_tier = SubscriptionTier.BASICasync def mock_feature_enabled(*args, **kwargs):return True@@ -378,7 +399,7 @@ def test_update_subscription_tier_rejects_open_redirect() -> None:"""POST /credits/subscription rejects success/cancel URLs outside the frontend origin."""mock_user = Mock()- mock_user.subscription_tier = SubscriptionTier.FREE+ mock_user.subscription_tier = SubscriptionTier.BASICasync def mock_feature_enabled(*args, **kwargs):return True@@ -572,14 +593,14 @@ def test_update_subscription_tier_same_tier_stripe_error_returns_502(assert "contact support" in response.json()["detail"].lower()-def test_update_subscription_tier_free_with_payment_schedules_cancel_and_does_not_update_db(+def test_update_subscription_tier_basic_with_payment_schedules_cancel_and_does_not_update_db(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,) -> None:- """Downgrading to FREE schedules Stripe cancellation at period end.+ """Downgrading to BASIC schedules Stripe cancellation at period end.The DB tier must NOT be updated immediately — the customer.subscription.deleted- webhook fires at period end and downgrades to FREE then.+ webhook fires at period end and downgrades to BASIC then."""mock_user = Mock()mock_user.subscription_tier = SubscriptionTier.PRO@@ -605,18 +626,18 @@ def test_update_subscription_tier_free_with_payment_schedules_cancel_and_does_noside_effect=mock_feature_enabled,)- response = client.post("/credits/subscription", json={"tier": "FREE"})+ response = client.post("/credits/subscription", json={"tier": "BASIC"})assert response.status_code == 200mock_cancel.assert_awaited_once()mock_set_tier.assert_not_awaited()-def test_update_subscription_tier_free_cancel_failure_returns_502(+def test_update_subscription_tier_basic_cancel_failure_returns_502(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,) -> None:- """Downgrading to FREE returns 502 with a generic error (no Stripe detail leakage)."""+ """Downgrading to BASIC returns 502 with a generic error (no Stripe detail leakage)."""mock_user = Mock()mock_user.subscription_tier = SubscriptionTier.PRO@@ -639,7 +660,7 @@ def test_update_subscription_tier_free_cancel_failure_returns_502(side_effect=mock_feature_enabled,)- response = client.post("/credits/subscription", json={"tier": "FREE"})+ response = client.post("/credits/subscription", json={"tier": "BASIC"})assert response.status_code == 502detail = response.json()["detail"]@@ -756,6 +777,16 @@ def test_update_subscription_tier_paid_to_paid_modifies_subscription(mock_user = Mock()mock_user.subscription_tier = SubscriptionTier.PRO+ async def price_id_with_business(tier: SubscriptionTier) -> str | None:+ return {+ **_DEFAULT_TIER_PRICES,+ SubscriptionTier.BUSINESS: "price_business",+ }.get(tier)++ mocker.patch(+ "backend.api.features.v1.get_subscription_price_id",+ side_effect=price_id_with_business,+ )mocker.patch("backend.api.features.v1.get_user_by_id",new_callable=AsyncMock,@@ -791,6 +822,49 @@ def test_update_subscription_tier_paid_to_paid_modifies_subscription(checkout_mock.assert_not_awaited()+def test_update_subscription_tier_max_checkout(+ client: fastapi.testclient.TestClient,+ mocker: pytest_mock.MockFixture,+) -> None:+ """POST /credits/subscription from PRO→MAX modifies the existing subscription."""+ mock_user = Mock()+ mock_user.subscription_tier = SubscriptionTier.PRO++ mocker.patch(+ "backend.api.features.v1.get_user_by_id",+ new_callable=AsyncMock,+ return_value=mock_user,+ )+ mocker.patch(+ "backend.api.features.v1.is_feature_enabled",+ new_callable=AsyncMock,+ return_value=True,+ )+ modify_mock = mocker.patch(+ "backend.api.features.v1.modify_stripe_subscription_for_tier",+ new_callable=AsyncMock,+ return_value=True,+ )+ checkout_mock = mocker.patch(+ "backend.api.features.v1.create_subscription_checkout",+ new_callable=AsyncMock,+ )++ response = client.post(+ "/credits/subscription",+ json={+ "tier": "MAX",+ "success_url": f"{TEST_FRONTEND_ORIGIN}/success",+ "cancel_url": f"{TEST_FRONTEND_ORIGIN}/cancel",+ },+ )++ assert response.status_code == 200+ assert response.json()["url"] == ""+ modify_mock.assert_awaited_once_with(TEST_USER_ID, SubscriptionTier.MAX)+ checkout_mock.assert_not_awaited()++def test_update_subscription_tier_admin_granted_paid_to_paid_updates_db_directly(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,@@ -804,6 +878,16 @@ def test_update_subscription_tier_admin_granted_paid_to_paid_updates_db_directlymock_user = Mock()mock_user.subscription_tier = SubscriptionTier.PRO+ async def price_id_with_business(tier: SubscriptionTier) -> str | None:+ return {+ **_DEFAULT_TIER_PRICES,+ SubscriptionTier.BUSINESS: "price_business",+ }.get(tier)++ mocker.patch(+ "backend.api.features.v1.get_subscription_price_id",+ side_effect=price_id_with_business,+ )mocker.patch("backend.api.features.v1.get_user_by_id",new_callable=AsyncMock,@@ -846,6 +930,128 @@ def test_update_subscription_tier_admin_granted_paid_to_paid_updates_db_directlycheckout_mock.assert_not_awaited()+def test_update_subscription_tier_priced_basic_no_sub_falls_through_to_checkout(+ client: fastapi.testclient.TestClient,+ mocker: pytest_mock.MockFixture,+) -> None:+ """Once stripe-price-id-basic is configured, a BASIC user without an active sub+ must hit Stripe Checkout rather than being silently set_subscription_tier'd."""+ mock_user = Mock()+ mock_user.subscription_tier = SubscriptionTier.BASIC++ async def mock_price_id(tier: SubscriptionTier) -> str | None:+ return {+ SubscriptionTier.BASIC: "price_basic",+ SubscriptionTier.PRO: "price_pro",+ SubscriptionTier.MAX: "price_max",+ SubscriptionTier.BUSINESS: "price_business",+ }.get(tier)++ mocker.patch(+ "backend.api.features.v1.get_user_by_id",+ new_callable=AsyncMock,+ return_value=mock_user,+ )+ mocker.patch(+ "backend.api.features.v1.get_subscription_price_id",+ side_effect=mock_price_id,+ )+ mocker.patch(+ "backend.api.features.v1.is_feature_enabled",+ new_callable=AsyncMock,+ return_value=True,+ )+ modify_mock = mocker.patch(+ "backend.api.features.v1.modify_stripe_subscription_for_tier",+ new_callable=AsyncMock,+ return_value=False,+ )+ set_tier_mock = mocker.patch(+ "backend.api.features.v1.set_subscription_tier",+ new_callable=AsyncMock,+ )+ checkout_mock = mocker.patch(+ "backend.api.features.v1.create_subscription_checkout",+ new_callable=AsyncMock,+ return_value="https://checkout.stripe.com/pay/cs_test_priced_basic",+ )++ response = client.post(+ "/credits/subscription",+ json={+ "tier": "PRO",+ "success_url": f"{TEST_FRONTEND_ORIGIN}/success",+ "cancel_url": f"{TEST_FRONTEND_ORIGIN}/cancel",+ },+ )++ assert response.status_code == 200+ assert (+ response.json()["url"] == "https://checkout.stripe.com/pay/cs_test_priced_basic"+ )+ # Priced-BASIC user without an active sub: must NOT silently flip DB tier —+ # they need to set up payment via Checkout.+ set_tier_mock.assert_not_awaited()+ checkout_mock.assert_awaited_once()+ # modify is still called first; returning False just means "no active sub".+ modify_mock.assert_awaited_once_with(TEST_USER_ID, SubscriptionTier.PRO)+++def test_update_subscription_tier_target_without_ld_price_returns_422(+ client: fastapi.testclient.TestClient,+ mocker: pytest_mock.MockFixture,+) -> None:+ """Paid target with no LD-configured Stripe price must fail fast with 422.++ Matches the UI hiding: if `stripe-price-id-pro` resolves to None we can't+ start a Checkout Session anyway, and we don't want to surface an opaque+ Stripe error mid-flow. The handler rejects the request before touching+ Stripe at all.+ """+ mock_user = Mock()+ mock_user.subscription_tier = SubscriptionTier.BASIC++ async def mock_price_id(tier: SubscriptionTier) -> str | None:+ return None # Neither BASIC nor PRO have an LD price.++ mocker.patch(+ "backend.api.features.v1.get_user_by_id",+ new_callable=AsyncMock,+ return_value=mock_user,+ )+ mocker.patch(+ "backend.api.features.v1.get_subscription_price_id",+ side_effect=mock_price_id,+ )+ mocker.patch(+ "backend.api.features.v1.is_feature_enabled",+ new_callable=AsyncMock,+ return_value=True,+ )+ checkout_mock = mocker.patch(+ "backend.api.features.v1.create_subscription_checkout",+ new_callable=AsyncMock,+ )+ modify_mock = mocker.patch(+ "backend.api.features.v1.modify_stripe_subscription_for_tier",+ new_callable=AsyncMock,+ )++ response = client.post(+ "/credits/subscription",+ json={+ "tier": "PRO",+ "success_url": f"{TEST_FRONTEND_ORIGIN}/success",+ "cancel_url": f"{TEST_FRONTEND_ORIGIN}/cancel",+ },+ )++ assert response.status_code == 422+ assert "not available" in response.json()["detail"].lower()+ checkout_mock.assert_not_awaited()+ modify_mock.assert_not_awaited()++def test_update_subscription_tier_paid_to_paid_stripe_error_returns_502(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,@@ -854,6 +1060,16 @@ def test_update_subscription_tier_paid_to_paid_stripe_error_returns_502(mock_user = Mock()mock_user.subscription_tier = SubscriptionTier.PRO+ async def price_id_with_business(tier: SubscriptionTier) -> str | None:+ return {+ **_DEFAULT_TIER_PRICES,+ SubscriptionTier.BUSINESS: "price_business",+ }.get(tier)++ mocker.patch(+ "backend.api.features.v1.get_subscription_price_id",+ side_effect=price_id_with_business,+ )mocker.patch("backend.api.features.v1.get_user_by_id",new_callable=AsyncMock,@@ -882,11 +1098,11 @@ def test_update_subscription_tier_paid_to_paid_stripe_error_returns_502(assert response.status_code == 502-def test_update_subscription_tier_free_no_stripe_subscription(+def test_update_subscription_tier_basic_no_stripe_subscription(client: fastapi.testclient.TestClient,mocker: pytest_mock.MockFixture,) -> None:- """Downgrading to FREE when no Stripe subscription exists updates DB tier directly.+ """Downgrading to BASIC when no Stripe subscription exists updates DB tier directly.Admin-granted paid tiers have no associated Stripe subscription. When such auser requests a self-service downgrade, cancel_stripe_subscription returns False@@ -917,13 +1133,13 @@ def test_update_subscription_tier_free_no_stripe_subscription(new_callable=AsyncMock,)- response = client.post("/credits/subscription", json={"tier": "FREE"})+ response = client.post("/credits/subscription", json={"tier": "BASIC"})assert response.status_code == 200assert response.json()["url"] == ""cancel_mock.assert_awaited_once_with(TEST_USER_ID)# DB tier must be updated immediately — no webhook will fire for a missing sub- set_tier_mock.assert_awaited_once_with(TEST_USER_ID, SubscriptionTier.FREE)+ set_tier_mock.assert_awaited_once_with(TEST_USER_ID, SubscriptionTier.BASIC)def test_get_subscription_status_includes_pending_tier(@@ -1014,6 +1230,16 @@ def test_update_subscription_tier_downgrade_paid_to_paid_schedules(mock_user = Mock()mock_user.subscription_tier = SubscriptionTier.BUSINESS+ async def price_id_with_business(tier: SubscriptionTier) -> str | None:+ return {+ **_DEFAULT_TIER_PRICES,+ SubscriptionTier.BUSINESS: "price_business",+ }.get(tier)++ mocker.patch(+ "backend.api.features.v1.get_subscription_price_id",+ side_effect=price_id_with_business,+ )mocker.patch("backend.api.features.v1.get_user_by_id",new_callable=AsyncMock,diff --git a/autogpt_platform/backend/backend/api/features/v1.py b/autogpt_platform/backend/backend/api/features/v1.pyindex 12a31e6bd1..ad65428a32 100644--- a/autogpt_platform/backend/backend/api/features/v1.py+++ b/autogpt_platform/backend/backend/api/features/v1.py@@ -699,23 +699,23 @@ async def get_user_auto_top_up(class SubscriptionTierRequest(BaseModel):- tier: Literal["FREE", "PRO", "BUSINESS"]+ tier: Literal["BASIC", "PRO", "MAX", "BUSINESS"]success_url: str = ""cancel_url: str = ""class SubscriptionStatusResponse(BaseModel):- tier: Literal["FREE", "PRO", "BUSINESS", "ENTERPRISE"]+ tier: Literal["BASIC", "PRO", "MAX", "BUSINESS", "ENTERPRISE"]monthly_cost: int # amount in cents (Stripe convention)tier_costs: dict[str, int] # tier name -> amount in centsproration_credit_cents: int # unused portion of current sub to convert on upgrade- pending_tier: Optional[Literal["FREE", "PRO", "BUSINESS"]] = None+ pending_tier: Optional[Literal["BASIC", "PRO", "MAX", "BUSINESS"]] = Nonepending_tier_effective_at: Optional[datetime] = Noneurl: str = Field(default="",description=("Populated only when POST /credits/subscription starts a Stripe Checkout"- " Session (FREE → paid upgrade). Empty string in all other branches —"+ " Session (BASIC → paid upgrade). Empty string in all other branches —"" the client redirects to this URL when non-empty."),)@@ -794,24 +794,27 @@ async def get_subscription_status(user_id: Annotated[str, Security(get_user_id)],) -> SubscriptionStatusResponse:user = await get_user_by_id(user_id)- tier = user.subscription_tier or SubscriptionTier.FREE+ tier = user.subscription_tier or SubscriptionTier.BASIC- paid_tiers = [SubscriptionTier.PRO, SubscriptionTier.BUSINESS]+ priceable_tiers = [+ SubscriptionTier.BASIC,+ SubscriptionTier.PRO,+ SubscriptionTier.MAX,+ SubscriptionTier.BUSINESS,+ ]price_ids = await asyncio.gather(- *[get_subscription_price_id(t) for t in paid_tiers]+ *[get_subscription_price_id(t) for t in priceable_tiers])- tier_costs: dict[str, int] = {- SubscriptionTier.FREE.value: 0,- SubscriptionTier.ENTERPRISE.value: 0,- }-async def _cost(pid: str | None) -> int:return (await _get_stripe_price_amount(pid) or 0) if pid else 0costs = await asyncio.gather(*[_cost(pid) for pid in price_ids])- for t, cost in zip(paid_tiers, costs):- tier_costs[t.value] = cost++ tier_costs: dict[str, int] = {}+ for t, pid, cost in zip(priceable_tiers, price_ids, costs):+ if pid:+ tier_costs[t.value] = costcurrent_monthly_cost = tier_costs.get(tier.value, 0)proration_credit = await get_proration_credit_cents(user_id, current_monthly_cost)@@ -838,13 +841,13 @@ async def get_subscription_status()if pending is not None:pending_tier_enum, pending_effective_at = pending- if pending_tier_enum == SubscriptionTier.FREE:- response.pending_tier = "FREE"- elif pending_tier_enum == SubscriptionTier.PRO:- response.pending_tier = "PRO"- elif pending_tier_enum == SubscriptionTier.BUSINESS:- response.pending_tier = "BUSINESS"- if response.pending_tier is not None:+ if pending_tier_enum in (+ SubscriptionTier.BASIC,+ SubscriptionTier.PRO,+ SubscriptionTier.MAX,+ SubscriptionTier.BUSINESS,+ ):+ response.pending_tier = pending_tier_enum.valueresponse.pending_tier_effective_at = pending_effective_atreturn response@@ -860,23 +863,25 @@ async def update_subscription_tier(request: SubscriptionTierRequest,user_id: Annotated[str, Security(get_user_id)],) -> SubscriptionStatusResponse:- # Pydantic validates tier is one of FREE/PRO/BUSINESS via Literal type.+ # Pydantic validates tier is one of BASIC/PRO/MAX/BUSINESS via Literal type.tier = SubscriptionTier(request.tier)# ENTERPRISE tier is admin-managed — block self-service changes from ENTERPRISE users.user = await get_user_by_id(user_id)- if (user.subscription_tier or SubscriptionTier.FREE) == SubscriptionTier.ENTERPRISE:+ if (+ user.subscription_tier or SubscriptionTier.BASIC+ ) == SubscriptionTier.ENTERPRISE:raise HTTPException(status_code=403,detail="ENTERPRISE subscription changes must be managed by an administrator",)# Same-tier request = "stay on my current tier" = cancel any pending- # scheduled change (paid→paid downgrade or paid→FREE cancel). This is the+ # scheduled change (paid→paid downgrade or paid→BASIC cancel). This is the# collapsed behaviour that replaces the old /credits/subscription/cancel-pending# route. Safe when no pending change exists: release_pending_subscription_schedule# returns False and we simply return the current status.- if (user.subscription_tier or SubscriptionTier.FREE) == tier:+ if (user.subscription_tier or SubscriptionTier.BASIC) == tier:try:await release_pending_subscription_schedule(user_id)except stripe.StripeError as e:@@ -898,22 +903,22 @@ async def update_subscription_tier(Flag.ENABLE_PLATFORM_PAYMENT, user_id, default=False)- # Downgrade to FREE: schedule Stripe cancellation at period end so the user- # keeps their tier for the time they already paid for. The DB tier is NOT- # updated here when a subscription exists — the customer.subscription.deleted- # webhook fires at period end and downgrades to FREE then.- # Exception: if the user has no active Stripe subscription (e.g. admin-granted- # tier), cancel_stripe_subscription returns False and we update the DB tier- # immediately since no webhook will ever fire.- # When payment is disabled entirely, update the DB tier directly.- if tier == SubscriptionTier.FREE:+ current_tier = user.subscription_tier or SubscriptionTier.BASIC+ target_price_id, current_tier_price_id = await asyncio.gather(+ get_subscription_price_id(tier),+ get_subscription_price_id(current_tier),+ )++ # Legacy cancel: target BASIC + stripe-price-id-basic unset. Schedule Stripe+ # cancellation at period end; cancel_at_period_end=True lets the webhook flip+ # the DB tier. No active sub (admin-granted) or payment disabled → DB flip.+ # Once stripe-price-id-basic is configured, BASIC becomes a real sub and falls+ # through to the modify/checkout flow below.+ if tier == SubscriptionTier.BASIC and target_price_id is None:if payment_enabled:try:had_subscription = await cancel_stripe_subscription(user_id)except stripe.StripeError as e:- # Log full Stripe error server-side but return a generic message- # to the client — raw Stripe errors can leak customer/sub IDs and- # infrastructure config details.logger.exception("Stripe error cancelling subscription for user %s: %s",user_id,@@ -927,39 +932,37 @@ async def update_subscription_tier(),)if not had_subscription:- # No active Stripe subscription found — the user was on an- # admin-granted tier. Update DB immediately since the- # subscription.deleted webhook will never fire.await set_subscription_tier(user_id, tier)return await get_subscription_status(user_id)await set_subscription_tier(user_id, tier)return await get_subscription_status(user_id)- # Paid tier changes require payment to be enabled — block self-service upgrades- # when the flag is off. Admins use the /api/admin/ routes to set tiers directly.if not payment_enabled:raise HTTPException(status_code=422,- detail=f"Subscription not available for tier {tier}",+ detail=f"Subscription not available for tier {tier.value}",)- # Paid→paid tier change: if the user already has a Stripe subscription,- # modify it in-place with proration instead of creating a new Checkout- # Session. This preserves remaining paid time and avoids double-charging.- # The customer.subscription.updated webhook fires and updates the DB tier.- current_tier = user.subscription_tier or SubscriptionTier.FREE- if current_tier in (SubscriptionTier.PRO, SubscriptionTier.BUSINESS):+ # Target has no LD price — not provisionable (matches the GET hiding).+ if target_price_id is None:+ raise HTTPException(+ status_code=422,+ detail=f"Subscription not available for tier {tier.value}",+ )++ # User has an active Stripe subscription (current tier has an LD price):+ # modify it in-place. modify_stripe_subscription_for_tier returns False when no+ # active sub exists — that's only a "DB-only flip is OK" signal for admin-granted+ # paid tiers (PRO/BUSINESS with no Stripe record). Priced-BASIC users without a+ # sub must still go through Checkout so they set up payment.+ if current_tier_price_id is not None:try:modified = await modify_stripe_subscription_for_tier(user_id, tier)if modified:return await get_subscription_status(user_id)- # modify_stripe_subscription_for_tier returns False when no active- # Stripe subscription exists — i.e. the user has an admin-granted- # paid tier with no Stripe record. In that case, update the DB- # tier directly (same as the FREE-downgrade path for admin-granted- # users) rather than sending them through a new Checkout Session.- await set_subscription_tier(user_id, tier)- return await get_subscription_status(user_id)+ if current_tier != SubscriptionTier.BASIC:+ await set_subscription_tier(user_id, tier)+ return await get_subscription_status(user_id)except ValueError as e:raise HTTPException(status_code=422, detail=str(e))except stripe.StripeError as e:@@ -974,7 +977,7 @@ async def update_subscription_tier(),)- # Paid upgrade from FREE → create Stripe Checkout Session.+ # No active Stripe subscription → create Stripe Checkout Session.if not request.success_url or not request.cancel_url:raise HTTPException(status_code=422,diff --git a/autogpt_platform/backend/backend/copilot/rate_limit.py b/autogpt_platform/backend/backend/copilot/rate_limit.pyindex 66f8b82f07..a582463cb5 100644--- a/autogpt_platform/backend/backend/copilot/rate_limit.py+++ b/autogpt_platform/backend/backend/copilot/rate_limit.py@@ -73,8 +73,9 @@ class SubscriptionTier(str, Enum):from prisma.enums import SubscriptionTier"""- FREE = "FREE"+ BASIC = "BASIC"PRO = "PRO"+ MAX = "MAX"BUSINESS = "BUSINESS"ENTERPRISE = "ENTERPRISE"@@ -83,14 +84,16 @@ class SubscriptionTier(str, Enum):# Intentionally int (not float): keeps limits as whole microdollars and avoids# floating-point rounding. If fractional multipliers are ever needed, change# the type and round the result in get_global_rate_limits().+# BUSINESS matches ENTERPRISE (60x); MAX sits at 20x as the self-service $320 tier.TIER_MULTIPLIERS: dict[SubscriptionTier, int] = {- SubscriptionTier.FREE: 1,+ SubscriptionTier.BASIC: 1,SubscriptionTier.PRO: 5,- SubscriptionTier.BUSINESS: 20,+ SubscriptionTier.MAX: 20,+ SubscriptionTier.BUSINESS: 60,SubscriptionTier.ENTERPRISE: 60,}-DEFAULT_TIER = SubscriptionTier.FREE+DEFAULT_TIER = SubscriptionTier.BASICclass UsageWindow(BaseModel):diff --git a/autogpt_platform/backend/backend/copilot/rate_limit_test.py b/autogpt_platform/backend/backend/copilot/rate_limit_test.pyindex 3787796c17..9ea0ba413c 100644--- a/autogpt_platform/backend/backend/copilot/rate_limit_test.py+++ b/autogpt_platform/backend/backend/copilot/rate_limit_test.py@@ -346,19 +346,21 @@ class TestRecordCostUsage:class TestSubscriptionTier:def test_tier_values(self):- assert SubscriptionTier.FREE.value == "FREE"+ assert SubscriptionTier.BASIC.value == "BASIC"assert SubscriptionTier.PRO.value == "PRO"+ assert SubscriptionTier.MAX.value == "MAX"assert SubscriptionTier.BUSINESS.value == "BUSINESS"assert SubscriptionTier.ENTERPRISE.value == "ENTERPRISE"def test_tier_multipliers(self):- assert TIER_MULTIPLIERS[SubscriptionTier.FREE] == 1+ assert TIER_MULTIPLIERS[SubscriptionTier.BASIC] == 1assert TIER_MULTIPLIERS[SubscriptionTier.PRO] == 5- assert TIER_MULTIPLIERS[SubscriptionTier.BUSINESS] == 20+ assert TIER_MULTIPLIERS[SubscriptionTier.MAX] == 20+ assert TIER_MULTIPLIERS[SubscriptionTier.BUSINESS] == 60assert TIER_MULTIPLIERS[SubscriptionTier.ENTERPRISE] == 60- def test_default_tier_is_free(self):- assert DEFAULT_TIER == SubscriptionTier.FREE+ def test_default_tier_is_basic(self):+ assert DEFAULT_TIER == SubscriptionTier.BASICdef test_usage_status_includes_tier(self):now = datetime.now(UTC)@@ -366,7 +368,7 @@ class TestSubscriptionTier:daily=UsageWindow(used=0, limit=100, resets_at=now + timedelta(hours=1)),weekly=UsageWindow(used=0, limit=500, resets_at=now + timedelta(days=1)),)- assert status.tier == SubscriptionTier.FREE+ assert status.tier == SubscriptionTier.BASICdef test_usage_status_with_custom_tier(self):now = datetime.now(UTC)@@ -469,7 +471,7 @@ class TestGetUserTier:Regression test: when ``get_user_tier`` is called before a user recordexists, the DEFAULT_TIER fallback must not be cached. Otherwise, anewly created user with a higher tier (e.g. PRO) would receive the- stale cached FREE tier for up to 5 minutes.+ stale cached BASIC tier for up to 5 minutes."""# First call: user does not exist yetmissing_db = self._mock_user_db(raises=Exception("not found"))@@ -670,7 +672,7 @@ class TestGetGlobalRateLimitsWithTiers:patch("backend.copilot.rate_limit.get_user_tier",new_callable=AsyncMock,- return_value=SubscriptionTier.FREE,+ return_value=SubscriptionTier.BASIC,),patch("backend.util.feature_flag.get_feature_flag_value",@@ -683,7 +685,7 @@ class TestGetGlobalRateLimitsWithTiers:assert daily == 2_500_000assert weekly == 12_500_000- assert tier == SubscriptionTier.FREE+ assert tier == SubscriptionTier.BASIC@pytest.mark.asyncioasync def test_pro_tier_5x_multiplier(self):@@ -708,13 +710,13 @@ class TestGetGlobalRateLimitsWithTiers:assert tier == SubscriptionTier.PRO@pytest.mark.asyncio- async def test_business_tier_20x_multiplier(self):- """Business tier should multiply limits by 20."""+ async def test_max_tier_20x_multiplier(self):+ """Max tier should multiply limits by 20 (self-service $320 tier)."""with (patch("backend.copilot.rate_limit.get_user_tier",new_callable=AsyncMock,- return_value=SubscriptionTier.BUSINESS,+ return_value=SubscriptionTier.MAX,),patch("backend.util.feature_flag.get_feature_flag_value",@@ -727,6 +729,28 @@ class TestGetGlobalRateLimitsWithTiers:assert daily == 50_000_000assert weekly == 250_000_000+ assert tier == SubscriptionTier.MAX++ @pytest.mark.asyncio+ async def test_business_tier_60x_multiplier(self):+ """Business tier should multiply limits by 60 (matches Enterprise capacity)."""+ with (+ patch(+ "backend.copilot.rate_limit.get_user_tier",+ new_callable=AsyncMock,+ return_value=SubscriptionTier.BUSINESS,+ ),+ patch(+ "backend.util.feature_flag.get_feature_flag_value",+ side_effect=self._ld_side_effect(2_500_000, 12_500_000),+ ),+ ):+ daily, weekly, tier = await get_global_rate_limits(+ _USER, 2_500_000, 12_500_000+ )++ assert daily == 150_000_000+ assert weekly == 750_000_000assert tier == SubscriptionTier.BUSINESS@pytest.mark.asyncio@@ -778,9 +802,9 @@ class TestTierLimitsRespected:return _side_effect@pytest.mark.asyncio- async def test_pro_user_allowed_above_free_limit(self):- """A PRO user with usage above the FREE limit should be allowed."""- # Usage: 3M tokens (above FREE limit of 2.5M, below PRO limit of 12.5M)+ async def test_pro_user_allowed_above_basic_limit(self):+ """A PRO user with usage above the BASIC limit should be allowed."""+ # Usage: 3M tokens (above BASIC limit of 2.5M, below PRO limit of 12.5M)mock_redis = AsyncMock()mock_redis.get = AsyncMock(side_effect=["3000000", "3000000"])@@ -811,9 +835,9 @@ class TestTierLimitsRespected:)@pytest.mark.asyncio- async def test_free_user_blocked_at_free_limit(self):- """A FREE user at or above the base limit should be blocked."""- # Usage: 2.5M tokens (at FREE limit of 2.5M)+ async def test_basic_user_blocked_at_basic_limit(self):+ """A BASIC user at or above the base limit should be blocked."""+ # Usage: 2.5M tokens (at BASIC limit of 2.5M)mock_redis = AsyncMock()mock_redis.get = AsyncMock(side_effect=["2500000", "2500000"])@@ -821,7 +845,7 @@ class TestTierLimitsRespected:patch("backend.copilot.rate_limit.get_user_tier",new_callable=AsyncMock,- return_value=SubscriptionTier.FREE,+ return_value=SubscriptionTier.BASIC,),patch("backend.util.feature_flag.get_feature_flag_value",@@ -835,9 +859,9 @@ class TestTierLimitsRespected:daily, weekly, tier = await get_global_rate_limits(_USER, self._BASE_DAILY, self._BASE_WEEKLY)- # FREE: 1x multiplier+ # BASIC: 1x multiplierassert daily == 2_500_000- assert tier == SubscriptionTier.FREE+ assert tier == SubscriptionTier.BASIC# Should raise — 2.5M >= 2.5Mwith pytest.raises(RateLimitExceeded):await check_rate_limit(@@ -1126,7 +1150,7 @@ class TestTierLimitsEnforced:patch("backend.copilot.rate_limit.get_user_tier",new_callable=AsyncMock,- return_value=SubscriptionTier.FREE,+ return_value=SubscriptionTier.BASIC,),patch("backend.util.feature_flag.get_feature_flag_value",@@ -1145,18 +1169,18 @@ class TestTierLimitsEnforced:await check_rate_limit(_USER, daily, weekly)@pytest.mark.asyncio- async def test_free_tier_cannot_bypass_pro_limit(self):- """A FREE-tier user whose usage is within PRO limits but over FREE+ async def test_basic_tier_cannot_bypass_pro_limit(self):+ """A BASIC-tier user whose usage is within PRO limits but over BASIClimits must still be rejected.Negative test: ensures the tier multiplier is applied *before* therate-limit check, so a lower-tier user cannot 'bypass' limits thatwould be acceptable for a higher tier."""- free_daily = self._BASE_DAILY * TIER_MULTIPLIERS[SubscriptionTier.FREE]+ basic_daily = self._BASE_DAILY * TIER_MULTIPLIERS[SubscriptionTier.BASIC]pro_daily = self._BASE_DAILY * TIER_MULTIPLIERS[SubscriptionTier.PRO]- # Usage above FREE limit but below PRO limit- usage = free_daily + 500_000+ # Usage above BASIC limit but below PRO limit+ usage = basic_daily + 500_000assert usage < pro_daily, "test sanity: usage must be under PRO limit"mock_redis = AsyncMock()@@ -1166,7 +1190,7 @@ class TestTierLimitsEnforced:patch("backend.copilot.rate_limit.get_user_tier",new_callable=AsyncMock,- return_value=SubscriptionTier.FREE,+ return_value=SubscriptionTier.BASIC,),patch("backend.util.feature_flag.get_feature_flag_value",@@ -1180,25 +1204,25 @@ class TestTierLimitsEnforced:daily, weekly, tier = await get_global_rate_limits(_USER, self._BASE_DAILY, self._BASE_WEEKLY)- assert tier == SubscriptionTier.FREE- assert daily == free_daily # 1x, not 5x+ assert tier == SubscriptionTier.BASIC+ assert daily == basic_daily # 1x, not 5xwith pytest.raises(RateLimitExceeded) as exc_info:await check_rate_limit(_USER, daily, weekly)assert exc_info.value.window == "daily"@pytest.mark.asyncioasync def test_tier_change_updates_effective_limits(self):- """After upgrading from FREE to BUSINESS, the effective limits must+ """After upgrading from BASIC to BUSINESS, the effective limits mustincrease accordingly.Verifies that the tier multiplier is correctly applied after a tier- change, and that usage that was over the FREE limit is within the new+ change, and that usage that was over the BASIC limit is within the newBUSINESS limit."""- free_daily = self._BASE_DAILY * TIER_MULTIPLIERS[SubscriptionTier.FREE]+ basic_daily = self._BASE_DAILY * TIER_MULTIPLIERS[SubscriptionTier.BASIC]biz_daily = self._BASE_DAILY * TIER_MULTIPLIERS[SubscriptionTier.BUSINESS]- # Usage above FREE limit but below BUSINESS limit- usage = free_daily + 500_000+ # Usage above BASIC limit but below BUSINESS limit+ usage = basic_daily + 500_000assert usage < biz_daily, "test sanity: usage must be under BUSINESS limit"mock_redis = AsyncMock()@@ -1224,7 +1248,7 @@ class TestTierLimitsEnforced:_USER, self._BASE_DAILY, self._BASE_WEEKLY)assert tier == SubscriptionTier.BUSINESS- assert daily == biz_daily # 20x+ assert daily == biz_daily # 60x# Should NOT raise — usage is within the BUSINESS tier allowanceawait check_rate_limit(_USER, daily, weekly)diff --git a/autogpt_platform/backend/backend/data/credit.py b/autogpt_platform/backend/backend/data/credit.pyindex a42ba91be8..85c5fe1fd0 100644--- a/autogpt_platform/backend/backend/data/credit.py+++ b/autogpt_platform/backend/backend/data/credit.py@@ -1302,7 +1302,7 @@ async def _cancel_customer_subscriptions(When ``at_period_end=True``, schedules cancellation at the end of the currentbilling period instead of cancelling immediately — the user keeps their tieruntil the period ends, then ``customer.subscription.deleted`` fires and the- webhook downgrades them to FREE.+ webhook downgrades them to BASIC.Wraps every synchronous Stripe SDK call with run_in_threadpool so the async eventloop is never blocked. Raises stripe.StripeError on list/cancel failure so callers@@ -1364,7 +1364,7 @@ async def cancel_stripe_subscription(user_id: str) -> bool:The subscription stays active until the end of the billing period so the userkeeps their tier for the time they already paid for. The ``customer.subscription.deleted``- webhook fires at period end and downgrades the DB tier to FREE.+ webhook fires at period end and downgrades the DB tier to BASIC.Returns True if at least one subscription was found and scheduled for cancellation,False if the customer had no active/trialing subscriptions (e.g., admin-granted tier@@ -1403,7 +1403,7 @@ async def get_proration_credit_cents(user_id: str, monthly_cost_cents: int) -> iFetches the user's active Stripe subscription to determine how many secondsremain in the current billing period, then calculates the unused portion of- the monthly cost. Returns 0 for FREE/ENTERPRISE users or when no active sub+ the monthly cost. Returns 0 for BASIC/ENTERPRISE users or when no active subis found."""if monthly_cost_cents <= 0:@@ -1442,8 +1442,9 @@ async def get_proration_credit_cents(user_id: str, monthly_cost_cents: int) -> i# (move right) from downgrades (move left); ENTERPRISE is admin-managed and# never reached via self-service flows._TIER_ORDER: tuple[SubscriptionTier, ...] = (- SubscriptionTier.FREE,+ SubscriptionTier.BASIC,SubscriptionTier.PRO,+ SubscriptionTier.MAX,SubscriptionTier.BUSINESS,SubscriptionTier.ENTERPRISE,)@@ -1551,7 +1552,7 @@ async def _schedule_downgrade_at_period_end(``SubscriptionSchedule.create`` if either (a) a schedule is alreadyattached to the subscription or (b) ``cancel_at_period_end=True`` is set.Both conditions mean the user is overwriting a pending change they made- earlier (e.g. BUSINESS→FREE cancel, now switching to BUSINESS→PRO+ earlier (e.g. BUSINESS→BASIC cancel, now switching to BUSINESS→PROdowngrade). We clear the conflicting state first so the new schedule canbe created. These defensive reads serialize through Stripe's own atomicoperations — by the time modify/release returns, the subscription is in a@@ -1669,7 +1670,7 @@ async def modify_stripe_subscription_for_tier(user = await get_user_by_id(user_id)if not user.stripe_customer_id:return False- current_tier = user.subscription_tier or SubscriptionTier.FREE+ current_tier = user.subscription_tier or SubscriptionTier.BASICsub = await _get_active_subscription(user.stripe_customer_id)if sub is None:@@ -1701,7 +1702,7 @@ async def modify_stripe_subscription_for_tier(existing_schedule_id, "modify_stripe_subscription_for_tier")- # If a paid→FREE cancel is pending (cancel_at_period_end=True), clear it+ # If a paid→BASIC cancel is pending (cancel_at_period_end=True), clear it# as part of the upgrade — the user is explicitly choosing to stay on a# paid tier. Without this, the sub would be upgraded AND still cancelled# at period end, leaving a confusing dual state.@@ -1757,7 +1758,7 @@ async def release_pending_subscription_schedule(user_id: str) -> bool:- **Subscription Schedule** (paid→paid downgrade): ``stripe.SubscriptionSchedule.release``detaches the schedule and lets the subscription continue on its currentphase's price.- - **cancel_at_period_end=True** (paid→FREE cancel): clearing that flag via+ - **cancel_at_period_end=True** (paid→BASIC cancel): clearing that flag via``stripe.Subscription.modify`` keeps the subscription active indefinitely.Returns True if a pending change was found and reverted, False otherwise.@@ -1826,7 +1827,7 @@ async def get_pending_subscription_change("""Return ``(pending_tier, effective_at)`` when a change is queued, else ``None``.Reflects both Subscription Schedule phase transitions (paid→paid downgrade)- and ``cancel_at_period_end=True`` (paid→FREE cancel).+ and ``cancel_at_period_end=True`` (paid→BASIC cancel).Cached for 30 seconds per user_id. *Why the cache exists:* this functionruns on every dashboard/home fetch and would otherwise fire@@ -1854,23 +1855,29 @@ async def get_pending_subscription_change(user = await get_user_by_id(user_id)if not user.stripe_customer_id:# Short-circuit for users with no Stripe customer (admin-granted tiers,- # FREE-only users): skip the Stripe API calls entirely.+ # BASIC-only users): skip the Stripe API calls entirely.return None- pro_price, biz_price = await asyncio.gather(+ basic_price, pro_price, max_price, business_price = await asyncio.gather(+ get_subscription_price_id(SubscriptionTier.BASIC),get_subscription_price_id(SubscriptionTier.PRO),+ get_subscription_price_id(SubscriptionTier.MAX),get_subscription_price_id(SubscriptionTier.BUSINESS),)price_to_tier: dict[str, SubscriptionTier] = {}+ if basic_price:+ price_to_tier[basic_price] = SubscriptionTier.BASICif pro_price:price_to_tier[pro_price] = SubscriptionTier.PRO- if biz_price:- price_to_tier[biz_price] = SubscriptionTier.BUSINESS+ if max_price:+ price_to_tier[max_price] = SubscriptionTier.MAX+ if business_price:+ price_to_tier[business_price] = SubscriptionTier.BUSINESSif not price_to_tier:logger.warning("get_pending_subscription_change: no Stripe price IDs resolvable for"- " PRO/BUSINESS (LaunchDarkly fetch failed?); raising to bypass the"- " None cache so the next request retries fresh"+ " BASIC/PRO/MAX/BUSINESS (LaunchDarkly fetch failed?); raising to bypass"+ " the None cache so the next request retries fresh")raise PendingChangeUnknown("Stripe price lookup failed; pending-change state cannot be determined"@@ -1884,7 +1891,7 @@ async def get_pending_subscription_change(return Noneeffective_at = datetime.fromtimestamp(period_end, tz=timezone.utc)if sub.cancel_at_period_end:- return SubscriptionTier.FREE, effective_at+ return SubscriptionTier.BASIC, effective_atif not sub.schedule:return Noneschedule_id = sub.schedule if isinstance(sub.schedule, str) else sub.schedule.id@@ -1943,11 +1950,13 @@ async def get_subscription_price_id(tier: SubscriptionTier) -> str | None:``cache_none=False`` prevents a transient LD failure from caching ``None``and blocking subscription upgrades for the full 60-second TTL window.- A tier with no configured flag (FREE, ENTERPRISE) returns ``None`` from an- O(1) dict lookup before hitting LD, so the extra LD call is never made.+ ENTERPRISE has no LD flag and returns None from an O(1) dict lookup before+ hitting LD, so the extra LD call is never made."""flag_map = {+ SubscriptionTier.BASIC: Flag.STRIPE_PRICE_BASIC,SubscriptionTier.PRO: Flag.STRIPE_PRICE_PRO,+ SubscriptionTier.MAX: Flag.STRIPE_PRICE_MAX,SubscriptionTier.BUSINESS: Flag.STRIPE_PRICE_BUSINESS,}flag = flag_map.get(tier)@@ -2061,7 +2070,7 @@ async def sync_subscription_from_stripe(stripe_subscription: dict) -> None:# ENTERPRISE user to a different tier — if a user on ENTERPRISE somehow has# a self-service Stripe sub, it's a data-consistency issue for an operator,# not something the webhook should automatically "fix".- current_tier = user.subscriptionTier or SubscriptionTier.FREE+ current_tier = user.subscriptionTier or SubscriptionTier.BASICif current_tier == SubscriptionTier.ENTERPRISE:logger.warning("sync_subscription_from_stripe: refusing to overwrite ENTERPRISE tier"@@ -2078,17 +2087,23 @@ async def sync_subscription_from_stripe(stripe_subscription: dict) -> None:items = stripe_subscription.get("items", {}).get("data", [])if items:price_id = items[0].get("price", {}).get("id", "")- pro_price, biz_price = await asyncio.gather(+ basic_price, pro_price, max_price, business_price = await asyncio.gather(+ get_subscription_price_id(SubscriptionTier.BASIC),get_subscription_price_id(SubscriptionTier.PRO),+ get_subscription_price_id(SubscriptionTier.MAX),get_subscription_price_id(SubscriptionTier.BUSINESS),)- if price_id and pro_price and price_id == pro_price:+ if price_id and basic_price and price_id == basic_price:+ tier = SubscriptionTier.BASIC+ elif price_id and pro_price and price_id == pro_price:tier = SubscriptionTier.PRO- elif price_id and biz_price and price_id == biz_price:+ elif price_id and max_price and price_id == max_price:+ tier = SubscriptionTier.MAX+ elif price_id and business_price and price_id == business_price:tier = SubscriptionTier.BUSINESSelse:# Unknown or unconfigured price ID — preserve the user's current tier- # rather than defaulting to FREE. This prevents accidental downgrades+ # rather than defaulting to BASIC. This prevents accidental downgrades# during a price migration or when LD flags are not yet configured.logger.warning("sync_subscription_from_stripe: unknown price %s for customer %s,"@@ -2099,7 +2114,7 @@ async def sync_subscription_from_stripe(stripe_subscription: dict) -> None:returnelse:# A subscription was cancelled or ended. DO NOT unconditionally downgrade- # to FREE — Stripe does not guarantee webhook delivery order, so a+ # to BASIC — Stripe does not guarantee webhook delivery order, so a# `customer.subscription.deleted` for the OLD sub can arrive after we've# already processed `customer.subscription.created` for a new paid sub.# Ask Stripe whether any OTHER active/trialing subs exist for this@@ -2154,7 +2169,7 @@ async def sync_subscription_from_stripe(stripe_subscription: dict) -> None:current_tier.value,)return- tier = SubscriptionTier.FREE+ tier = SubscriptionTier.BASIC# Idempotency: Stripe retries webhooks on delivery failure, and several event# types map to the same final tier. Skip the DB write + cache invalidation# when the tier is already correct to avoid redundant writes on replay.@@ -2175,7 +2190,7 @@ async def sync_subscription_from_stripe(stripe_subscription: dict) -> None:# set_subscription_tier writes BUSINESS to the DB. If Stripe delivers# the PRO `customer.subscription.deleted` event concurrently and it# processes after the PRO cancel but before set_subscription_tier- # commits, the user could momentarily appear as FREE in the DB.+ # commits, the user could momentarily appear as BASIC in the DB.# This window is very short in practice (two sequential awaits),# but is a known limitation of the current webhook-driven approach.# A future improvement would be to write the new tier first, then@@ -2235,7 +2250,7 @@ async def handle_subscription_payment_failure(invoice: dict) -> None:- Balance sufficient → deduct from balance, then pay the Stripe invoice soStripe stops retrying it. The sub stays intact and the user keeps their tier.- - Balance insufficient → cancel Stripe sub immediately, downgrade to FREE.+ - Balance insufficient → cancel Stripe sub immediately, downgrade to BASIC.Cancelling here avoids further Stripe retries on an invoice we cannot cover."""customer_id = invoice.get("customer")@@ -2253,7 +2268,7 @@ async def handle_subscription_payment_failure(invoice: dict) -> None:)return- current_tier = user.subscriptionTier or SubscriptionTier.FREE+ current_tier = user.subscriptionTier or SubscriptionTier.BASICif current_tier == SubscriptionTier.ENTERPRISE:logger.warning("handle_subscription_payment_failure: skipping ENTERPRISE user %s"@@ -2318,12 +2333,12 @@ async def handle_subscription_payment_failure(invoice: dict) -> None:except InsufficientBalanceError:# Balance insufficient — cancel Stripe subscription first, then downgrade DB.# Order matters: if we downgrade the DB first and the Stripe cancel fails, the- # user is permanently stuck on FREE while Stripe continues billing them.+ # user is permanently stuck on BASIC while Stripe continues billing them.# Cancelling Stripe first is safe: if the DB write then fails, the webhook# customer.subscription.deleted will fire and correct the tier eventually.logger.info("handle_subscription_payment_failure: insufficient balance for user %s;"- " cancelling Stripe sub %s then downgrading to FREE",+ " cancelling Stripe sub %s then downgrading to BASIC",user.id,sub_id,)@@ -2339,7 +2354,7 @@ async def handle_subscription_payment_failure(invoice: dict) -> None:customer_id,)return- await set_subscription_tier(user.id, SubscriptionTier.FREE)+ await set_subscription_tier(user.id, SubscriptionTier.BASIC)async def admin_get_user_history(diff --git a/autogpt_platform/backend/backend/data/credit_subscription_test.py b/autogpt_platform/backend/backend/data/credit_subscription_test.pyindex d38f71d09e..b940516e38 100644--- a/autogpt_platform/backend/backend/data/credit_subscription_test.py+++ b/autogpt_platform/backend/backend/data/credit_subscription_test.py@@ -50,11 +50,13 @@ async def test_set_subscription_tier_downgrade():),patch("backend.data.credit.get_user_by_id"),):- # Downgrade to FREE should not raise- await set_subscription_tier("user-1", SubscriptionTier.FREE)+ # Downgrade to BASIC should not raise+ await set_subscription_tier("user-1", SubscriptionTier.BASIC)-def _make_user(user_id: str = "user-1", tier: SubscriptionTier = SubscriptionTier.FREE):+def _make_user(+ user_id: str = "user-1", tier: SubscriptionTier = SubscriptionTier.BASIC+):mock_user = MagicMock(spec=User)mock_user.id = user_idmock_user.subscriptionTier = tier@@ -172,7 +174,7 @@ async def test_sync_subscription_from_stripe_enterprise_not_overwritten():@pytest.mark.asyncioasync def test_sync_subscription_from_stripe_cancelled():- """When the only active sub is cancelled, the user is downgraded to FREE."""+ """When the only active sub is cancelled, the user is downgraded to BASIC."""mock_user = _make_user(tier=SubscriptionTier.PRO)stripe_sub = {"id": "sub_old",@@ -197,7 +199,7 @@ async def test_sync_subscription_from_stripe_cancelled():) as mock_set,):await sync_subscription_from_stripe(stripe_sub)- mock_set.assert_awaited_once_with("user-1", SubscriptionTier.FREE)+ mock_set.assert_awaited_once_with("user-1", SubscriptionTier.BASIC)@pytest.mark.asyncio@@ -206,7 +208,7 @@ async def test_sync_subscription_from_stripe_cancelled_but_other_active_sub_exisThis covers the race condition where `customer.subscription.deleted` forthe old sub arrives after `customer.subscription.created` for the new sub- was already processed. Unconditionally downgrading to FREE here would+ was already processed. Unconditionally downgrading to BASIC here wouldimmediately undo the user's upgrade."""mock_user = _make_user(tier=SubscriptionTier.BUSINESS)@@ -243,7 +245,7 @@ async def test_sync_subscription_from_stripe_cancelled_but_other_active_sub_exis) as mock_set,):await sync_subscription_from_stripe(stripe_sub)- # Must NOT write FREE — another active sub is still present.+ # Must NOT write BASIC — another active sub is still present.mock_set.assert_not_awaited()@@ -514,7 +516,7 @@ async def test_cancel_stripe_subscription_releases_attached_schedule_first():Stripe rejects ``modify(cancel_at_period_end=True)`` with HTTP 400 when thesubscription has an attached schedule (e.g. user queued a BUSINESS→PRO- downgrade and now clicks "Downgrade to FREE"). Without the pre-release,+ downgrade and now clicks "Downgrade to BASIC"). Without the pre-release,the API handler would surface a 502 to the user."""mock_subscriptions = MagicMock()@@ -579,7 +581,7 @@ async def test_get_proration_credit_cents_no_stripe_customer_returns_zero():@pytest.mark.asyncioasync def test_get_proration_credit_cents_zero_cost_returns_zero():- """FREE tier users (cost=0) return 0 without calling get_user_by_id."""+ """BASIC tier users (cost=0) return 0 without calling get_user_by_id."""with patch("backend.data.credit.get_user_by_id", new_callable=AsyncMock) as mock_get_user:@@ -689,7 +691,7 @@ async def test_sync_subscription_from_stripe_missing_customer_key_returns_early(@pytest.mark.asyncioasync def test_sync_subscription_from_stripe_unknown_price_id_preserves_current_tier():- """Unknown price_id should preserve the current tier, not default to FREE (no DB write)."""+ """Unknown price_id should preserve the current tier, not default to BASIC (no DB write)."""mock_user = _make_user(tier=SubscriptionTier.PRO)stripe_sub = {"customer": "cus_123",@@ -720,7 +722,7 @@ async def test_sync_subscription_from_stripe_unknown_price_id_preserves_current_@pytest.mark.asyncioasync def test_sync_subscription_from_stripe_unconfigured_ld_price_preserves_current_tier():- """When LD flags are unconfigured (None price IDs), the current tier should be preserved, not defaulted to FREE."""+ """When LD flags are unconfigured (None price IDs), the current tier should be preserved, not defaulted to BASIC."""mock_user = _make_user(tier=SubscriptionTier.PRO)stripe_sub = {"customer": "cus_123",@@ -790,6 +792,56 @@ async def test_sync_subscription_from_stripe_business_tier():mock_set.assert_awaited_once_with("user-1", SubscriptionTier.BUSINESS)+async def test_sync_subscription_from_stripe_basic_tier_via_ld_price():+ """BASIC price_id via LD should reconcile the user to BASIC.++ Protects the new stripe-price-id-basic reconciliation path — webhooks for a+ priced-BASIC sub must flip the DB tier back to BASIC when the active Stripe+ item matches the configured basic price.+ """+ mock_user = _make_user(tier=SubscriptionTier.PRO)+ stripe_sub = {+ "id": "sub_new",+ "customer": "cus_123",+ "status": "active",+ "items": {"data": [{"price": {"id": "price_basic_monthly"}}]},+ }++ async def mock_price_id(tier: SubscriptionTier) -> str | None:+ if tier == SubscriptionTier.BASIC:+ return "price_basic_monthly"+ if tier == SubscriptionTier.PRO:+ return "price_pro_monthly"+ if tier == SubscriptionTier.BUSINESS:+ return "price_biz_monthly"+ return None++ empty_list = MagicMock()+ empty_list.data = []+ empty_list.has_more = False++ with (+ patch(+ "backend.data.credit.User.prisma",+ return_value=MagicMock(find_first=AsyncMock(return_value=mock_user)),+ ),+ patch(+ "backend.data.credit.get_subscription_price_id",+ side_effect=mock_price_id,+ ),+ patch(+ "backend.data.credit.stripe.Subscription.list",+ return_value=empty_list,+ ),+ patch(+ "backend.data.credit.set_subscription_tier", new_callable=AsyncMock+ ) as mock_set,+ ):+ await sync_subscription_from_stripe(stripe_sub)+ mock_set.assert_awaited_once_with("user-1", SubscriptionTier.BASIC)++@pytest.mark.asyncioasync def test_sync_subscription_from_stripe_cancels_stale_subs():"""When a new subscription becomes active, older active subs are cancelled.@@ -910,11 +962,41 @@ async def test_get_subscription_price_id_pro():@pytest.mark.asyncio-async def test_get_subscription_price_id_free_returns_none():+async def test_get_subscription_price_id_basic_returns_ld_flag():+ from backend.data.credit import get_subscription_price_id++ get_subscription_price_id.cache_clear() # type: ignore[attr-defined]+ with patch(+ "backend.data.credit.get_feature_flag_value",+ new_callable=AsyncMock,+ return_value="price_basic_monthly",+ ):+ price_id = await get_subscription_price_id(SubscriptionTier.BASIC)+ assert price_id == "price_basic_monthly"+ get_subscription_price_id.cache_clear() # type: ignore[attr-defined]+++async def test_get_subscription_price_id_max():from backend.data.credit import get_subscription_price_id- # FREE tier bypasses the LD flag lookup entirely (returns None before fetch).- price_id = await get_subscription_price_id(SubscriptionTier.FREE)+ get_subscription_price_id.cache_clear() # type: ignore[attr-defined]+ with patch(+ "backend.data.credit.get_feature_flag_value",+ new_callable=AsyncMock,+ return_value="price_max_monthly",+ ):+ price_id = await get_subscription_price_id(SubscriptionTier.MAX)+ assert price_id == "price_max_monthly"+ get_subscription_price_id.cache_clear() # type: ignore[attr-defined]+++async def test_get_subscription_price_id_enterprise_returns_none():+ from backend.data.credit import get_subscription_price_id++ # ENTERPRISE bypasses the LD flag lookup entirely (returns None before fetch).+ price_id = await get_subscription_price_id(SubscriptionTier.ENTERPRISE)assert price_id is None@@ -991,7 +1073,7 @@ async def test_cancel_stripe_subscription_raises_on_cancel_error():@pytest.mark.asyncioasync def test_sync_subscription_from_stripe_metadata_user_id_matches():"""metadata.user_id matching the DB user is accepted and the tier is updated normally."""- mock_user = _make_user(user_id="user-1", tier=SubscriptionTier.FREE)+ mock_user = _make_user(user_id="user-1", tier=SubscriptionTier.BASIC)stripe_sub = {"id": "sub_new","customer": "cus_123",@@ -1035,7 +1117,7 @@ async def test_sync_subscription_from_stripe_metadata_user_id_mismatch_blocked()A customer↔user mapping inconsistency (e.g. a customer ID reassigned ora corrupted DB row) must never silently update the wrong user's tier."""- mock_user = _make_user(user_id="user-1", tier=SubscriptionTier.FREE)+ mock_user = _make_user(user_id="user-1", tier=SubscriptionTier.BASIC)stripe_sub = {"id": "sub_new","customer": "cus_123",@@ -1061,7 +1143,7 @@ async def test_sync_subscription_from_stripe_metadata_user_id_mismatch_blocked()@pytest.mark.asyncioasync def test_sync_subscription_from_stripe_no_metadata_user_id_skips_check():"""Absence of metadata.user_id (e.g. subs created outside Checkout) skips the cross-check."""- mock_user = _make_user(user_id="user-1", tier=SubscriptionTier.FREE)+ mock_user = _make_user(user_id="user-1", tier=SubscriptionTier.BASIC)stripe_sub = {"id": "sub_new","customer": "cus_123",@@ -1201,7 +1283,7 @@ async def test_modify_stripe_subscription_for_tier_modifies_existing_sub():mock_user = MagicMock(spec=User)mock_user.stripe_customer_id = "cus_abc"- mock_user.subscription_tier = SubscriptionTier.FREE+ mock_user.subscription_tier = SubscriptionTier.BASICwith (patch(@@ -1338,7 +1420,7 @@ async def test_modify_stripe_subscription_for_tier_returns_false_when_no_sub():mock_user = MagicMock(spec=User)mock_user.stripe_customer_id = "cus_abc"- mock_user.subscription_tier = SubscriptionTier.FREE+ mock_user.subscription_tier = SubscriptionTier.BASICwith (patch(@@ -1377,11 +1459,11 @@ async def test_modify_stripe_subscription_for_tier_raises_on_missing_price_id():def test_tier_order_helpers():- assert is_tier_upgrade(SubscriptionTier.FREE, SubscriptionTier.PRO) is True+ assert is_tier_upgrade(SubscriptionTier.BASIC, SubscriptionTier.PRO) is Trueassert is_tier_upgrade(SubscriptionTier.PRO, SubscriptionTier.BUSINESS) is Trueassert is_tier_upgrade(SubscriptionTier.BUSINESS, SubscriptionTier.PRO) is Falseassert is_tier_downgrade(SubscriptionTier.BUSINESS, SubscriptionTier.PRO) is True- assert is_tier_downgrade(SubscriptionTier.PRO, SubscriptionTier.FREE) is True+ assert is_tier_downgrade(SubscriptionTier.PRO, SubscriptionTier.BASIC) is Trueassert is_tier_downgrade(SubscriptionTier.PRO, SubscriptionTier.BUSINESS) is False@@ -1569,7 +1651,7 @@ async def test_release_pending_subscription_schedule_releases_downgrade_schedule@pytest.mark.asyncioasync def test_release_pending_subscription_schedule_clears_cancel_at_period_end():- """release_pending_subscription_schedule reverts a pending paid→FREE cancel."""+ """release_pending_subscription_schedule reverts a pending paid→BASIC cancel."""mock_sub = stripe.Subscription.construct_from({"id": "sub_pro",@@ -1662,7 +1744,7 @@ async def test_release_pending_subscription_schedule_no_stripe_customer_returns_@pytest.mark.asyncioasync def test_get_pending_subscription_change_cancel_at_period_end():- """cancel_at_period_end=True maps to pending FREE at current_period_end."""+ """cancel_at_period_end=True maps to pending BASIC at current_period_end."""import time as time_modget_pending_subscription_change.cache_clear() # type: ignore[attr-defined]@@ -1711,7 +1793,7 @@ async def test_get_pending_subscription_change_cancel_at_period_end():assert result is not Nonepending_tier, effective_at = result- assert pending_tier == SubscriptionTier.FREE+ assert pending_tier == SubscriptionTier.BASICassert int(effective_at.timestamp()) == period_end@@ -1793,6 +1875,86 @@ async def test_get_pending_subscription_change_from_schedule():assert int(effective_at.timestamp()) == period_end+async def test_get_pending_subscription_change_from_schedule_to_basic():+ """A schedule whose next phase uses the BASIC price maps to pending_tier=BASIC."""+ import time as time_mod++ get_pending_subscription_change.cache_clear() # type: ignore[attr-defined]++ now = int(time_mod.time())+ period_end = now + 10 * 24 * 3600+ mock_sub = stripe.Subscription.construct_from(+ {+ "id": "sub_pro",+ "current_period_end": period_end,+ "cancel_at_period_end": False,+ "schedule": "sub_sched_2",+ },+ "k",+ )+ mock_list = MagicMock()+ mock_list.data = [mock_sub]++ mock_schedule = stripe.SubscriptionSchedule.construct_from(+ {+ "id": "sub_sched_2",+ "phases": [+ {+ "start_date": now - 3 * 24 * 3600,+ "end_date": period_end,+ "items": [{"price": "price_pro_monthly"}],+ },+ {+ "start_date": period_end,+ "items": [{"price": "price_basic_monthly"}],+ },+ ],+ },+ "k",+ )++ mock_user = MagicMock()+ mock_user.stripe_customer_id = "cus_abc"++ async def mock_price_id(tier: SubscriptionTier) -> str | None:+ if tier == SubscriptionTier.BASIC:+ return "price_basic_monthly"+ if tier == SubscriptionTier.PRO:+ return "price_pro_monthly"+ if tier == SubscriptionTier.BUSINESS:+ return "price_biz_monthly"+ return None++ with (+ patch(+ "backend.data.credit.get_user_by_id",+ new_callable=AsyncMock,+ return_value=mock_user,+ ),+ patch(+ "backend.data.credit.get_subscription_price_id",+ side_effect=mock_price_id,+ ),+ patch(+ "backend.data.credit.stripe.Subscription.list_async",+ new_callable=AsyncMock,+ return_value=mock_list,+ ),+ patch(+ "backend.data.credit.stripe.SubscriptionSchedule.retrieve_async",+ new_callable=AsyncMock,+ return_value=mock_schedule,+ ),+ ):+ result = await get_pending_subscription_change("user-1")++ assert result is not None+ pending_tier, effective_at = result+ assert pending_tier == SubscriptionTier.BASIC+ assert int(effective_at.timestamp()) == period_end++@pytest.mark.asyncioasync def test_get_pending_subscription_change_none_when_no_schedule_or_cancel():"""Returns None when neither a schedule nor cancel_at_period_end is set."""diff --git a/autogpt_platform/backend/backend/data/model.py b/autogpt_platform/backend/backend/data/model.pyindex f1d3e1630e..6f7d806bb3 100644--- a/autogpt_platform/backend/backend/data/model.py+++ b/autogpt_platform/backend/backend/data/model.py@@ -72,7 +72,7 @@ class User(BaseModel):None, description="Top up configuration")subscription_tier: SubscriptionTier = Field(- default=SubscriptionTier.FREE, description="User subscription tier"+ default=SubscriptionTier.BASIC, description="User subscription tier")# Notification preferences@@ -148,7 +148,7 @@ class User(BaseModel):integrations=prisma_user.integrations or "",stripe_customer_id=prisma_user.stripeCustomerId,top_up_config=top_up_config,- subscription_tier=prisma_user.subscriptionTier or SubscriptionTier.FREE,+ subscription_tier=prisma_user.subscriptionTier or SubscriptionTier.BASIC,max_emails_per_day=prisma_user.maxEmailsPerDay or 3,notify_on_agent_run=prisma_user.notifyOnAgentRun or True,notify_on_zero_balance=prisma_user.notifyOnZeroBalance or True,diff --git a/autogpt_platform/backend/backend/util/feature_flag.py b/autogpt_platform/backend/backend/util/feature_flag.pyindex 8699fc2eeb..8f7bf86d3c 100644--- a/autogpt_platform/backend/backend/util/feature_flag.py+++ b/autogpt_platform/backend/backend/util/feature_flag.py@@ -44,7 +44,9 @@ class Flag(str, Enum):COPILOT_SDK = "copilot-sdk"COPILOT_DAILY_COST_LIMIT = "copilot-daily-cost-limit-microdollars"COPILOT_WEEKLY_COST_LIMIT = "copilot-weekly-cost-limit-microdollars"+ STRIPE_PRICE_BASIC = "stripe-price-id-basic"STRIPE_PRICE_PRO = "stripe-price-id-pro"+ STRIPE_PRICE_MAX = "stripe-price-id-max"STRIPE_PRICE_BUSINESS = "stripe-price-id-business"GRAPHITI_MEMORY = "graphiti-memory"diff --git a/autogpt_platform/backend/migrations/20260424091957_add_max_tier_and_rename_free_to_basic/migration.sql b/autogpt_platform/backend/migrations/20260424091957_add_max_tier_and_rename_free_to_basic/migration.sqlnew file mode 100644index 0000000000..10d6bdecc8--- /dev/null+++ b/autogpt_platform/backend/migrations/20260424091957_add_max_tier_and_rename_free_to_basic/migration.sql@@ -0,0 +1,5 @@+-- Add MAX between PRO and BUSINESS and rename FREE → BASIC. ADD VALUE BEFORE+-- preserves existing rows on BUSINESS/ENTERPRISE; RENAME VALUE updates the+-- label in place so existing FREE rows (the common case) remain valid.+ALTER TYPE "SubscriptionTier" ADD VALUE IF NOT EXISTS 'MAX' BEFORE 'BUSINESS';+ALTER TYPE "SubscriptionTier" RENAME VALUE 'FREE' TO 'BASIC';diff --git a/autogpt_platform/backend/schema.prisma b/autogpt_platform/backend/schema.prismaindex b6ddc7cad0..a689151934 100644--- a/autogpt_platform/backend/schema.prisma+++ b/autogpt_platform/backend/schema.prisma@@ -41,12 +41,12 @@ model User {timezone String @default("not-set")// CoPilot subscription tier — controls rate-limit multipliers.- // Multipliers applied in get_global_rate_limits(): FREE=1x, PRO=5x, BUSINESS=20x, ENTERPRISE=60x.+ // Multipliers applied in get_global_rate_limits(): BASIC=1x, PRO=5x, MAX=20x, BUSINESS=60x, ENTERPRISE=60x.// NOTE: @default(PRO) is intentional for the beta period — all existing and new// users receive PRO-level (5x) rate limits by default. The Python-level constant- // DEFAULT_TIER=FREE (in copilot/rate_limit.py) acts as a code-level fallback when+ // DEFAULT_TIER=BASIC (in copilot/rate_limit.py) acts as a code-level fallback when// the DB value is NULL or unrecognised. At GA, a migration will flip the column- // default to FREE and batch-update users to their billing-derived tiers.+ // default to BASIC and batch-update users to their billing-derived tiers.subscriptionTier SubscriptionTier @default(PRO)// Relations@@ -88,8 +88,9 @@ model User {}enum SubscriptionTier {- FREE+ BASICPRO+ MAXBUSINESSENTERPRISE}diff --git a/autogpt_platform/backend/snapshots/get_rate_limit b/autogpt_platform/backend/snapshots/get_rate_limitindex 3ac1b94222..623f3ee649 100644--- a/autogpt_platform/backend/snapshots/get_rate_limit+++ b/autogpt_platform/backend/snapshots/get_rate_limit@@ -1,7 +1,7 @@{"daily_cost_limit_microdollars": 2500000,"daily_cost_used_microdollars": 500000,- "tier": "FREE",+ "tier": "BASIC","user_email": "[email protected]","user_id": "5e53486c-cf57-477e-ba2a-cb02dc828e1c","weekly_cost_limit_microdollars": 12500000,diff --git a/autogpt_platform/backend/snapshots/reset_user_usage_daily_and_weekly b/autogpt_platform/backend/snapshots/reset_user_usage_daily_and_weeklyindex b5361be34a..17fd49d458 100644--- a/autogpt_platform/backend/snapshots/reset_user_usage_daily_and_weekly+++ b/autogpt_platform/backend/snapshots/reset_user_usage_daily_and_weekly@@ -1,7 +1,7 @@{"daily_cost_limit_microdollars": 2500000,"daily_cost_used_microdollars": 0,- "tier": "FREE",+ "tier": "BASIC","user_email": "[email protected]","user_id": "5e53486c-cf57-477e-ba2a-cb02dc828e1c","weekly_cost_limit_microdollars": 12500000,diff --git a/autogpt_platform/backend/snapshots/reset_user_usage_daily_only b/autogpt_platform/backend/snapshots/reset_user_usage_daily_onlyindex 256d8e893d..72d1888633 100644--- a/autogpt_platform/backend/snapshots/reset_user_usage_daily_only+++ b/autogpt_platform/backend/snapshots/reset_user_usage_daily_only@@ -1,7 +1,7 @@{"daily_cost_limit_microdollars": 2500000,"daily_cost_used_microdollars": 0,- "tier": "FREE",+ "tier": "BASIC","user_email": "[email protected]","user_id": "5e53486c-cf57-477e-ba2a-cb02dc828e1c","weekly_cost_limit_microdollars": 12500000,diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/RateLimitDisplay.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/RateLimitDisplay.tsxindex 024b819699..2c192342ce 100644--- a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/RateLimitDisplay.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/RateLimitDisplay.tsx@@ -6,19 +6,21 @@ import type { UserRateLimitResponse } from "@/app/api/__generated__/models/userRimport { useToast } from "@/components/molecules/Toast/use-toast";import { UsageBar } from "../../components/UsageBar";-const TIERS = ["FREE", "PRO", "BUSINESS", "ENTERPRISE"] as const;+const TIERS = ["BASIC", "PRO", "MAX", "BUSINESS", "ENTERPRISE"] as const;type Tier = (typeof TIERS)[number];const TIER_MULTIPLIERS: Record<Tier, string> = {- FREE: "1x base limits",+ BASIC: "1x base limits",PRO: "5x base limits",- BUSINESS: "20x base limits",+ MAX: "20x base limits",+ BUSINESS: "60x base limits",ENTERPRISE: "60x base limits",};const TIER_COLORS: Record<Tier, string> = {- FREE: "bg-gray-100 text-gray-700",+ BASIC: "bg-gray-100 text-gray-700",PRO: "bg-blue-100 text-blue-700",+ MAX: "bg-indigo-100 text-indigo-700",BUSINESS: "bg-purple-100 text-purple-700",ENTERPRISE: "bg-amber-100 text-amber-700",};@@ -44,7 +46,7 @@ export function RateLimitDisplay({const currentTier = TIERS.includes(data.tier as Tier)? (data.tier as Tier)- : "FREE";+ : "BASIC";async function handleReset() {const msg = resetWeeklydiff --git a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitDisplay.test.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitDisplay.test.tsxindex 08b5db312b..d4a5df3c4e 100644--- a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitDisplay.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitDisplay.test.tsx@@ -34,7 +34,7 @@ function makeData(weekly_cost_limit_microdollars: 50_000_000,daily_cost_used_microdollars: 2_500_000,weekly_cost_used_microdollars: 10_000_000,- tier: "FREE",+ tier: "BASIC",...overrides,};}@@ -71,14 +71,14 @@ describe("RateLimitDisplay", () => {expect(badge.className).toContain("bg-blue-100");});- it("defaults unknown tier to FREE", () => {+ it("defaults unknown tier to BASIC", () => {render(<RateLimitDisplaydata={makeData({ tier: "UNKNOWN" as UserRateLimitResponse["tier"] })}onReset={vi.fn()}/>,);- const badge = screen.getByText("FREE");+ const badge = screen.getByText("BASIC");expect(badge).toBeDefined();});@@ -86,7 +86,7 @@ describe("RateLimitDisplay", () => {render(<RateLimitDisplay data={makeData()} onReset={vi.fn()} />);const select = screen.getByLabelText("Subscription tier");expect(select).toBeDefined();- expect(select.querySelectorAll("option").length).toBe(4);+ expect(select.querySelectorAll("option").length).toBe(5);});it("disables tier dropdown when onTierChange is not provided", () => {@@ -195,7 +195,7 @@ describe("RateLimitDisplay", () => {render(<RateLimitDisplay- data={makeData({ tier: "FREE" })}+ data={makeData({ tier: "BASIC" })}onReset={vi.fn()}onTierChange={onTierChange}/>,@@ -215,14 +215,14 @@ describe("RateLimitDisplay", () => {render(<RateLimitDisplay- data={makeData({ tier: "FREE" })}+ data={makeData({ tier: "BASIC" })}onReset={vi.fn()}onTierChange={onTierChange}/>,);fireEvent.change(screen.getByLabelText("Subscription tier"), {- target: { value: "FREE" },+ target: { value: "BASIC" },});expect(onTierChange).not.toHaveBeenCalled();@@ -234,7 +234,7 @@ describe("RateLimitDisplay", () => {render(<RateLimitDisplay- data={makeData({ tier: "FREE" })}+ data={makeData({ tier: "BASIC" })}onReset={vi.fn()}onTierChange={onTierChange}/>,@@ -253,7 +253,7 @@ describe("RateLimitDisplay", () => {render(<RateLimitDisplay- data={makeData({ tier: "FREE" })}+ data={makeData({ tier: "BASIC" })}onReset={vi.fn()}onTierChange={onTierChange}/>,diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitManager.test.tsx b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitManager.test.tsxindex 8435e6dc6d..423030177b 100644--- a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitManager.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/RateLimitManager.test.tsx@@ -178,7 +178,7 @@ describe("RateLimitManager", () => {weekly_cost_limit_microdollars: 50_000_000,daily_cost_used_microdollars: 2_500_000,weekly_cost_used_microdollars: 10_000_000,- tier: "FREE",+ tier: "BASIC",},});@@ -201,7 +201,7 @@ describe("RateLimitManager", () => {weekly_cost_limit_microdollars: 50_000_000,daily_cost_used_microdollars: 2_500_000,weekly_cost_used_microdollars: 10_000_000,- tier: "FREE",+ tier: "BASIC",},});diff --git a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/useRateLimitManager.test.ts b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/useRateLimitManager.test.tsindex 523af7514b..00ba9303bc 100644--- a/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/useRateLimitManager.test.ts+++ b/autogpt_platform/frontend/src/app/(platform)/admin/rate-limits/components/__tests__/useRateLimitManager.test.ts@@ -32,7 +32,7 @@ function makeRateLimitResponse(overrides = {}) {weekly_cost_limit_microdollars: 50_000_000,daily_cost_used_microdollars: 2_500_000,weekly_cost_used_microdollars: 10_000_000,- tier: "FREE",+ tier: "BASIC",...overrides,};}@@ -304,7 +304,7 @@ describe("useRateLimitManager", () => {});it("handleTierChange calls set tier and re-fetches", async () => {- const initial = makeRateLimitResponse({ tier: "FREE" });+ const initial = makeRateLimitResponse({ tier: "BASIC" });const updated = makeRateLimitResponse({ tier: "PRO" });mockGetV2GetUserRateLimit.mockResolvedValueOnce({ status: 200, data: initial })@@ -371,7 +371,7 @@ describe("useRateLimitManager", () => {});it("handleTierChange throws when set-tier endpoint returns non-200", async () => {- const initial = makeRateLimitResponse({ tier: "FREE" });+ const initial = makeRateLimitResponse({ tier: "BASIC" });mockGetV2GetUserRateLimit.mockResolvedValue({ status: 200, data: initial });mockPostV2SetUserRateLimitTier.mockResolvedValue({ status: 500 });diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsxindex cd1707950c..b3b3798fe4 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/__tests__/CopilotPage.test.tsx@@ -48,7 +48,7 @@ vi.mock("@/app/api/__generated__/endpoints/chat/chat", () => ({const data = {daily: null,weekly: null,- tier: "FREE",+ tier: "BASIC",reset_cost: 0,};if (typeof opts?.query?.select === "function") {diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsageLimits.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsageLimits.test.tsxindex 67595dceec..8331ae2f45 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsageLimits.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsageLimits.test.tsx@@ -38,7 +38,7 @@ afterEach(() => {function makeUsage({dailyPercent = 5,weeklyPercent = 4,- tier = "FREE",+ tier = "BASIC",}: {dailyPercent?: number | null;weeklyPercent?: number | null;diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsxindex db2d4241a8..7d8fd4fe38 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/__tests__/UsagePanelContentRender.test.tsx@@ -29,7 +29,7 @@ function makeUsage(const {dailyPercent = 5,weeklyPercent = 4,- tier = "FREE",+ tier = "BASIC",resetCost = 100,} = overrides;const future = new Date(Date.now() + 3600 * 1000).toISOString();diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/__tests__/BriefingTabContent.test.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/__tests__/BriefingTabContent.test.tsxindex 5dbb3bab17..f85cc3b22f 100644--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/__tests__/BriefingTabContent.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/__tests__/BriefingTabContent.test.tsx@@ -51,7 +51,7 @@ afterEach(() => {function makeUsage({dailyPercent = 5,weeklyPercent = 4,- tier = "FREE",+ tier = "BASIC",resetCost = 500,}: {dailyPercent?: number | null;diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsxindex d8aab67b22..7b4dd359a7 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/SubscriptionTierSection.tsx@@ -143,7 +143,9 @@ export function SubscriptionTierSection() {) : null}<div className="grid grid-cols-1 gap-3 sm:grid-cols-3">- {TIERS.map((tier) => {+ {TIERS.filter(+ (tier) => subscription.tier_costs[tier.key] !== undefined,+ ).map((tier) => {const isCurrent = currentTier === tier.key;const cost = subscription.tier_costs[tier.key] ?? 0;const currentIdx = TIER_ORDER.indexOf(currentTier);@@ -206,7 +208,7 @@ export function SubscriptionTierSection() {})}</div>- {currentTier !== "FREE" && isPaymentEnabled && (+ {currentTier !== "BASIC" && isPaymentEnabled && (<p className="text-sm text-neutral-500">Your subscription is managed through Stripe. Upgrades take effectimmediately. Downgrades take effect at the end of your current billing@@ -225,8 +227,8 @@ export function SubscriptionTierSection() {><Dialog.Content><p className="text-sm text-neutral-600 dark:text-neutral-400">- {confirmDowngradeTo === "FREE"- ? "Downgrading to Free will schedule your subscription to cancel at the end of your current billing period. You keep your current plan until then."+ {confirmDowngradeTo === "BASIC"+ ? "Downgrading to Basic will schedule your subscription to cancel at the end of your current billing period. You keep your current plan until then.": `Switching to ${TIERS.find((t) => t.key === confirmDowngradeTo)?.label ?? confirmDowngradeTo} will take effect at the end of your current billing period. You keep your current plan until then.`}{" "}Are you sure?</p>diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/__tests__/SubscriptionTierSection.test.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/__tests__/SubscriptionTierSection.test.tsxindex 57f3ec844a..cffa430a44 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/__tests__/SubscriptionTierSection.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/__tests__/SubscriptionTierSection.test.tsx@@ -67,9 +67,9 @@ vi.mock("@/components/molecules/Dialog/Dialog", () => ({}));function makeSubscription({- tier = "FREE",+ tier = "BASIC",monthlyCost = 0,- tierCosts = { FREE: 0, PRO: 1999, BUSINESS: 4999, ENTERPRISE: 0 },+ tierCosts = { BASIC: 0, PRO: 1999, MAX: 32000, ENTERPRISE: 0 },prorationCreditCents = 0,pendingTier = null as string | null,pendingTierEffectiveAt = null as Date | string | null,@@ -133,7 +133,7 @@ describe("SubscriptionTierSection", () => {render(<SubscriptionTierSection />);// Just verify we're rendering something (not null) and no tier cardsexpect(screen.queryByText("Pro")).toBeNull();- expect(screen.queryByText("Business")).toBeNull();+ expect(screen.queryByText("Max")).toBeNull();});it("renders error message when subscription fetch fails", () => {@@ -153,54 +153,56 @@ describe("SubscriptionTierSection", () => {expect(screen.getByText(/failed to load subscription info/i)).toBeDefined();});- it("renders all three tier cards for FREE user", () => {+ it("renders all three tier cards for BASIC user", () => {setupMocks();render(<SubscriptionTierSection />);- // Use getAllByText to account for the tier label AND cost display both containing "Free"- expect(screen.getAllByText("Free").length).toBeGreaterThan(0);+ // BASIC tier card is labelled "Basic"; cost displays "Free" for BASIC@$0.+ expect(screen.getByText("Basic")).toBeDefined();+ expect(screen.getByText("Free")).toBeDefined();expect(screen.getByText("Pro")).toBeDefined();- expect(screen.getByText("Business")).toBeDefined();+ expect(screen.getByText("Max")).toBeDefined();});it("shows Current badge on the active tier", () => {setupMocks({ subscription: makeSubscription({ tier: "PRO" }) });render(<SubscriptionTierSection />);expect(screen.getByText("Current")).toBeDefined();- // Upgrade to PRO button should NOT exist; Upgrade to BUSINESS and Downgrade to Free should+ // Upgrade to PRO button should NOT exist; Upgrade to Max and Downgrade to Basic shouldexpect(screen.queryByRole("button", { name: /upgrade to pro/i }),).toBeNull();expect(- screen.getByRole("button", { name: /upgrade to business/i }),+ screen.getByRole("button", { name: /upgrade to max/i }),).toBeDefined();expect(- screen.getByRole("button", { name: /downgrade to free/i }),+ screen.getByRole("button", { name: /downgrade to basic/i }),).toBeDefined();});it("displays tier costs from the API", () => {setupMocks({subscription: makeSubscription({- tier: "FREE",- tierCosts: { FREE: 0, PRO: 1999, BUSINESS: 4999, ENTERPRISE: 0 },+ tier: "BASIC",+ tierCosts: { BASIC: 0, PRO: 1999, MAX: 32000, ENTERPRISE: 0 },}),});render(<SubscriptionTierSection />);expect(screen.getByText("$19.99/mo")).toBeDefined();- expect(screen.getByText("$49.99/mo")).toBeDefined();- // FREE tier label should still be visible (there may be multiple "Free" elements)- expect(screen.getAllByText("Free").length).toBeGreaterThan(0);+ expect(screen.getByText("$320.00/mo")).toBeDefined();+ // BASIC tier card label is "Basic"; its $0 cost renders "Free".+ expect(screen.getByText("Basic")).toBeDefined();+ expect(screen.getByText("Free")).toBeDefined();});it("shows 'Pricing available soon' when tier cost is 0 for a paid tier", () => {setupMocks({subscription: makeSubscription({- tier: "FREE",- tierCosts: { FREE: 0, PRO: 0, BUSINESS: 0, ENTERPRISE: 0 },+ tier: "BASIC",+ tierCosts: { BASIC: 0, PRO: 0, MAX: 0, ENTERPRISE: 0 },}),});render(<SubscriptionTierSection />);- // PRO and BUSINESS with cost=0 should show "Pricing available soon"+ // PRO and MAX with cost=0 should show "Pricing available soon"expect(screen.getAllByText("Pricing available soon")).toHaveLength(2);});@@ -231,7 +233,9 @@ describe("SubscriptionTierSection", () => {setupMocks({ subscription: makeSubscription({ tier: "PRO" }) });render(<SubscriptionTierSection />);- fireEvent.click(screen.getByRole("button", { name: /downgrade to free/i }));+ fireEvent.click(+ screen.getByRole("button", { name: /downgrade to basic/i }),+ );expect(screen.getByRole("dialog")).toBeDefined();// The dialog title text appears in both a div and a button — just check the dialog is open@@ -248,13 +252,15 @@ describe("SubscriptionTierSection", () => {});render(<SubscriptionTierSection />);- fireEvent.click(screen.getByRole("button", { name: /downgrade to free/i }));+ fireEvent.click(+ screen.getByRole("button", { name: /downgrade to basic/i }),+ );fireEvent.click(screen.getByRole("button", { name: /confirm downgrade/i }));await waitFor(() => {expect(mutateFn).toHaveBeenCalledWith(expect.objectContaining({- data: expect.objectContaining({ tier: "FREE" }),+ data: expect.objectContaining({ tier: "BASIC" }),}),);});@@ -264,7 +270,9 @@ describe("SubscriptionTierSection", () => {setupMocks({ subscription: makeSubscription({ tier: "PRO" }) });render(<SubscriptionTierSection />);- fireEvent.click(screen.getByRole("button", { name: /downgrade to free/i }));+ fireEvent.click(+ screen.getByRole("button", { name: /downgrade to basic/i }),+ );expect(screen.getByRole("dialog")).toBeDefined();fireEvent.click(screen.getByRole("button", { name: /^cancel$/i }));@@ -316,16 +324,60 @@ describe("SubscriptionTierSection", () => {it("hides action buttons when payment flag is disabled", () => {mockPaymentEnabled = false;- setupMocks({ subscription: makeSubscription({ tier: "FREE" }) });+ setupMocks({ subscription: makeSubscription({ tier: "BASIC" }) });render(<SubscriptionTierSection />);// Tier cards still visibleexpect(screen.getByText("Pro")).toBeDefined();- expect(screen.getByText("Business")).toBeDefined();+ expect(screen.getByText("Max")).toBeDefined();// No upgrade/downgrade buttonsexpect(screen.queryByRole("button", { name: /upgrade/i })).toBeNull();expect(screen.queryByRole("button", { name: /downgrade/i })).toBeNull();});+ it("hides tiers that are missing from tier_costs (no LD price configured)", () => {+ // LD only has stripe-price-id-basic → only BASIC appears; PRO/Max/Business+ // cards must hide.+ setupMocks({+ subscription: makeSubscription({+ tier: "BASIC",+ tierCosts: { BASIC: 0 },+ }),+ });+ render(<SubscriptionTierSection />);+ expect(screen.getByText("Basic")).toBeDefined();+ expect(screen.queryByText("Pro")).toBeNull();+ expect(screen.queryByText("Max")).toBeNull();+ expect(screen.queryByText("Business")).toBeNull();+ });++ it("renders Max card when tier_costs includes MAX and hides BUSINESS when its flag is unset", () => {+ // MAX is priced by default (stripe-price-id-max); BUSINESS stays reserved+ // (stripe-price-id-business unset) and must not render.+ setupMocks({+ subscription: makeSubscription({+ tier: "BASIC",+ tierCosts: { BASIC: 0, PRO: 1999, MAX: 32000 },+ }),+ });+ render(<SubscriptionTierSection />);+ expect(screen.getByText("Max")).toBeDefined();+ expect(screen.getByText("$320.00/mo")).toBeDefined();+ expect(screen.queryByText("Business")).toBeNull();+ });++ it("hides the current tier when its LD price is unset — no safety-net rendering", () => {+ setupMocks({+ subscription: makeSubscription({+ tier: "MAX",+ tierCosts: { PRO: 1999 },+ }),+ });+ render(<SubscriptionTierSection />);+ expect(screen.getByText("Pro")).toBeDefined();+ expect(screen.queryByText("Max")).toBeNull();+ expect(screen.queryByText("Basic")).toBeNull();+ });+it("shows ENTERPRISE message for ENTERPRISE tier users", () => {setupMocks({ subscription: makeSubscription({ tier: "ENTERPRISE" }) });render(<SubscriptionTierSection />);@@ -334,7 +386,7 @@ describe("SubscriptionTierSection", () => {expect(screen.getByText(/managed by your administrator/i)).toBeDefined();// No standard tier cards should be renderedexpect(screen.queryByText("Pro")).toBeNull();- expect(screen.queryByText("Business")).toBeNull();+ expect(screen.queryByText("Max")).toBeNull();});it("shows success toast and clears URL param when ?subscription=success is present", async () => {@@ -367,40 +419,40 @@ describe("SubscriptionTierSection", () => {it("renders pending-change banner when pending_tier is set", () => {setupMocks({subscription: makeSubscription({- tier: "BUSINESS",+ tier: "MAX",pendingTier: "PRO",pendingTierEffectiveAt: new Date("2026-11-15T00:00:00Z"),}),});render(<SubscriptionTierSection />);expect(screen.getByText(/scheduled to downgrade to/i)).toBeDefined();- // Banner "Keep Business" button — the only Keep button, since the on-card+ // Banner "Keep Max" button — the only Keep button, since the on-card// duplicate was removed in favour of the banner.- expect(- screen.getAllByRole("button", { name: /keep business/i }),- ).toHaveLength(1);+ expect(screen.getAllByRole("button", { name: /keep max/i })).toHaveLength(+ 1,+ );});it("does not render pending-change banner when pending_tier is null", () => {setupMocks({- subscription: makeSubscription({ tier: "BUSINESS", pendingTier: null }),+ subscription: makeSubscription({ tier: "MAX", pendingTier: null }),});render(<SubscriptionTierSection />);expect(screen.queryByText(/scheduled to downgrade/i)).toBeNull();- expect(screen.queryByRole("button", { name: /keep business/i })).toBeNull();+ expect(screen.queryByRole("button", { name: /keep max/i })).toBeNull();});it("clicking Keep [CurrentTier] in banner submits a same-tier update and refetches", async () => {// The cancel-pending route was collapsed into POST /credits/subscription as- // a same-tier request. Clicking "Keep BUSINESS" calls useUpdateSubscriptionTier+ // a same-tier request. Clicking "Keep MAX" calls useUpdateSubscriptionTier// with tier === current tier so the backend releases any pending schedule.const mutateFn = vi.fn()- .mockResolvedValue({ status: 200, data: { url: "", tier: "BUSINESS" } });+ .mockResolvedValue({ status: 200, data: { url: "", tier: "MAX" } });const refetchFn = vi.fn();setupMocks({subscription: makeSubscription({- tier: "BUSINESS",+ tier: "MAX",pendingTier: "PRO",pendingTierEffectiveAt: new Date("2026-11-15T00:00:00Z"),}),@@ -409,12 +461,12 @@ describe("SubscriptionTierSection", () => {});render(<SubscriptionTierSection />);- fireEvent.click(screen.getByRole("button", { name: /keep business/i }));+ fireEvent.click(screen.getByRole("button", { name: /keep max/i }));await waitFor(() => {expect(mutateFn).toHaveBeenCalledWith(expect.objectContaining({- data: expect.objectContaining({ tier: "BUSINESS" }),+ data: expect.objectContaining({ tier: "MAX" }),}),);expect(refetchFn).toHaveBeenCalled();@@ -427,7 +479,7 @@ describe("SubscriptionTierSection", () => {});it("uses end-of-period copy for paid→paid downgrade confirmation", () => {- setupMocks({ subscription: makeSubscription({ tier: "BUSINESS" }) });+ setupMocks({ subscription: makeSubscription({ tier: "MAX" }) });render(<SubscriptionTierSection />);fireEvent.click(screen.getByRole("button", { name: /downgrade to pro/i }));@@ -453,7 +505,7 @@ describe("SubscriptionTierSection", () => {const refetchFn = vi.fn();setupMocks({subscription: makeSubscription({- tier: "BUSINESS",+ tier: "MAX",pendingTier: "PRO",pendingTierEffectiveAt: new Date("2026-11-15T00:00:00Z"),}),@@ -463,7 +515,7 @@ describe("SubscriptionTierSection", () => {render(<SubscriptionTierSection />);const keepButtons = screen.getAllByRole("button", {- name: /keep business/i,+ name: /keep max/i,});fireEvent.click(keepButtons[0]);@@ -481,14 +533,14 @@ describe("SubscriptionTierSection", () => {});it("disables the tier button that matches the pending tier so users can't overwrite their own scheduled change by mis-click", () => {- // User is on BUSINESS and has a pending downgrade to PRO. The "Downgrade+ // User is on MAX and has a pending downgrade to PRO. The "Downgrade// to Pro" button must be disabled + labelled "Scheduled" so the primary- // cancel path stays the banner. Other tier buttons (FREE here) remain+ // cancel path stays the banner. Other tier buttons (BASIC here) remain// clickable — the user can still overwrite their pending change by// picking a different target; backend handles that.setupMocks({subscription: makeSubscription({- tier: "BUSINESS",+ tier: "MAX",pendingTier: "PRO",pendingTierEffectiveAt: new Date("2026-11-15T00:00:00Z"),}),@@ -499,23 +551,25 @@ describe("SubscriptionTierSection", () => {expect(scheduledBtn).toBeDefined();expect((scheduledBtn as HTMLButtonElement).disabled).toBe(true);- // The non-pending tier (FREE) button is still clickable.- const freeBtn = screen.getByRole("button", { name: /downgrade to free/i });- expect((freeBtn as HTMLButtonElement).disabled).toBe(false);+ // The non-pending tier (BASIC) button is still clickable.+ const basicBtn = screen.getByRole("button", {+ name: /downgrade to basic/i,+ });+ expect((basicBtn as HTMLButtonElement).disabled).toBe(false);});it("shows replace-pending dialog when clicking a non-pending tier while a pending change exists, and fires the mutation after confirm", async () => {- // User is on BUSINESS with a pending downgrade to PRO. Clicking FREE (a+ // User is on MAX with a pending downgrade to PRO. Clicking BASIC (a// tier that is neither current nor the pending target) must NOT silently// overwrite the pending schedule — it must open a confirmation dialog.// Only after the user explicitly confirms should changeTier (→ its own- // downgrade confirm for paid→FREE) fire.+ // downgrade confirm for paid→BASIC) fire.const mutateFn = vi.fn().mockResolvedValue({ status: 200, data: { url: "" } });setupMocks({subscription: makeSubscription({- tier: "BUSINESS",+ tier: "MAX",pendingTier: "PRO",pendingTierEffectiveAt: new Date("2026-11-15T00:00:00Z"),}),@@ -523,15 +577,17 @@ describe("SubscriptionTierSection", () => {});render(<SubscriptionTierSection />);- // Clicking FREE while PRO is pending surfaces the replace-pending dialog+ // Clicking BASIC while PRO is pending surfaces the replace-pending dialog// before anything mutates.- fireEvent.click(screen.getByRole("button", { name: /downgrade to free/i }));+ fireEvent.click(+ screen.getByRole("button", { name: /downgrade to basic/i }),+ );expect(screen.getByRole("dialog")).toBeDefined();expect(screen.getByText(/replace pending change/i)).toBeDefined();expect(mutateFn).not.toHaveBeenCalled();// Confirm the replace: the replace-pending dialog closes and the- // downgrade-to-FREE dialog takes over (because FREE is a downgrade).+ // downgrade-to-BASIC dialog takes over (because BASIC is a downgrade).fireEvent.click(screen.getByRole("button", { name: /replace pending change/i }),);@@ -543,7 +599,7 @@ describe("SubscriptionTierSection", () => {await waitFor(() => {expect(mutateFn).toHaveBeenCalledWith(expect.objectContaining({- data: expect.objectContaining({ tier: "FREE" }),+ data: expect.objectContaining({ tier: "BASIC" }),}),);});@@ -555,7 +611,7 @@ describe("SubscriptionTierSection", () => {.mockResolvedValue({ status: 200, data: { url: "" } });setupMocks({subscription: makeSubscription({- tier: "BUSINESS",+ tier: "MAX",pendingTier: "PRO",pendingTierEffectiveAt: new Date("2026-11-15T00:00:00Z"),}),@@ -563,7 +619,9 @@ describe("SubscriptionTierSection", () => {});render(<SubscriptionTierSection />);- fireEvent.click(screen.getByRole("button", { name: /downgrade to free/i }));+ fireEvent.click(+ screen.getByRole("button", { name: /downgrade to basic/i }),+ );expect(screen.getByRole("dialog")).toBeDefined();fireEvent.click(screen.getByRole("button", { name: /^cancel$/i }));@@ -571,11 +629,11 @@ describe("SubscriptionTierSection", () => {expect(mutateFn).not.toHaveBeenCalled();});- it("renders FREE cancellation copy in banner when pending_tier is FREE", () => {+ it("renders BASIC cancellation copy in banner when pending_tier is BASIC", () => {setupMocks({subscription: makeSubscription({- tier: "BUSINESS",- pendingTier: "FREE",+ tier: "MAX",+ pendingTier: "BASIC",// Noon UTC so the local-formatted date lands on the same day// regardless of the runner's timezone (midnight UTC drifts to// the prior day in any timezone west of UTC).@@ -588,7 +646,7 @@ describe("SubscriptionTierSection", () => {screen.getByText(/scheduled to cancel your subscription on/i),).toBeDefined();expect(screen.getByText(/May 15, 2026/)).toBeDefined();- // Must NOT render the "downgrade to" phrasing on FREE cancellation.+ // Must NOT render the "downgrade to" phrasing on BASIC cancellation.expect(screen.queryByText(/scheduled to downgrade to/i)).toBeNull();});});diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/PendingChangeBanner.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/PendingChangeBanner.tsxindex 0088ad7666..b2b68ddbd8 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/PendingChangeBanner.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/PendingChangeBanner.tsx@@ -25,7 +25,7 @@ export function PendingChangeBanner({const currentLabel = getTierLabel(currentTier);const dateText = formatPendingDate(pendingEffectiveAt);- const isCancellation = pendingTier === "FREE";+ const isCancellation = pendingTier === "BASIC";return (<divdiff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/__tests__/PendingChangeBanner.test.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/__tests__/PendingChangeBanner.test.tsxindex 73e044c1fe..3d89d151fd 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/__tests__/PendingChangeBanner.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/components/PendingChangeBanner/__tests__/PendingChangeBanner.test.tsx@@ -7,7 +7,7 @@ import { PendingChangeBanner } from "../PendingChangeBanner";describe("PendingChangeBanner", () => {const baseProps = {currentTier: "PRO",- pendingTier: "FREE",+ pendingTier: "BASIC",// Use noon UTC so the formatted local date lands on the same day// regardless of the host timezone (important for CI runners).pendingEffectiveAt: "2026-05-01T12:00:00Z",@@ -25,7 +25,7 @@ describe("PendingChangeBanner", () => {expect(container.firstChild).toBeNull();});- it("shows cancellation copy when pending tier is FREE", () => {+ it("shows cancellation copy when pending tier is BASIC", () => {render(<PendingChangeBanner {...baseProps} />);expect(screen.getByText(/cancel your subscription on/i)).toBeDefined();expect(screen.getByText("May 1, 2026")).toBeDefined();@@ -37,15 +37,13 @@ describe("PendingChangeBanner", () => {render(<PendingChangeBanner{...baseProps}- currentTier="BUSINESS"+ currentTier="MAX"pendingTier="PRO"/>,);expect(screen.getByText(/downgrade to/i)).toBeDefined();expect(screen.getByText("Pro")).toBeDefined();- expect(- screen.getByRole("button", { name: /keep business/i }),- ).toBeDefined();+ expect(screen.getByRole("button", { name: /keep max/i })).toBeDefined();});it("invokes onKeepCurrent when the button is clicked", () => {diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.test.tsindex ecc020482a..b7e2144067 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.test.ts+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.test.ts@@ -9,26 +9,32 @@ import {} from "./helpers";describe("formatCost", () => {- it("returns 'Free' for the FREE tier regardless of cents", () => {- expect(formatCost(0, "FREE")).toBe("Free");- expect(formatCost(999, "FREE")).toBe("Free");+ it("returns 'Free' only when BASIC actually costs $0", () => {+ expect(formatCost(0, "BASIC")).toBe("Free");+ });++ it("formats BASIC to a dollars-per-month string when LD sets a non-zero price", () => {+ expect(formatCost(999, "BASIC")).toBe("$9.99/mo");});it("returns a placeholder when paid tier has no price yet", () => {expect(formatCost(0, "PRO")).toBe("Pricing available soon");+ expect(formatCost(0, "MAX")).toBe("Pricing available soon");expect(formatCost(0, "BUSINESS")).toBe("Pricing available soon");});it("formats cents to a dollars-per-month string for paid tiers", () => {expect(formatCost(999, "PRO")).toBe("$9.99/mo");+ expect(formatCost(32000, "MAX")).toBe("$320.00/mo");expect(formatCost(4900, "BUSINESS")).toBe("$49.00/mo");});});describe("getTierLabel", () => {it("returns the canonical label for known tiers", () => {- expect(getTierLabel("FREE")).toBe("Free");+ expect(getTierLabel("BASIC")).toBe("Basic");expect(getTierLabel("PRO")).toBe("Pro");+ expect(getTierLabel("MAX")).toBe("Max");expect(getTierLabel("BUSINESS")).toBe("Business");});diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.tsindex fde4674a8b..9d576f53ab 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.ts+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/helpers.ts@@ -7,8 +7,8 @@ export interface TierInfo {export const TIERS: TierInfo[] = [{- key: "FREE",- label: "Free",+ key: "BASIC",+ label: "Basic",multiplier: "1x",description: "Base AutoPilot capacity with standard rate limits",},@@ -18,19 +18,25 @@ export const TIERS: TierInfo[] = [multiplier: "5x",description: "5x AutoPilot capacity — run 5× more tasks per day/week",},+ {+ key: "MAX",+ label: "Max",+ multiplier: "20x",+ description: "20x AutoPilot capacity — ideal for power users",+ },{key: "BUSINESS",label: "Business",- multiplier: "20x",- description: "20x AutoPilot capacity — ideal for teams and heavy workloads",+ multiplier: "60x",+ description: "60x AutoPilot capacity — ideal for teams and heavy workloads",},];-export const TIER_ORDER = ["FREE", "PRO", "BUSINESS", "ENTERPRISE"];+export const TIER_ORDER = ["BASIC", "PRO", "MAX", "BUSINESS", "ENTERPRISE"];export function formatCost(cents: number, tierKey: string): string {- if (tierKey === "FREE") return "Free";- if (cents === 0) return "Pricing available soon";+ if (cents === 0)+ return tierKey === "BASIC" ? "Free" : "Pricing available soon";return `$${(cents / 100).toFixed(2)}/mo`;}diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/useSubscriptionTierSection.ts b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/useSubscriptionTierSection.tsindex d51a2a6051..8bdce215ff 100644--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/useSubscriptionTierSection.ts+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/credits/components/SubscriptionTierSection/useSubscriptionTierSection.ts@@ -11,7 +11,7 @@ import { Flag, useGetFlag } from "@/services/feature-flags/use-get-flag";export type SubscriptionStatus = SubscriptionStatusResponse;-const TIER_ORDER = ["FREE", "PRO", "BUSINESS", "ENTERPRISE"];+const TIER_ORDER = ["BASIC", "PRO", "MAX", "BUSINESS", "ENTERPRISE"];export function useSubscriptionTierSection() {const isPaymentEnabled = useGetFlag(Flag.ENABLE_PLATFORM_PAYMENT);@@ -85,8 +85,8 @@ export function useSubscriptionTierSection() {toast({title: "Subscription updated",description:- tier === "FREE"- ? "Your plan will be downgraded to Free at the end of your current billing period."+ tier === "BASIC"+ ? "Your plan will be downgraded to Basic at the end of your current billing period.": "Your subscription has been updated.",});} catch (e: unknown) {diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.jsonindex 2e6cda41df..450c22e4b3 100644--- a/autogpt_platform/frontend/src/app/api/openapi.json+++ b/autogpt_platform/frontend/src/app/api/openapi.json@@ -10382,7 +10382,7 @@},"tier": {"$ref": "#/components/schemas/SubscriptionTier",- "default": "FREE"+ "default": "BASIC"},"reset_cost": {"type": "integer",@@ -15987,7 +15987,7 @@"properties": {"tier": {"type": "string",- "enum": ["FREE", "PRO", "BUSINESS", "ENTERPRISE"],+ "enum": ["BASIC", "PRO", "MAX", "BUSINESS", "ENTERPRISE"],"title": "Tier"},"monthly_cost": { "type": "integer", "title": "Monthly Cost" },@@ -16002,7 +16002,7 @@},"pending_tier": {"anyOf": [- { "type": "string", "enum": ["FREE", "PRO", "BUSINESS"] },+ { "type": "string", "enum": ["BASIC", "PRO", "MAX", "BUSINESS"] },{ "type": "null" }],"title": "Pending Tier"@@ -16017,7 +16017,7 @@"url": {"type": "string","title": "Url",- "description": "Populated only when POST /credits/subscription starts a Stripe Checkout Session (FREE → paid upgrade). Empty string in all other branches — the client redirects to this URL when non-empty.",+ "description": "Populated only when POST /credits/subscription starts a Stripe Checkout Session (BASIC → paid upgrade). Empty string in all other branches — the client redirects to this URL when non-empty.","default": ""}},@@ -16032,7 +16032,7 @@},"SubscriptionTier": {"type": "string",- "enum": ["FREE", "PRO", "BUSINESS", "ENTERPRISE"],+ "enum": ["BASIC", "PRO", "MAX", "BUSINESS", "ENTERPRISE"],"title": "SubscriptionTier","description": "Subscription tiers with increasing cost allowances.\n\nMirrors the ``SubscriptionTier`` enum in ``schema.prisma``.\nOnce ``prisma generate`` is run, this can be replaced with::\n\n from prisma.enums import SubscriptionTier"},@@ -16040,7 +16040,7 @@"properties": {"tier": {"type": "string",- "enum": ["FREE", "PRO", "BUSINESS"],+ "enum": ["BASIC", "PRO", "MAX", "BUSINESS"],"title": "Tier"},"success_url": {