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.

feat(platform): require a short CTA-style sub_heading on marketplace listings, with a backfill script (#14494)

Reinier van der Leer465392c671c2
diff --git a/autogpt_platform/backend/backend/api/features/orgs/regression_test.py b/autogpt_platform/backend/backend/api/features/orgs/regression_test.py
index ac3a402447..d08b2a809e 100644
--- a/autogpt_platform/backend/backend/api/features/orgs/regression_test.py
+++ b/autogpt_platform/backend/backend/api/features/orgs/regression_test.py
@@ -1275,6 +1275,7 @@ class TestRegressionStore:
graph_version=GRAPH_VERSION,
slug=SLUG,
name="Test Agent",
+ sub_heading="Find test agents fast",
)
# The initial graph lookup must include userId
@@ -1304,6 +1305,7 @@ class TestRegressionStore:
user_id=USER_ID,
store_listing_version_id=STORE_LISTING_VERSION_ID,
name="Updated",
+ sub_heading="Find test agents fast",
)
@pytest.mark.asyncio
@@ -2191,6 +2193,7 @@ class TestPR15MarketplaceOrg:
graph_version=GRAPH_VERSION,
slug=SLUG,
name="Test Agent",
+ sub_heading="Find test agents fast",
organization_id="org-1",
)
diff --git a/autogpt_platform/backend/backend/api/features/store/db.py b/autogpt_platform/backend/backend/api/features/store/db.py
index cc11dae01b..04bef68439 100644
--- a/autogpt_platform/backend/backend/api/features/store/db.py
+++ b/autogpt_platform/backend/backend/api/features/store/db.py
@@ -841,12 +841,12 @@ async def create_store_submission(
graph_version: int,
slug: str,
name: str,
+ sub_heading: str,
video_url: str | None = None,
agent_output_demo_url: str | None = None,
image_urls: list[str] = [],
description: str = "",
instructions: str | None = None,
- sub_heading: str = "",
categories: list[str] = [],
changes_summary: str | None = "Initial Submission",
recommended_schedule_cron: str | None = None,
@@ -864,7 +864,7 @@ async def create_store_submission(
video_url: Optional URL to video demo
image_urls: List of image URLs for the listing
description: Description of the agent
- sub_heading: Optional sub-heading for the agent
+ sub_heading: Short CTA line shown under the agent name
categories: List of categories for the agent
changes_summary: Summary of changes made in this submission
@@ -1044,11 +1044,11 @@ async def edit_store_submission(
user_id: str,
store_listing_version_id: str,
name: str,
+ sub_heading: str,
video_url: str | None = None,
agent_output_demo_url: str | None = None,
image_urls: list[str] = [],
description: str = "",
- sub_heading: str = "",
categories: list[str] = [],
changes_summary: str | None = "Update submission",
recommended_schedule_cron: str | None = None,
@@ -1065,7 +1065,7 @@ async def edit_store_submission(
video_url: Optional URL to video demo
image_urls: List of image URLs for the listing
description: Description of the agent
- sub_heading: Optional sub-heading for the agent
+ sub_heading: Short CTA line shown under the agent name
categories: List of categories for the agent
changes_summary: Summary of changes made in this submission
diff --git a/autogpt_platform/backend/backend/api/features/store/db_test.py b/autogpt_platform/backend/backend/api/features/store/db_test.py
index 0208dbac31..85e82894b4 100644
--- a/autogpt_platform/backend/backend/api/features/store/db_test.py
+++ b/autogpt_platform/backend/backend/api/features/store/db_test.py
@@ -261,6 +261,7 @@ async def test_create_store_submission(mocker):
graph_version=1,
slug="test-agent",
name="Test Agent",
+ sub_heading="Find test agents fast",
description="Test description",
)
@@ -1072,6 +1073,7 @@ async def test_edit_store_submission_blocks_cross_org(mocker):
user_id="user-1",
store_listing_version_id="slv-1",
name="New Name",
+ sub_heading="Find test agents fast",
organization_id="org-A",
)
mock_client.update.assert_not_called()
diff --git a/autogpt_platform/backend/backend/api/features/store/model.py b/autogpt_platform/backend/backend/api/features/store/model.py
index 6dd41bcc9a..e395e02238 100644
--- a/autogpt_platform/backend/backend/api/features/store/model.py
+++ b/autogpt_platform/backend/backend/api/features/store/model.py
@@ -1,6 +1,6 @@
import datetime
import enum
-from typing import TYPE_CHECKING, List, Self
+from typing import TYPE_CHECKING, Annotated, List, Self
import prisma.enums
import pydantic
@@ -13,6 +13,25 @@ if TYPE_CHECKING:
import prisma.models
+SUB_HEADING_MAX_LENGTH = 100
+
+# Surfaced as a one-line card subtitle, so it must be a short CTA rather than a
+# description; whitespace-only is stripped to "" and rejected as empty.
+SubHeading = Annotated[
+ str,
+ pydantic.StringConstraints(
+ strip_whitespace=True, min_length=1, max_length=SUB_HEADING_MAX_LENGTH
+ ),
+ pydantic.Field(
+ description=(
+ "Short call-to-action line describing what the agent does for the "
+ "user, e.g. 'Find decision-makers at any company in seconds'. "
+ f"Required; max {SUB_HEADING_MAX_LENGTH} characters."
+ ),
+ ),
+]
+
+
class ChangelogEntry(pydantic.BaseModel):
version: str
changes_summary: str
@@ -318,7 +337,7 @@ class StoreSubmissionRequest(pydantic.BaseModel):
)
slug: str
name: str
- sub_heading: str
+ sub_heading: SubHeading
video_url: str | None = None
agent_output_demo_url: str | None = None
image_urls: list[str] = []
@@ -335,7 +354,7 @@ class StoreSubmissionRequest(pydantic.BaseModel):
class StoreSubmissionEditRequest(pydantic.BaseModel):
name: str
- sub_heading: str
+ sub_heading: SubHeading
video_url: str | None = None
agent_output_demo_url: str | None = None
image_urls: list[str] = []
diff --git a/autogpt_platform/backend/backend/api/features/store/model_test.py b/autogpt_platform/backend/backend/api/features/store/model_test.py
new file mode 100644
index 0000000000..8d15ad90ec
--- /dev/null
+++ b/autogpt_platform/backend/backend/api/features/store/model_test.py
@@ -0,0 +1,66 @@
+import pydantic
+import pytest
+
+from .model import (
+ SUB_HEADING_MAX_LENGTH,
+ StoreSubmissionEditRequest,
+ StoreSubmissionRequest,
+)
+
+SUBMISSION_MODELS = [StoreSubmissionRequest, StoreSubmissionEditRequest]
+
+
[email protected]("model", SUBMISSION_MODELS)
[email protected]("blank", ["", " ", "\t\n "])
+def test_a_blank_sub_heading_is_rejected(model, blank):
+ with pytest.raises(pydantic.ValidationError) as exc:
+ build(model, blank)
+ assert exc.value.errors()[0]["type"] == "string_too_short"
+
+
[email protected]("model", SUBMISSION_MODELS)
+def test_a_cta_sub_heading_is_accepted(model):
+ cta = "Find decision-makers at any company in seconds"
+ assert build(model, cta).sub_heading == cta
+
+
[email protected]("model", SUBMISSION_MODELS)
+def test_surrounding_whitespace_is_stripped(model):
+ assert build(model, " Find leads fast ").sub_heading == "Find leads fast"
+
+
[email protected]("model", SUBMISSION_MODELS)
+def test_the_length_ceiling_is_enforced_on_the_stripped_value(model):
+ at_limit = "x" * SUB_HEADING_MAX_LENGTH
+ assert build(model, f" {at_limit} ").sub_heading == at_limit
+
+ with pytest.raises(pydantic.ValidationError) as exc:
+ build(model, "x" * (SUB_HEADING_MAX_LENGTH + 1))
+ assert exc.value.errors()[0]["type"] == "string_too_long"
+
+
[email protected]("model", SUBMISSION_MODELS)
+def test_sub_heading_has_no_default(model):
+ """A missing key must 422 rather than silently persisting an empty line."""
+ with pytest.raises(pydantic.ValidationError) as exc:
+ model.model_validate(
+ {
+ "graph_id": "graph-1",
+ "graph_version": 1,
+ "slug": "lead-finder",
+ "name": "Lead Finder",
+ "categories": ["sales"],
+ }
+ )
+ assert any(e["loc"] == ("sub_heading",) for e in exc.value.errors())
+
+
+def build(model: type[pydantic.BaseModel], sub_heading: str):
+ common = {
+ "name": "Lead Finder",
+ "sub_heading": sub_heading,
+ "categories": ["sales"],
+ }
+ if model is StoreSubmissionRequest:
+ common |= {"graph_id": "graph-1", "graph_version": 1, "slug": "lead-finder"}
+ return model(**common)
diff --git a/autogpt_platform/backend/scripts/backfill_store_sub_headings.py b/autogpt_platform/backend/scripts/backfill_store_sub_headings.py
new file mode 100644
index 0000000000..1512484530
--- /dev/null
+++ b/autogpt_platform/backend/scripts/backfill_store_sub_headings.py
@@ -0,0 +1,261 @@
+"""Backfill an empty ``StoreListingVersion.subHeading`` with a generated CTA.
+
+Marketplace listings now require a short call-to-action sub-heading, but rows
+predating that rule can hold an empty string, which leaves preview cards to
+fall back on the full description.
+
+A dry run (the default) generates a one-line CTA per listing from its name and
+description via ``gpt-4o-mini`` and writes ``id,name,description,
+proposed_sub_heading`` to the CSV; it writes nothing to the database. Review
+the CSV, editing or deleting rows as needed, then ``--apply`` writes that CSV's
+``proposed_sub_heading`` values to the rows whose subHeading is still empty.
+``--apply`` generates nothing.
+
+Usage::
+
+ poetry run python scripts/backfill_store_sub_headings.py # dry run
+ poetry run python scripts/backfill_store_sub_headings.py --apply
+"""
+
+from __future__ import annotations
+
+import argparse
+import asyncio
+import csv
+import os
+import sys
+from pathlib import Path
+
+DEFAULT_CSV_PATH = Path("store_sub_heading_backfill.csv")
+# Spreadsheet apps evaluate cells opening with these (CWE-1236).
+FORMULA_PREFIXES = ("=", "+", "-", "@", "\t", "\r")
+# Matches the API validator, which strips all whitespace; btrim() trims only spaces.
+BLANK_SUB_HEADING = "\"subHeading\" !~ '\\S'"
+
+MODEL = "gpt-4o-mini"
+MAX_OUTPUT_TOKENS = 40
+# One stuck call otherwise inherits the OpenAI client's 600s default (x2 retries).
+CALL_TIMEOUT_SECONDS = 30.0
+RATE_LIMIT_DELAY_SECONDS = 0.2
+
+SYSTEM_PROMPT = (
+ "You write one-line marketplace taglines for automation agents. "
+ "Given an agent's name and description, reply with a single "
+ "call-to-action line of at most {max_length} characters saying what the "
+ "agent does for the user. Start with a verb, name the outcome rather "
+ "than the mechanism, and use sentence case with no trailing period. "
+ "Example: 'Find decision-makers at any company in seconds'. "
+ "Output only the line."
+)
+
+
+async def main(
+ limit: int | None,
+ include_unapproved: bool,
+ csv_path: Path,
+ apply: bool,
+) -> int:
+ if not os.environ.get("DATABASE_URL"):
+ raise SystemExit("DATABASE_URL must be set")
+
+ # Imported lazily so --help works without the backend env being loaded.
+ from backend.api.features.store.model import SUB_HEADING_MAX_LENGTH
+ from backend.data.db import connect, disconnect
+
+ if apply:
+ reviewed = read_reviewed_csv(csv_path, SUB_HEADING_MAX_LENGTH)
+ await connect()
+ try:
+ written = await persist_sub_headings(reviewed)
+ finally:
+ await disconnect()
+ print(
+ f"Updated {written} of {len(reviewed)} listing version(s) from {csv_path}."
+ )
+ return 0
+
+ await connect()
+ try:
+ rows = await find_listings_without_sub_heading(limit, include_unapproved)
+ print(
+ f"{len(rows)} listing version(s) with an empty subHeading"
+ f"{'' if include_unapproved else ' (APPROVED only)'}."
+ )
+ if not rows:
+ return 0
+
+ proposals = await generate_sub_headings(rows, SUB_HEADING_MAX_LENGTH)
+ write_csv(csv_path, proposals)
+ print(f"Wrote {len(proposals)} proposal(s) to {csv_path}")
+
+ for row_id, name, _description, proposed in proposals[:5]:
+ print(f" {row_id} {name!r}\n -> {proposed!r}")
+
+ print(
+ f"\nDry run: nothing written. Review {csv_path}, then re-run with --apply."
+ )
+ return 0
+ finally:
+ await disconnect()
+
+
+async def find_listings_without_sub_heading(
+ limit: int | None, include_unapproved: bool
+) -> list[tuple[str, str, str]]:
+ from prisma import get_client
+
+ # Prisma has no "empty once trimmed" string filter.
+ status_clause = (
+ "" if include_unapproved else "AND \"submissionStatus\" = 'APPROVED'"
+ )
+ limit_clause = f"LIMIT {int(limit)}" if limit else ""
+ rows = await get_client().query_raw(
+ f"""
+ SELECT id, name, description
+ FROM platform."StoreListingVersion"
+ WHERE {BLANK_SUB_HEADING} AND "isDeleted" = false
+ {status_clause}
+ ORDER BY "createdAt" DESC
+ {limit_clause}
+ """
+ )
+ return [(r["id"], r["name"], r["description"]) for r in rows]
+
+
+async def generate_sub_headings(
+ rows: list[tuple[str, str, str]], max_length: int
+) -> list[tuple[str, str, str, str]]:
+ from backend.util.clients import get_openai_client
+
+ client = get_openai_client()
+ if client is None:
+ raise SystemExit("No OpenAI client configured (OPENAI_API_KEY unset)")
+
+ system_prompt = SYSTEM_PROMPT.format(max_length=max_length)
+ proposals: list[tuple[str, str, str, str]] = []
+ for index, (row_id, name, description) in enumerate(rows, start=1):
+ try:
+ response = await asyncio.wait_for(
+ client.chat.completions.create(
+ model=MODEL,
+ messages=[
+ {"role": "system", "content": system_prompt},
+ {
+ "role": "user",
+ "content": f"Name: {name}\nDescription: {description}",
+ },
+ ],
+ max_tokens=MAX_OUTPUT_TOKENS,
+ ),
+ timeout=CALL_TIMEOUT_SECONDS,
+ )
+ except asyncio.TimeoutError:
+ print(f" [{index}/{len(rows)}] timed out on {row_id}", file=sys.stderr)
+ continue
+ except Exception as exc: # noqa: BLE001 - one bad row must not end the run
+ print(f" [{index}/{len(rows)}] failed on {row_id}: {exc}", file=sys.stderr)
+ continue
+
+ proposed = clean_sub_heading(
+ response.choices[0].message.content or "", max_length
+ )
+ if proposed:
+ proposals.append((row_id, name, description, proposed))
+ else:
+ print(
+ f" [{index}/{len(rows)}] empty generation for {row_id}",
+ file=sys.stderr,
+ )
+
+ await asyncio.sleep(RATE_LIMIT_DELAY_SECONDS)
+
+ return proposals
+
+
+def clean_sub_heading(raw: str, max_length: int) -> str:
+ """Strip the quoting and trailing period models add, then enforce the cap."""
+ line = raw.strip().split("\n")[0].strip().strip('"').strip("'").rstrip(".").strip()
+ if len(line) <= max_length:
+ return line
+ # Truncating mid-word would ship a broken line; drop the row for review instead.
+ return ""
+
+
+def write_csv(path: Path, proposals: list[tuple[str, str, str, str]]) -> None:
+ with path.open("w", newline="", encoding="utf-8") as handle:
+ writer = csv.writer(handle)
+ writer.writerow(["id", "name", "description", "proposed_sub_heading"])
+ writer.writerows(
+ (row_id, *(escape_formula(cell) for cell in cells))
+ for row_id, *cells in proposals
+ )
+
+
+def read_reviewed_csv(path: Path, max_length: int) -> list[tuple[str, str]]:
+ if not path.exists():
+ raise SystemExit(f"{path} not found: run without --apply first to create it")
+ reviewed: list[tuple[str, str]] = []
+ with path.open(newline="", encoding="utf-8") as handle:
+ for row in csv.DictReader(handle):
+ row_id = row["id"].strip()
+ proposed = unescape_formula(row["proposed_sub_heading"]).strip()
+ if not proposed or len(proposed) > max_length:
+ print(f" skipping {row_id}: {proposed!r} is empty or too long")
+ continue
+ reviewed.append((row_id, proposed))
+ return reviewed
+
+
+def escape_formula(cell: str) -> str:
+ return "'" + cell if cell.startswith(FORMULA_PREFIXES) else cell
+
+
+def unescape_formula(cell: str) -> str:
+ return (
+ cell[1:] if cell[:1] == "'" and cell[1:].startswith(FORMULA_PREFIXES) else cell
+ )
+
+
+async def persist_sub_headings(reviewed: list[tuple[str, str]]) -> int:
+ from prisma import get_client
+
+ client = get_client()
+ written = 0
+ for row_id, proposed in reviewed:
+ # The emptiness re-check keeps a concurrent edit from being overwritten.
+ written += await client.execute_raw(
+ f"""
+ UPDATE platform."StoreListingVersion"
+ SET "subHeading" = $2
+ WHERE id = $1 AND {BLANK_SUB_HEADING}
+ """,
+ row_id,
+ proposed,
+ )
+ return written
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--limit", type=int, default=None, help="Dry run only.")
+ parser.add_argument(
+ "--include-unapproved",
+ action="store_true",
+ help="Dry run only: also cover DRAFT/PENDING/REJECTED versions, which fail "
+ "validation on edit.",
+ )
+ parser.add_argument(
+ "--csv",
+ type=Path,
+ default=DEFAULT_CSV_PATH,
+ help="Written by a dry run; read by --apply.",
+ )
+ parser.add_argument(
+ "--apply",
+ action="store_true",
+ help="Write the reviewed CSV's proposed_sub_heading values. Generates nothing.",
+ )
+ args = parser.parse_args()
+ raise SystemExit(
+ asyncio.run(main(args.limit, args.include_unapproved, args.csv, args.apply))
+ )
diff --git a/autogpt_platform/backend/scripts/test_backfill_store_sub_headings.py b/autogpt_platform/backend/scripts/test_backfill_store_sub_headings.py
new file mode 100644
index 0000000000..2f7fc1c50d
--- /dev/null
+++ b/autogpt_platform/backend/scripts/test_backfill_store_sub_headings.py
@@ -0,0 +1,92 @@
+"""Tests for the store sub-heading backfill script's CSV review round trip."""
+
+import csv
+from pathlib import Path
+from unittest.mock import AsyncMock
+
+import pytest
+
+import scripts.backfill_store_sub_headings as backfill
+
+
+ ("cell", "expected"),
+ [
+ (
+ '=HYPERLINK("https://evil.example","x")',
+ '\'=HYPERLINK("https://evil.example","x")',
+ ),
+ ("+1+1", "'+1+1"),
+ ("-2+3", "'-2+3"),
+ ("@SUM(A1)", "'@SUM(A1)"),
+ ("\t=1", "'\t=1"),
+ ("Find leads in seconds", "Find leads in seconds"),
+ ],
+)
+def test_write_csv_neutralises_formula_cells(tmp_path: Path, cell: str, expected: str):
+ path = tmp_path / "out.csv"
+ backfill.write_csv(path, [("id-1", cell, cell, cell)])
+
+ with path.open(newline="", encoding="utf-8") as handle:
+ rows = list(csv.reader(handle))
+
+ assert rows[1] == ["id-1", expected, expected, expected]
+
+
+def test_reviewed_csv_round_trips_and_honours_edits(tmp_path: Path):
+ path = tmp_path / "out.csv"
+ backfill.write_csv(
+ path,
+ [
+ ("keep", "n", "d", "Find leads in seconds"),
+ ("formula", "n", "d", "=not a formula once applied"),
+ ("edited", "n", "d", "Generated line"),
+ ("blank", "n", "d", "Will be blanked"),
+ ("long", "n", "d", "Will be lengthened"),
+ ],
+ )
+ rows = list(csv.reader(path.open(newline="", encoding="utf-8")))
+ rows[3][3] = "Reviewer's line"
+ rows[4][3] = " "
+ rows[5][3] = "x" * 101
+ with path.open("w", newline="", encoding="utf-8") as handle:
+ csv.writer(handle).writerows(rows)
+
+ assert backfill.read_reviewed_csv(path, 100) == [
+ ("keep", "Find leads in seconds"),
+ ("formula", "=not a formula once applied"),
+ ("edited", "Reviewer's line"),
+ ]
+
+
+async def test_apply_persists_the_reviewed_csv_without_generating(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+):
+ path = tmp_path / "out.csv"
+ backfill.write_csv(path, [("id-1", "n", "d", "Reviewer-approved line")])
+ monkeypatch.setenv("DATABASE_URL", "postgresql://unused")
+ monkeypatch.setattr("backend.data.db.connect", AsyncMock())
+ monkeypatch.setattr("backend.data.db.disconnect", AsyncMock())
+ generate = AsyncMock(side_effect=AssertionError("--apply must not generate"))
+ monkeypatch.setattr(backfill, "generate_sub_headings", generate)
+ monkeypatch.setattr(backfill, "find_listings_without_sub_heading", generate)
+ persist = AsyncMock(return_value=1)
+ monkeypatch.setattr(backfill, "persist_sub_headings", persist)
+ before = path.read_bytes()
+
+ assert await backfill.main(None, False, path, apply=True) == 0
+
+ persist.assert_awaited_once_with([("id-1", "Reviewer-approved line")])
+ assert path.read_bytes() == before
+
+
+async def test_apply_without_a_reviewed_csv_refuses(
+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+):
+ monkeypatch.setenv("DATABASE_URL", "postgresql://unused")
+ connect = AsyncMock()
+ monkeypatch.setattr("backend.data.db.connect", connect)
+
+ with pytest.raises(SystemExit, match="run without --apply first"):
+ await backfill.main(None, False, tmp_path / "missing.csv", apply=True)
+ connect.assert_not_awaited()
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 386a5d6840..bd46f90c6e 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -30330,7 +30330,13 @@
"StoreSubmissionEditRequest": {
"properties": {
"name": { "type": "string", "title": "Name" },
- "sub_heading": { "type": "string", "title": "Sub Heading" },
+ "sub_heading": {
+ "type": "string",
+ "maxLength": 100,
+ "minLength": 1,
+ "title": "Sub Heading",
+ "description": "Short call-to-action line describing what the agent does for the user, e.g. 'Find decision-makers at any company in seconds'. Required; max 100 characters."
+ },
"video_url": {
"anyOf": [{ "type": "string" }, { "type": "null" }],
"title": "Video Url"
@@ -30388,7 +30394,13 @@
},
"slug": { "type": "string", "title": "Slug" },
"name": { "type": "string", "title": "Name" },
- "sub_heading": { "type": "string", "title": "Sub Heading" },
+ "sub_heading": {
+ "type": "string",
+ "maxLength": 100,
+ "minLength": 1,
+ "title": "Sub Heading",
+ "description": "Short call-to-action line describing what the agent does for the user, e.g. 'Find decision-makers at any company in seconds'. Required; max 100 characters."
+ },
"video_url": {
"anyOf": [{ "type": "string" }, { "type": "null" }],
"title": "Video Url"
diff --git a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/__tests__/EditAgentModal.test.tsx b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/__tests__/EditAgentModal.test.tsx
index 1f3089c05f..f329b1f272 100644
--- a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/__tests__/EditAgentModal.test.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/__tests__/EditAgentModal.test.tsx
@@ -58,6 +58,22 @@ describe("EditAgentModal", () => {
).toBeDefined();
});
+ it("counts the tagline against its 100-character limit", () => {
+ render(
+ <EditAgentModal
+ isOpen={true}
+ onClose={() => {}}
+ submission={makeSubmission()}
+ onSuccess={() => {}}
+ />,
+ );
+
+ const counts = screen
+ .getAllByTestId("char-count")
+ .map((el) => el.textContent);
+ expect(counts).toContain("9 / 100");
+ });
+
it("disables the category field when the category list cannot be loaded", async () => {
server.use(
http.get("http://localhost:3000/api/proxy/api/store/categories", () =>
diff --git a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsx b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsx
index 02dcacfec1..8f55f3046e 100644
--- a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/EditAgentForm.tsx
@@ -17,6 +17,7 @@ import {
import { CharCountedTextarea } from "../../PublishAgentModal/components/AgentInfoStep/components/CharCountedTextarea";
import { ThumbnailImages } from "../../PublishAgentModal/components/AgentInfoStep/components/ThumbnailImages";
+import { SUB_HEADING_MAX } from "../../PublishAgentModal/components/AgentInfoStep/helpers";
import { useEditAgentForm } from "./useEditAgentForm";
import {
@@ -187,16 +188,22 @@ export function EditAgentForm({
control={form.control}
name="subheader"
render={({ field }) => (
- <Input
- id={field.name}
- labelVariant="body"
- label="Subheader"
- labelTooltip="One-sentence tagline displayed under the title."
- type="text"
- placeholder="A concise tagline for your agent"
- error={form.formState.errors.subheader?.message}
- {...field}
- />
+ <CharCountedTextarea
+ max={SUB_HEADING_MAX}
+ value={field.value ?? ""}
+ >
+ <Input
+ id={field.name}
+ labelVariant="body"
+ label="Tagline"
+ labelTooltip="The one-line subtitle shown under the agent name and on preview cards. Start with a verb and name the outcome for the user."
+ type="text"
+ placeholder="Find decision-makers at any company in seconds"
+ error={form.formState.errors.subheader?.message}
+ required
+ {...field}
+ />
+ </CharCountedTextarea>
)}
/>
</div>
diff --git a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.ts b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.ts
index 2e5a4ef1b3..de1d021d20 100644
--- a/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.ts
+++ b/autogpt_platform/frontend/src/components/contextual/EditAgentModal/components/useEditAgentForm.ts
@@ -8,6 +8,7 @@ import { StoreSubmissionEditRequest } from "@/app/api/__generated__/models/store
import { useToast } from "@/components/molecules/Toast/use-toast";
import { useStoreCategories } from "@/hooks/useStoreCategories";
import { validateYouTubeUrl } from "@/lib/utils";
+import { SUB_HEADING_MAX } from "../../PublishAgentModal/components/AgentInfoStep/helpers";
import { zodResolver } from "@hookform/resolvers/zod";
import { useQueryClient } from "@tanstack/react-query";
import React from "react";
@@ -35,8 +36,12 @@ export const useEditAgentForm = ({
.max(100, "Title must be less than 100 characters"),
subheader: z
.string()
- .min(1, "Subheader is required")
- .max(200, "Subheader must be less than 200 characters"),
+ .trim()
+ .min(1, "Tagline is required")
+ .max(
+ SUB_HEADING_MAX,
+ `Tagline must be ${SUB_HEADING_MAX} characters or less`,
+ ),
youtubeLink: z
.string()
.refine(validateYouTubeUrl, "Please enter a valid YouTube URL"),
diff --git a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/AgentInfoStep.tsx b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/AgentInfoStep.tsx
index 9488faeb4f..5700e84a3b 100644
--- a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/AgentInfoStep.tsx
+++ b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/AgentInfoStep.tsx
@@ -22,6 +22,7 @@ import { StepFooter } from "../StepFooter";
import { ThumbnailImages } from "./components/ThumbnailImages";
import { CharCountedTextarea } from "./components/CharCountedTextarea";
import { Props, useAgentInfoStep } from "./useAgentInfoStep";
+import { SUB_HEADING_MAX } from "./helpers";
import {
Album01Icon,
AlertCircleIcon,
@@ -223,16 +224,22 @@ export function AgentInfoStep({
control={form.control}
name="subheader"
render={({ field }) => (
- <Input
- id={field.name}
- labelVariant="body"
- label="Subheader"
- labelTooltip="One-sentence tagline displayed under the title."
- type="text"
- placeholder="A concise tagline for your agent"
- error={form.formState.errors.subheader?.message}
- {...field}
- />
+ <CharCountedTextarea
+ max={SUB_HEADING_MAX}
+ value={field.value ?? ""}
+ >
+ <Input
+ id={field.name}
+ labelVariant="body"
+ label="Tagline"
+ labelTooltip="The one-line subtitle shown under the agent name and on preview cards. Start with a verb and name the outcome for the user."
+ type="text"
+ placeholder="Find decision-makers at any company in seconds"
+ error={form.formState.errors.subheader?.message}
+ required
+ {...field}
+ />
+ </CharCountedTextarea>
)}
/>
</div>
diff --git a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/__tests__/helpers.test.ts
index dc68db5b4e..2a9ad86efd 100644
--- a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/__tests__/helpers.test.ts
+++ b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/__tests__/helpers.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { publishAgentSchemaFactory } from "../helpers";
+import { SUB_HEADING_MAX, publishAgentSchemaFactory } from "../helpers";
const validBase = {
title: "My Agent",
@@ -76,16 +76,56 @@ describe("publishAgentSchemaFactory", () => {
expect(result.success).toBe(true);
});
- it("treats title and subheader as optional on updates", () => {
+ it("treats the title as optional on updates", () => {
const result = publishAgentSchemaFactory(true).safeParse({
...validBase,
title: "",
- subheader: "",
changesSummary: "Refreshed copy",
});
expect(result.success).toBe(true);
});
+ it.each([false, true])(
+ "requires a non-blank tagline (isMarketplaceUpdate=%s)",
+ (isUpdate) => {
+ for (const subheader of ["", " ", "\t\n "]) {
+ const result = publishAgentSchemaFactory(isUpdate).safeParse({
+ ...validBase,
+ subheader,
+ changesSummary: "Refreshed copy",
+ });
+ expect(result.success).toBe(false);
+ }
+ },
+ );
+
+ it("accepts a CTA-shaped tagline and trims it", () => {
+ const result = publishAgentSchemaFactory(false).safeParse({
+ ...validBase,
+ subheader: " Find decision-makers at any company in seconds ",
+ });
+ expect(result.success).toBe(true);
+ if (result.success) {
+ expect(result.data.subheader).toBe(
+ "Find decision-makers at any company in seconds",
+ );
+ }
+ });
+
+ it("caps the tagline at the shared length ceiling", () => {
+ const atLimit = publishAgentSchemaFactory(false).safeParse({
+ ...validBase,
+ subheader: "x".repeat(SUB_HEADING_MAX),
+ });
+ expect(atLimit.success).toBe(true);
+
+ const overLimit = publishAgentSchemaFactory(false).safeParse({
+ ...validBase,
+ subheader: "x".repeat(SUB_HEADING_MAX + 1),
+ });
+ expect(overLimit.success).toBe(false);
+ });
+
it("still requires a category on updates, which overwrite the stored ones", () => {
const result = publishAgentSchemaFactory(true).safeParse({
...validBase,
diff --git a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/helpers.ts b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/helpers.ts
index 8ba9d32b4b..046a038676 100644
--- a/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/helpers.ts
+++ b/autogpt_platform/frontend/src/components/contextual/PublishAgentModal/components/AgentInfoStep/helpers.ts
@@ -1,6 +1,9 @@
import z from "zod";
import { validateYouTubeUrl } from "@/lib/utils";
+// Mirrors SUB_HEADING_MAX_LENGTH in backend/api/features/store/model.py.
+export const SUB_HEADING_MAX = 100;
+
// Create conditional schema that changes based on whether it's a marketplace update
export const publishAgentSchemaFactory = (
isMarketplaceUpdate: boolean = false,
@@ -24,18 +27,14 @@ export const publishAgentSchemaFactory = (
.string()
.min(1, "Title is required")
.max(100, "Title must be less than 100 characters"),
- subheader: isMarketplaceUpdate
- ? z
- .string()
- .optional()
- .refine(
- (val) => !val || val.length <= 200,
- "Subheader must be less than 200 characters",
- )
- : z
- .string()
- .min(1, "Subheader is required")
- .max(200, "Subheader must be less than 200 characters"),
+ subheader: z
+ .string()
+ .trim()
+ .min(1, "Tagline is required")
+ .max(
+ SUB_HEADING_MAX,
+ `Tagline must be ${SUB_HEADING_MAX} characters or less`,
+ ),
slug: isMarketplaceUpdate
? z
.string()
diff --git a/autogpt_platform/frontend/src/playwright/pages/marketplace.page.ts b/autogpt_platform/frontend/src/playwright/pages/marketplace.page.ts
index 84691acbcb..8dc40269cd 100644
--- a/autogpt_platform/frontend/src/playwright/pages/marketplace.page.ts
+++ b/autogpt_platform/frontend/src/playwright/pages/marketplace.page.ts
@@ -255,8 +255,8 @@ export class MarketplacePage extends BasePage {
await publishAgentModal.getByLabel("Title").fill(agentTitle);
await publishAgentModal
- .getByLabel("Subheader")
- .fill("A deterministic marketplace submission");
+ .getByLabel("Tagline")
+ .fill("Publish a deterministic marketplace submission");
await publishAgentModal.getByLabel("Slug").fill(agentSlug);
await publishAgentModal.getByRole("combobox", { name: "Category" }).click();