Skip to content

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.

fix(frontend): say no model is connected in the builder chat; hide spend without billing (#15439)

Nicholas Tindle13d33b9f223f
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx
index 17f915fee4..5f8e36ad95 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/BuilderChatPanel.tsx
@@ -5,6 +5,7 @@ import { ChatMessagesContainer } from "@/app/(platform)/copilot/components/ChatM
import { CopilotChatActionsProvider } from "@/app/(platform)/copilot/components/CopilotChatActionsProvider/CopilotChatActionsProvider";
import { cn } from "@/lib/utils";
import { useRef } from "react";
+import { NoModelNotice } from "./components/NoModelNotice";
import { PanelHeader } from "./components/PanelHeader";
import { useBuilderChatPanel } from "./useBuilderChatPanel";
import { BubbleChatIcon, Cancel01Icon } from "@hugeicons/core-free-icons";
@@ -27,24 +28,31 @@ export function BuilderChatPanel({ className }: Props) {
onSend,
queuedMessages,
isBootstrapping,
+ hasNoModel,
revertTargetVersion,
handleRevert,
bindError,
bootstrapError,
retryBind,
retryBootstrap,
+ transportCheckError,
+ retryTransportCheck,
} = useBuilderChatPanel({ panelRef });
const isStreaming = status === "streaming" || status === "submitted";
- const activeError = bindError ?? bootstrapError ?? null;
+ const activeError = bindError ?? bootstrapError ?? transportCheckError;
const activeRetry = bindError
? retryBind
: bootstrapError
? retryBootstrap
- : null;
+ : transportCheckError
+ ? retryTransportCheck
+ : null;
const activeErrorTitle = bindError
? "Could not start the builder chat"
- : "Could not create a blank agent";
+ : bootstrapError
+ ? "Could not create a blank agent"
+ : "Could not check the AI connection";
return (
<div
@@ -69,7 +77,9 @@ export function BuilderChatPanel({ className }: Props) {
/>
<div className="flex h-0 min-h-0 flex-1 flex-col">
- {activeError && activeRetry ? (
+ {hasNoModel ? (
+ <NoModelNotice />
+ ) : activeError && activeRetry ? (
<div className="flex flex-1 flex-col items-center justify-center gap-3 px-4 py-6 text-center text-sm text-slate-600">
<p className="font-medium text-slate-800">
{activeErrorTitle}
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsx
index 4798f563ee..baba7d7f5a 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/BuilderChatPanel.test.tsx
@@ -32,12 +32,15 @@ function makeMockHook(
onSend: vi.fn(),
queuedMessages: [],
isBootstrapping: false,
+ hasNoModel: false,
revertTargetVersion: null,
handleRevert: vi.fn(),
bindError: null,
bootstrapError: null,
retryBind: vi.fn(),
retryBootstrap: vi.fn(),
+ transportCheckError: null,
+ retryTransportCheck: vi.fn(),
...overrides,
} as ReturnType<typeof useBuilderChatPanel>;
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/no-model.test.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/no-model.test.tsx
new file mode 100644
index 0000000000..ebb30d0432
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/__tests__/no-model.test.tsx
@@ -0,0 +1,322 @@
+import { getGetV2ListChatTransportsQueryKey } from "@/app/api/__generated__/endpoints/chat/chat";
+import {
+ getGetV2ListChatTransportsMockHandler,
+ getPostV2CreateSessionMockHandler,
+} from "@/app/api/__generated__/endpoints/chat/chat.msw";
+import {
+ getPostV1CreateNewGraphMockHandler,
+ getPostV1CreateNewGraphResponseMock,
+} from "@/app/api/__generated__/endpoints/graphs/graphs.msw";
+import type { ChatTransportResponse } from "@/app/api/__generated__/models/chatTransportResponse";
+import { TooltipProvider } from "@/components/atoms/Tooltip/BaseTooltip";
+import { BackendAPIProvider } from "@/lib/autogpt-server-api/context";
+import { server } from "@/mocks/mock-server";
+import OnboardingProvider from "@/providers/onboarding/onboarding-provider";
+import { act, fireEvent, render, screen, within } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { delay, http, HttpResponse } from "msw";
+import { parseAsString, useQueryStates } from "nuqs";
+import { NuqsTestingAdapter } from "nuqs/adapters/testing";
+import type { ReactNode } from "react";
+import { beforeEach, describe, expect, it } from "vitest";
+import { BuilderChatPanel } from "../BuilderChatPanel";
+
+// A self-hosted install with no model: chat can never answer, so opening the
+// builder chat must say how to fix that and must not leave anything behind.
+
+const SELF_HOSTED_CHAT: ChatTransportResponse = {
+ auth_provider: "platform",
+ credential_id: null,
+ label: "Self-hosted chat",
+ available: false,
+ default: false,
+};
+
+let createdGraphs: number;
+let createdSessions: number;
+
+beforeEach(() => {
+ createdGraphs = 0;
+ createdSessions = 0;
+ server.use(
+ getPostV1CreateNewGraphMockHandler(() => {
+ createdGraphs += 1;
+ return { ...getPostV1CreateNewGraphResponseMock(), id: "graph-new" };
+ }),
+ getPostV2CreateSessionMockHandler(() => {
+ createdSessions += 1;
+ return {
+ id: "session-1",
+ created_at: "2026-10-12T00:00:00Z",
+ user_id: "user-1",
+ };
+ }),
+ );
+});
+
+// The URL has to keep the agent the panel creates, so the testing adapter
+// remembers updates and keeps its queue. Even so, once an agent has been
+// created the URL can briefly read "no agent" again under load and the panel
+// creates a second one; dev's panel does the same. Counts taken after a
+// successful creation are therefore lower bounds. Exact counts are kept where
+// the point is that nothing was created.
+function renderPanel({
+ queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ }),
+ searchParams,
+ beside,
+}: {
+ queryClient?: QueryClient;
+ searchParams?: string;
+ beside?: ReactNode;
+} = {}) {
+ return render(
+ <>
+ {beside}
+ <BuilderChatPanel />
+ </>,
+ {
+ wrapper: ({ children }: { children: ReactNode }) => (
+ <QueryClientProvider client={queryClient}>
+ <NuqsTestingAdapter
+ hasMemory
+ resetUrlUpdateQueueOnMount={false}
+ searchParams={searchParams}
+ >
+ <BackendAPIProvider>
+ <OnboardingProvider>
+ <TooltipProvider>{children}</TooltipProvider>
+ </OnboardingProvider>
+ </BackendAPIProvider>
+ </NuqsTestingAdapter>
+ </QueryClientProvider>
+ ),
+ },
+ );
+}
+
+// Opens another agent the way the builder does: through the URL.
+function OpenAgentButton({ id }: { id: string }) {
+ const [, setQuery] = useQueryStates({ flowID: parseAsString });
+ return (
+ <button type="button" onClick={() => void setQuery({ flowID: id })}>
+ Open {id}
+ </button>
+ );
+}
+
+async function expectNoModelNotice() {
+ const notice = await screen.findByRole("status", {
+ name: "No AI connection",
+ });
+ expect(notice.textContent).toContain("No AI model is connected");
+ expect(
+ within(notice)
+ .getByRole("link", { name: /setup guide/i })
+ .getAttribute("href"),
+ ).toContain("single-container.md#models-and-memory");
+ expect(screen.queryByRole("button", { name: /Retry/i })).toBeNull();
+ expect(screen.queryByText(/Something went wrong/i)).toBeNull();
+}
+
+describe("Builder chat with no AI model connected", () => {
+ it("says how to connect one and creates no agent and no session", async () => {
+ server.use(
+ getGetV2ListChatTransportsMockHandler({ transports: [SELF_HOSTED_CHAT] }),
+ );
+
+ renderPanel();
+ fireEvent.click(screen.getByLabelText("Chat with builder"));
+
+ await expectNoModelNotice();
+ expect(createdGraphs).toBe(0);
+ expect(createdSessions).toBe(0);
+ });
+
+ it("falls back to the server's answer when the model check itself fails", async () => {
+ server.use(
+ http.get("/api/proxy/api/chat/transports", () =>
+ HttpResponse.json({ detail: "unavailable" }, { status: 500 }),
+ ),
+ http.post("/api/proxy/api/chat/sessions", () => {
+ createdSessions += 1;
+ return HttpResponse.json(
+ { detail: "chat_transport_not_configured" },
+ { status: 503 },
+ );
+ }),
+ );
+
+ renderPanel({ searchParams: "?flowID=graph-saved" });
+ fireEvent.click(screen.getByLabelText("Chat with builder"));
+
+ await expectNoModelNotice();
+ expect(createdSessions).toBe(1);
+ expect(createdGraphs).toBe(0);
+ expect(screen.queryByText(/Could not start the builder chat/i)).toBeNull();
+ });
+
+ it("with no agent open, a failed model check creates nothing and offers a retry", async () => {
+ let transportsUp = false;
+ server.use(
+ http.get("/api/proxy/api/chat/transports", () =>
+ transportsUp
+ ? HttpResponse.json({
+ transports: [
+ { ...SELF_HOSTED_CHAT, available: true, default: true },
+ ],
+ })
+ : HttpResponse.json({ detail: "unavailable" }, { status: 500 }),
+ ),
+ );
+
+ renderPanel();
+ fireEvent.click(screen.getByLabelText("Chat with builder"));
+
+ expect(
+ await screen.findByText("Could not check the AI connection"),
+ ).toBeDefined();
+ expect(createdGraphs).toBe(0);
+
+ transportsUp = true;
+ fireEvent.click(screen.getByRole("button", { name: "Retry" }));
+ expect(
+ await screen.findByPlaceholderText(
+ "Ask the builder to edit or run this agent…",
+ ),
+ ).toBeDefined();
+ expect(createdGraphs).toBeGreaterThanOrEqual(1);
+ expect(createdSessions).toBeGreaterThanOrEqual(1);
+ });
+
+ it("re-checks a model it saw earlier before creating an agent", async () => {
+ // The model was there when this tab last asked, and has gone since.
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ queryClient.setQueryData(getGetV2ListChatTransportsQueryKey(), {
+ status: 200,
+ data: {
+ transports: [{ ...SELF_HOSTED_CHAT, available: true, default: true }],
+ },
+ headers: new Headers(),
+ });
+ server.use(
+ http.get("/api/proxy/api/chat/transports", async () => {
+ await delay(50);
+ return HttpResponse.json({ transports: [SELF_HOSTED_CHAT] });
+ }),
+ );
+
+ renderPanel({ queryClient });
+ fireEvent.click(screen.getByLabelText("Chat with builder"));
+
+ await expectNoModelNotice();
+ expect(createdGraphs).toBe(0);
+ expect(createdSessions).toBe(0);
+ });
+
+ it("after a failed agent creation, waits for Retry even when the model check refetches", async () => {
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false } },
+ });
+ let attempts = 0;
+ server.use(
+ http.get("/api/proxy/api/chat/transports", async () => {
+ await delay(20);
+ return HttpResponse.json({
+ transports: [{ ...SELF_HOSTED_CHAT, available: true, default: true }],
+ });
+ }),
+ http.post("/api/proxy/api/graphs", () => {
+ attempts += 1;
+ return attempts === 1
+ ? HttpResponse.json({ detail: "boom" }, { status: 500 })
+ : HttpResponse.json({
+ ...getPostV1CreateNewGraphResponseMock(),
+ id: "graph-new",
+ });
+ }),
+ );
+
+ renderPanel({ queryClient });
+ fireEvent.click(screen.getByLabelText("Chat with builder"));
+ expect(
+ await screen.findByText("Could not create a blank agent"),
+ ).toBeDefined();
+
+ // A window focus refetches the transports; that alone must not retry.
+ await queryClient.refetchQueries({
+ queryKey: getGetV2ListChatTransportsQueryKey(),
+ });
+ await act(() => new Promise((resolve) => setTimeout(resolve, 50)));
+ expect(attempts).toBe(1);
+ expect(screen.getByText("Could not create a blank agent")).toBeDefined();
+
+ fireEvent.click(screen.getByRole("button", { name: "Retry" }));
+ expect(
+ await screen.findByPlaceholderText(
+ "Ask the builder to edit or run this agent…",
+ ),
+ ).toBeDefined();
+ expect(attempts).toBeGreaterThanOrEqual(2);
+ });
+
+ it("a session that failed for one agent doesn't hold up the next agent's", async () => {
+ server.use(
+ getGetV2ListChatTransportsMockHandler({
+ transports: [{ ...SELF_HOSTED_CHAT, available: true, default: true }],
+ }),
+ http.post("/api/proxy/api/chat/sessions", async ({ request }) => {
+ const body = (await request.json()) as { builder_graph_id?: string };
+ return body.builder_graph_id === "graph-a"
+ ? HttpResponse.json({ detail: "boom" }, { status: 500 })
+ : HttpResponse.json({
+ id: "session-b",
+ created_at: "2026-10-12T00:00:00Z",
+ user_id: "user-1",
+ });
+ }),
+ );
+
+ renderPanel({
+ searchParams: "?flowID=graph-a",
+ beside: <OpenAgentButton id="graph-b" />,
+ });
+ fireEvent.click(screen.getByLabelText("Chat with builder"));
+ expect(
+ await screen.findByText("Could not start the builder chat"),
+ ).toBeDefined();
+
+ fireEvent.click(screen.getByRole("button", { name: "Open graph-b" }));
+ expect(
+ await screen.findByPlaceholderText(
+ "Ask the builder to edit or run this agent…",
+ ),
+ ).toBeDefined();
+ expect(screen.queryByText("Could not start the builder chat")).toBeNull();
+ });
+
+ it("still creates the agent and opens the chat when a model is connected", async () => {
+ server.use(
+ getGetV2ListChatTransportsMockHandler({
+ transports: [{ ...SELF_HOSTED_CHAT, available: true, default: true }],
+ }),
+ );
+
+ renderPanel();
+ fireEvent.click(screen.getByLabelText("Chat with builder"));
+
+ expect(
+ await screen.findByPlaceholderText(
+ "Ask the builder to edit or run this agent…",
+ ),
+ ).toBeDefined();
+ expect(createdGraphs).toBeGreaterThanOrEqual(1);
+ expect(createdSessions).toBeGreaterThanOrEqual(1);
+ expect(screen.queryByRole("status", { name: "No AI connection" })).toBe(
+ null,
+ );
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/components/NoModelNotice.tsx b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/components/NoModelNotice.tsx
new file mode 100644
index 0000000000..023ea87bc9
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/components/NoModelNotice.tsx
@@ -0,0 +1,36 @@
+import { SELF_HOSTED_MODELS_DOCS_URL } from "@/app/(platform)/copilot/helpers/reportedSendError";
+import { Icon } from "@/components/atoms/Icon/Icon";
+import { Alert02Icon } from "@hugeicons/core-free-icons";
+
+// The builder chat runs only on this server's own model, so unlike the main
+// chat's notice this one has no ChatGPT-plan route to offer.
+export function NoModelNotice() {
+ return (
+ <div className="flex flex-1 items-center justify-center px-4 py-6">
+ <div
+ role="status"
+ aria-label="No AI connection"
+ className="flex w-full items-start gap-2 rounded-2xl bg-amber-50 px-3 py-2 text-left text-sm text-amber-900"
+ >
+ <Icon
+ icon={Alert02Icon}
+ className="mt-0.5 h-4 w-4 shrink-0"
+ aria-hidden
+ />
+ <span className="min-w-0 flex-1">
+ No AI model is connected, so the builder chat can&apos;t answer yet.
+ Whoever runs this server can add a model API key or a local model{" "}
+ <a
+ href={SELF_HOSTED_MODELS_DOCS_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="font-medium underline underline-offset-2"
+ >
+ (setup guide)
+ </a>
+ .
+ </span>
+ </div>
+ </div>
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/helpers.ts
new file mode 100644
index 0000000000..3ed23f5c42
--- /dev/null
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/helpers.ts
@@ -0,0 +1,44 @@
+import type { ChatTransportResponse } from "@/app/api/__generated__/models/chatTransportResponse";
+import { ApiError } from "@/lib/autogpt-server-api/helpers";
+
+export type DeploymentModelStatus =
+ | "checking"
+ | "available"
+ | "missing"
+ | "unknown";
+
+interface TransportsQuery {
+ isPending: boolean;
+ isFetching: boolean;
+ transports: ChatTransportResponse[] | undefined;
+}
+
+// Builder sessions only run on this server's own model (the platform
+// transport). A connected ChatGPT plan does not open them up, so it doesn't
+// count here. "unknown" means the check itself failed.
+export function getDeploymentModelStatus({
+ isPending,
+ isFetching,
+ transports,
+}: TransportsQuery): DeploymentModelStatus {
+ if (transports) {
+ const isAvailable = transports.some(
+ (transport) =>
+ transport.auth_provider === "platform" && transport.available,
+ );
+ if (!isAvailable) return "missing";
+ // A cached "available" can be stale (the model may have gone since the
+ // panel last opened), and the agent it lets us create can't be taken
+ // back, so wait for the refetch.
+ return isFetching ? "checking" : "available";
+ }
+ return isPending || isFetching ? "checking" : "unknown";
+}
+
+export function isNoModelError(error: unknown) {
+ return (
+ error instanceof ApiError &&
+ error.status === 503 &&
+ error.response?.detail === "chat_transport_not_configured"
+ );
+}
diff --git a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
index 0c5dabfd01..6fe3527dcb 100644
--- a/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/build/components/BuilderChatPanel/useBuilderChatPanel.ts
@@ -8,6 +8,7 @@ import {
} from "@/app/api/__generated__/endpoints/graphs/graphs";
import {
getGetV2GetSessionQueryKey,
+ useGetV2ListChatTransports,
usePostV2CreateSession,
} from "@/app/api/__generated__/endpoints/chat/chat";
import type { GraphModel } from "@/app/api/__generated__/models/graphModel";
@@ -24,6 +25,7 @@ import { useCopilotPendingChips } from "@/app/(platform)/copilot/useCopilotPendi
import { useGetV2GetSession } from "@/app/api/__generated__/endpoints/chat/chat";
import { isKey } from "@/lib/keyboard";
import { retryUnlessClientError } from "../../helpers/graphLoadError";
+import { getDeploymentModelStatus, isNoModelError } from "./helpers";
interface UseBuilderChatPanelArgs {
panelRef?: React.RefObject<HTMLElement | null>;
@@ -77,6 +79,9 @@ export function useBuilderChatPanel({
// surfaced by the panel. Cleared on each retry attempt and on success.
const [bindError, setBindError] = useState<string | null>(null);
const [bootstrapError, setBootstrapError] = useState<string | null>(null);
+ // Set when the server refuses the session for having no model, in case the
+ // transports check below could not answer first.
+ const [sessionRefusedNoModel, setSessionRefusedNoModel] = useState(false);
const [{ flowID, flowVersion }, setQueryStates] = useQueryStates({
flowID: parseAsString,
flowExecutionID: parseAsString,
@@ -85,6 +90,31 @@ export function useBuilderChatPanel({
const { toast } = useToast();
const queryClient = useQueryClient();
+ // Checked before anything is created: with no model the chat can never
+ // answer, so neither the blank agent nor the session below is worth making.
+ const transportsQuery = useGetV2ListChatTransports({
+ query: { enabled: isOpen },
+ });
+ const modelStatus = sessionRefusedNoModel
+ ? "missing"
+ : getDeploymentModelStatus({
+ isPending: transportsQuery.isPending,
+ isFetching: transportsQuery.isFetching,
+ transports:
+ transportsQuery.data?.status === 200
+ ? transportsQuery.data.data.transports
+ : undefined,
+ });
+ const isWaitingForModel =
+ modelStatus === "checking" || modelStatus === "missing";
+ // If the check fails, an open agent still binds (the session request
+ // answers for itself), but no blank agent is created on a guess.
+ const canCreateAgent = modelStatus === "available";
+ const transportCheckError =
+ isOpen && !flowID && modelStatus === "unknown"
+ ? "failed_to_check_ai_connection"
+ : null;
+
const { data: graph, refetch: refetchGraph } = useGetV1GetSpecificGraph(
flowID ?? "",
{},
@@ -188,6 +218,13 @@ export function useBuilderChatPanel({
}
}, [flowID, setMessages]);
+ // An error belongs to the graph it happened on: moving to another one, or
+ // to a blank builder, clears it so that graph's chat starts on its own.
+ useEffect(() => {
+ setBindError(null);
+ setBootstrapError(null);
+ }, [flowID]);
+
// Bind the panel session to (flowID -> graph_id). Navigating to a
// different graph or clearing flowID drops the current session (above) so
// the next panel open starts clean with the right graph. Guards against:
@@ -200,6 +237,10 @@ export function useBuilderChatPanel({
useEffect(() => {
if (!isOpen) return;
if (!flowID) return;
+ if (isWaitingForModel) return;
+ // A failed bind waits for Retry (which clears it) or a new graph, not for
+ // the next transports refetch to re-run this effect.
+ if (bindError) return;
if (boundGraphRef.current === flowID && sessionId) return;
if (bindingRef.current) return;
const effectFlowID = flowID;
@@ -228,10 +269,13 @@ export function useBuilderChatPanel({
setSessionId(response.data.id);
} catch (err) {
if (currentFlowIDRef.current !== effectFlowID) return;
+ boundGraphRef.current = null;
+ if (isNoModelError(err)) {
+ setSessionRefusedNoModel(true);
+ return;
+ }
Sentry.captureException(err);
setBindError("failed_to_bind_builder_session");
- // Clear the bound marker so the panel can re-trigger on retry.
- boundGraphRef.current = null;
toast({
variant: "destructive",
title: "Could not start the builder chat",
@@ -244,7 +288,16 @@ export function useBuilderChatPanel({
// `bindRetryToken` is intentionally in the dep array so retrying bumps
// the token and forces this effect to re-run even when flowID+sessionId
// haven't changed.
- }, [isOpen, flowID, sessionId, bindRetryToken, createBuilderSession, toast]);
+ }, [
+ isOpen,
+ flowID,
+ sessionId,
+ bindRetryToken,
+ isWaitingForModel,
+ bindError,
+ createBuilderSession,
+ toast,
+ ]);
// Auto-create a blank agent when the panel is opened without one.
// The saved graph's id becomes the builder session's binding. On
@@ -253,6 +306,9 @@ export function useBuilderChatPanel({
const isBootstrappingRef = useRef(false);
useEffect(() => {
if (!isOpen || flowID || isBootstrappingRef.current) return;
+ if (!canCreateAgent) return;
+ // Likewise, a failed attempt waits for Retry.
+ if (bootstrapError) return;
isBootstrappingRef.current = true;
setBootstrapError(null);
void (async () => {
@@ -294,6 +350,8 @@ export function useBuilderChatPanel({
isOpen,
flowID,
bootstrapRetryToken,
+ canCreateAgent,
+ bootstrapError,
createNewGraph,
setQueryStates,
toast,
@@ -428,6 +486,7 @@ export function useBuilderChatPanel({
function handleToggle() {
setIsOpen((o) => !o);
+ setSessionRefusedNoModel(false);
}
async function handleRevert() {
@@ -491,7 +550,10 @@ export function useBuilderChatPanel({
// the loading spinner — so the computed bootstrapping flag must read
// false in that case. Without this, a bind / create-graph failure would
// still render "Preparing builder chat…" forever.
+ const hasNoModel = modelStatus === "missing";
const isBootstrapping =
+ !hasNoModel &&
+ !transportCheckError &&
!bindError &&
!bootstrapError &&
(isBootstrappingGraph ||
@@ -508,6 +570,10 @@ export function useBuilderChatPanel({
setBootstrapRetryToken((t) => t + 1);
}
+ function retryTransportCheck() {
+ void transportsQuery.refetch();
+ }
+
return {
isOpen,
handleToggle,
@@ -522,11 +588,14 @@ export function useBuilderChatPanel({
onSend,
queuedMessages,
isBootstrapping,
+ hasNoModel,
revertTargetVersion,
handleRevert,
bindError,
bootstrapError,
retryBind,
retryBootstrap,
+ transportCheckError,
+ retryTransportCheck,
};
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/__tests__/briefing.test.tsx b/autogpt_platform/frontend/src/app/(platform)/library/__tests__/briefing.test.tsx
index 40ab26982e..932ad77516 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/__tests__/briefing.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/__tests__/briefing.test.tsx
@@ -1,6 +1,7 @@
import { afterEach, describe, expect, test, vi } from "vitest";
import { within } from "@testing-library/react";
-import { render, screen } from "@/tests/integrations/test-utils";
+import { http, HttpResponse } from "msw";
+import { fireEvent, render, screen } from "@/tests/integrations/test-utils";
import { server } from "@/mocks/mock-server";
import {
getGetV2ListLibraryAgentsMockHandler,
@@ -20,15 +21,20 @@ import LibraryPage from "../page";
afterEach(() => {
vi.useRealTimers();
+ flags.paymentsOn = true;
});
+// Payments on is a billed install; off is a self-hosted one without billing.
+const flags = vi.hoisted(() => ({ paymentsOn: true }));
+
vi.mock("@/services/feature-flags/use-get-flag", async () => {
const actual = await vi.importActual<
typeof import("@/services/feature-flags/use-get-flag")
>("@/services/feature-flags/use-get-flag");
return {
...actual,
- useGetFlag: () => false,
+ useGetFlag: (flag: string) =>
+ flag === actual.Flag.ENABLE_PLATFORM_PAYMENT && flags.paymentsOn,
};
});
@@ -113,3 +119,46 @@ describe("LibraryPage — AgentBriefingPanel 'Spent this month' tile", () => {
expect(within(tile).getByText("$0.00")).toBeDefined();
});
});
+
+describe("LibraryPage — AgentBriefingPanel without billing (self-hosted)", () => {
+ test("shows no spend, no costs breakdown, and never asks for spend", async () => {
+ flags.paymentsOn = false;
+ setupHandlers({ totalCents: 825 });
+ let costSummaryRequests = 0;
+ server.use(
+ http.get("/api/proxy/api/executions/cost-summary", () => {
+ costSummaryRequests += 1;
+ return HttpResponse.json({}, { status: 500 });
+ }),
+ );
+
+ render(<LibraryPage />);
+
+ const runningTile = (await screen.findByText("Running now")).closest(
+ "button",
+ );
+ expect(runningTile).not.toBeNull();
+ expect(screen.queryByText("Spent this month")).toBeNull();
+ expect(screen.queryByText(/costs breakdown/i)).toBeNull();
+ expect(screen.queryByText("$8.25")).toBeNull();
+ expect(costSummaryRequests).toBe(0);
+ });
+
+ test("a second click on the active tile goes back to the overview", async () => {
+ flags.paymentsOn = false;
+ setupHandlers({ totalCents: 0 });
+
+ render(<LibraryPage />);
+
+ const idle = await screen.findByRole("button", { name: /^Idle\b/ });
+ fireEvent.click(idle);
+ expect(idle.getAttribute("aria-pressed")).toBe("true");
+ fireEvent.click(idle);
+ expect(idle.getAttribute("aria-pressed")).toBe("false");
+ expect(
+ screen
+ .getByRole("button", { name: /^Running now\b/ })
+ .getAttribute("aria-pressed"),
+ ).toBe("false");
+ });
+});
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/BriefingTabContent.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/BriefingTabContent.tsx
index b0d01402d4..98c0aa090c 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/BriefingTabContent.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/BriefingTabContent.tsx
@@ -1,6 +1,7 @@
"use client";
import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
+import { useIsBillingEnabled } from "@/hooks/useIsBillingEnabled";
import { CostsBreakdown } from "../CostsBreakdown/CostsBreakdown";
import { AgentListSection } from "./components/AgentListSection";
@@ -14,10 +15,12 @@ interface Props {
}
export function BriefingTabContent({ activeTab, agents }: Props) {
+ const isBillingEnabled = useIsBillingEnabled();
+
if (activeTab === "all") {
return (
<div className="py-2">
- <CostsBreakdown agents={agents} />
+ {isBillingEnabled ? <CostsBreakdown agents={agents} /> : null}
<CopilotLibrarySummary />
</div>
);
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/BriefingTabContent.test.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/BriefingTabContent.test.tsx
index 71ffdfebae..93271f486b 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/BriefingTabContent.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/BriefingTabContent/__tests__/BriefingTabContent.test.tsx
@@ -17,6 +17,11 @@ import {
import { afterEach, describe, expect, it, vi } from "vitest";
import { BriefingTabContent } from "../BriefingTabContent";
+// The costs breakdown is billing UI: these tests are a billed install's view.
+vi.mock("@/hooks/useIsBillingEnabled", () => ({
+ useIsBillingEnabled: () => true,
+}));
+
const mockUseGetV1UserCostSummary = vi.fn();
vi.mock(
"@/app/api/__generated__/endpoints/graphs/graphs",
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/StatsGrid/StatsGrid.tsx b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/StatsGrid/StatsGrid.tsx
index 08b70b8e37..824bf26062 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/StatsGrid/StatsGrid.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/library/components/AgentBriefingPanel/components/StatsGrid/StatsGrid.tsx
@@ -5,6 +5,7 @@ import { OverflowText } from "@/components/atoms/OverflowText/OverflowText";
import { Emoji } from "@/components/atoms/Emoji/Emoji";
import { cn } from "@/lib/utils";
import { formatCents } from "@/app/(platform)/copilot/components/usageHelpers";
+import { useIsBillingEnabled } from "@/hooks/useIsBillingEnabled";
import type { FleetSummary, AgentStatusFilter } from "../../../../types";
interface Props {
@@ -67,9 +68,19 @@ const TILES: {
];
export function StatsGrid({ summary, activeTab, onTabChange }: Props) {
+ const isBillingEnabled = useIsBillingEnabled();
+ const tiles = isBillingEnabled
+ ? TILES
+ : TILES.filter((tile) => tile.key !== "monthlySpend");
+
return (
- <div className="grid grid-cols-1 gap-3 min-[450px]:grid-cols-2 sm:grid-cols-3 lg:grid-cols-6">
- {TILES.map((tile) => {
+ <div
+ className={cn(
+ "grid grid-cols-1 gap-3 min-[450px]:grid-cols-2 sm:grid-cols-3",
+ isBillingEnabled ? "lg:grid-cols-6" : "lg:grid-cols-5",
+ )}
+ >
+ {tiles.map((tile) => {
const rawValue = summary[tile.key];
const value = tile.format ? tile.format(rawValue) : rawValue;
const isActive = activeTab === tile.filter;
@@ -78,7 +89,10 @@ export function StatsGrid({ summary, activeTab, onTabChange }: Props) {
<button
key={tile.label}
type="button"
- onClick={() => onTabChange(tile.filter)}
+ aria-pressed={isActive}
+ // A second click goes back to the overview, which has no tile of
+ // its own when billing is off.
+ onClick={() => onTabChange(isActive ? "all" : tile.filter)}
className={cn(
"flex min-w-0 flex-col gap-1 rounded-medium border p-3 text-left shadow-md transition-all hover:shadow-lg",
isActive
diff --git a/autogpt_platform/frontend/src/app/(platform)/library/hooks/useLibraryFleetSummary.ts b/autogpt_platform/frontend/src/app/(platform)/library/hooks/useLibraryFleetSummary.ts
index 9d340743fe..f36533de5e 100644
--- a/autogpt_platform/frontend/src/app/(platform)/library/hooks/useLibraryFleetSummary.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/library/hooks/useLibraryFleetSummary.ts
@@ -10,6 +10,7 @@ import type { LibraryAgent } from "@/app/api/__generated__/models/libraryAgent";
import type { UserExecutionCostSummary } from "@/app/api/__generated__/models/userExecutionCostSummary";
import { okData } from "@/app/api/helpers";
import { useExecutionEvents } from "@/hooks/useExecutionEvents";
+import { useIsBillingEnabled } from "@/hooks/useIsBillingEnabled";
import { useQueryClient } from "@tanstack/react-query";
import { useCallback, useMemo } from "react";
import type { FleetSummary } from "../types";
@@ -46,17 +47,20 @@ export function useLibraryFleetSummary(
agents: LibraryAgent[],
): FleetSummary | undefined {
const queryClient = useQueryClient();
+ const isBillingEnabled = useIsBillingEnabled();
const { data: executions, isSuccess } = useGetV1ListAllExecutions({
query: { select: okData },
});
// Authoritative monthly total comes from the server-side aggregator so it
- // stays correct above the 250-row /executions cap.
+ // stays correct above the 250-row /executions cap. Without billing nothing
+ // shows spend, so there is nothing to fetch.
const { data: costSummary } = useGetV1UserCostSummary(undefined, {
query: {
select: (res) => res.data as UserExecutionCostSummary,
staleTime: 60_000,
+ enabled: isBillingEnabled,
},
});
diff --git a/autogpt_platform/frontend/src/playwright/journeys/selfhost-journey.spec.ts b/autogpt_platform/frontend/src/playwright/journeys/selfhost-journey.spec.ts
index 76de4d5058..c2977ff9d9 100644
--- a/autogpt_platform/frontend/src/playwright/journeys/selfhost-journey.spec.ts
+++ b/autogpt_platform/frontend/src/playwright/journeys/selfhost-journey.spec.ts
@@ -84,6 +84,31 @@ test("selfhost journey: a self-hoster's first hour has nothing hosted-only in it
await expect.soft(notice).toBeVisible();
});
+ await test.step("builder chat with no model says how to fix it, and saves no agent", async () => {
+ const buildPage = new BuildPage(page);
+ await buildPage.open();
+ await page.getByRole("button", { name: "Chat with builder" }).click();
+ const panel = page.getByRole("complementary", {
+ name: "Builder chat panel",
+ });
+ const notice = panel.getByRole("status", { name: "No AI connection" });
+ await expect.soft(notice).toBeVisible();
+ await expect
+ .soft(notice.getByRole("link", { name: /setup guide/i }))
+ .toHaveAttribute("href", /single-container\.md#models-and-memory/);
+ await expect
+ .soft(panel.getByRole("button", { name: "Retry" }))
+ .toHaveCount(0);
+
+ await page.getByRole("button", { name: "Close chat" }).click();
+ expect
+ .soft(
+ await libraryAgentNames(page),
+ "opening the builder chat must not save an empty agent",
+ )
+ .toEqual([]);
+ });
+
const agentName = createUniqueAgentName("Selfhost Journey Agent");
const expectedOutput = `selfhost-output-${runID}`;
const outputName = `selfhost-result-${runID}`;
@@ -120,6 +145,15 @@ test("selfhost journey: a self-hoster's first hour has nothing hosted-only in it
await expectNoHostedOnlyChrome(page);
});
+ await test.step("the Library's briefing shows no spend", async () => {
+ await page.goto("/library");
+ await expect(page.getByText("Agent Briefing")).toBeVisible();
+ await expect.soft(page.getByText("Spent this month")).toHaveCount(0);
+ await expect
+ .soft(page.getByRole("button", { name: /costs breakdown/i }))
+ .toHaveCount(0);
+ });
+
await test.step("settings: memory is reachable, billing is not", async () => {
await page.goto("/settings/memory");
await expect
@@ -180,6 +214,15 @@ async function connectHandles(page: Page, output: string, input: string) {
await page.mouse.up();
}
+async function libraryAgentNames(page: Page) {
+ const response = await page.request.get(
+ "/api/proxy/api/library/agents?page_size=100",
+ );
+ expect(response.ok()).toBe(true);
+ const { agents } = (await response.json()) as { agents: { name: string }[] };
+ return agents.map((agent) => agent.name);
+}
+
async function centerOf(locator: Locator) {
const box = await locator.boundingBox();
if (!box) throw new Error("handle is not on screen");