Skip to content

Open-source SEO, GEO, and marketing skills for AI agents.

refactor(agents): personal name + role identity, immutable after creation

Yuting Zhong75671d5980cd
diff --git a/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsx b/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsx
index bc8b19ff..e6ef1143 100644
--- a/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsx
+++ b/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsx
@@ -102,7 +102,7 @@ export default async function AgentChatThreadPage({
key={threadId}
projectSlug={projectSlug}
agentSlug={agentSlug}
- agentDisplayName={resolved.display_name}
+ agentDisplayName={resolved.name}
threadId={threadId}
sessionKey={sessionKey}
initialEvents={initialEvents}
diff --git a/src/app/(app)/[project]/agents/[agent]/cron/page.tsx b/src/app/(app)/[project]/agents/[agent]/cron/page.tsx
index 43ec4962..3abd2188 100644
--- a/src/app/(app)/[project]/agents/[agent]/cron/page.tsx
+++ b/src/app/(app)/[project]/agents/[agent]/cron/page.tsx
@@ -129,7 +129,7 @@ export default async function AgentCronPage({
<header className="flex flex-row items-center justify-between gap-4">
<div>
<h2 className="text-lg font-semibold tracking-tight">
- {resolved.display_name}&rsquo;s scheduled work
+ {resolved.name}&rsquo;s scheduled work
</h2>
<p className="text-sm text-muted-foreground">
{totalActive} active
@@ -153,7 +153,7 @@ export default async function AgentCronPage({
<Card>
<CardContent className="space-y-2 py-10 text-center">
<p className="text-sm font-medium">
- No scheduled work for {resolved.display_name} yet.
+ No scheduled work for {resolved.name} yet.
</p>
<p className="text-xs text-muted-foreground">
Ask the agent in chat (&ldquo;run a daily bid review at 9am&rdquo;) or
diff --git a/src/app/(app)/[project]/agents/[agent]/settings/page.tsx b/src/app/(app)/[project]/agents/[agent]/settings/page.tsx
index cdad208d..dbdaafc8 100644
--- a/src/app/(app)/[project]/agents/[agent]/settings/page.tsx
+++ b/src/app/(app)/[project]/agents/[agent]/settings/page.tsx
@@ -1,9 +1,9 @@
import { notFound } from "next/navigation";
import { Card, CardContent } from "@/components/ui/card";
+import { TEMPLATES } from "@/server/agent-templates";
import { getProject } from "@/server/db/projects";
import { resolveAgentBySlug, readAgentMeta } from "@/server/agent-meta";
import { AgentDangerZone } from "@/components/agent-danger-zone";
-import { AgentRenameCard } from "@/components/agent-rename-card";
type Params = { agent: string; project: string };
@@ -19,6 +19,9 @@ export default async function AgentSettingsPage({
if (!resolved) notFound();
const meta = readAgentMeta(resolved.agent_id);
+ const role = resolved.template_key
+ ? TEMPLATES.find((t) => t.key === resolved.template_key)
+ : undefined;
return (
<div className="h-full overflow-y-auto p-6">
@@ -26,7 +29,7 @@ export default async function AgentSettingsPage({
<header>
<h2 className="text-lg font-semibold tracking-tight">Settings</h2>
<p className="text-sm text-muted-foreground">
- {resolved.display_name}{" "}
+ {resolved.name}{" "}
<span className="font-mono text-xs">· {resolved.agent_id}</span>
</p>
</header>
@@ -34,22 +37,22 @@ export default async function AgentSettingsPage({
<Card>
<CardContent className="p-4">
<dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-sm">
- <dt className="text-muted-foreground">Agent id</dt>
- <dd className="font-mono text-xs">{resolved.agent_id}</dd>
+ <dt className="text-muted-foreground">Name</dt>
+ <dd>{resolved.name}</dd>
- <dt className="text-muted-foreground">URL slug</dt>
- <dd className="font-mono text-xs">{resolved.slug}</dd>
-
- <dt className="text-muted-foreground">Display name</dt>
- <dd>{resolved.display_name}</dd>
-
- {resolved.template_key && (
+ {role && (
<>
- <dt className="text-muted-foreground">Template</dt>
- <dd className="font-mono text-xs">{resolved.template_key}</dd>
+ <dt className="text-muted-foreground">Role</dt>
+ <dd>{role.display_name}</dd>
</>
)}
+ <dt className="text-muted-foreground">URL slug</dt>
+ <dd className="font-mono text-xs">{resolved.slug}</dd>
+
+ <dt className="text-muted-foreground">Agent id</dt>
+ <dd className="font-mono text-xs">{resolved.agent_id}</dd>
+
{meta?.source_agent_id && (
<>
<dt className="text-muted-foreground">Cloned from</dt>
@@ -66,23 +69,21 @@ export default async function AgentSettingsPage({
</>
)}
</dl>
+ <p className="mt-4 border-t pt-3 text-xs text-muted-foreground">
+ Agent identity is immutable. The name set at onboarding stays
+ fixed for the life of the project; the URL slug is computed
+ from the role + name.
+ </p>
</CardContent>
</Card>
- <AgentRenameCard
- agentId={resolved.agent_id}
- projectSlug={project.slug}
- currentDisplayName={resolved.display_name}
- currentSlug={resolved.slug}
- />
-
<section className="space-y-2 pt-2">
<h3 className="text-xs font-semibold uppercase tracking-wide text-muted-foreground">
Danger zone
</h3>
<AgentDangerZone
agentId={resolved.agent_id}
- agentDisplayName={resolved.display_name}
+ agentDisplayName={resolved.name}
/>
</section>
</div>
diff --git a/src/app/(app)/[project]/agents/[agent]/skills/page.tsx b/src/app/(app)/[project]/agents/[agent]/skills/page.tsx
index c45dde54..622d90d4 100644
--- a/src/app/(app)/[project]/agents/[agent]/skills/page.tsx
+++ b/src/app/(app)/[project]/agents/[agent]/skills/page.tsx
@@ -35,7 +35,7 @@ export default async function AgentSkillsPage({
<header>
<h2 className="text-lg font-semibold tracking-tight">Skills</h2>
<p className="text-sm text-muted-foreground">
- Capabilities OpenClaw exposes to {resolved.display_name}.
+ Capabilities OpenClaw exposes to {resolved.name}.
{report?.agentSkillFilter?.length
? ` Filtered to this agent's allowlist (${report.agentSkillFilter.length}).`
: " Workspace-wide; no per-agent filter."}
diff --git a/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx b/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx
index 8970e345..8b0b69db 100644
--- a/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx
+++ b/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx
@@ -78,7 +78,7 @@ export default async function AgentTasksPage({ params, searchParams }: Props) {
projectSlug={projectSlug}
agentSlug={agentSlug}
agentFullId={agentFullId}
- agentDisplayName={resolved.display_name}
+ agentDisplayName={resolved.name}
tasks={tasks}
selected={selected}
proposedCount={proposedCount}
diff --git a/src/app/(app)/[project]/agents/page.tsx b/src/app/(app)/[project]/agents/page.tsx
index f662896d..ff027e99 100644
--- a/src/app/(app)/[project]/agents/page.tsx
+++ b/src/app/(app)/[project]/agents/page.tsx
@@ -5,12 +5,8 @@ import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { notFound } from "next/navigation";
import { getProject } from "@/server/db/projects";
-import {
- TEMPLATES,
- urlSlugForTemplate,
- agentNameFor,
- type AgentTemplateKey,
-} from "@/server/agent-templates";
+import { TEMPLATES } from "@/server/agent-templates";
+import { listProjectAgents } from "@/server/agent-meta";
import { listCronsForProject } from "@/server/openclaw/crons";
import { reprovisionAgentsAction } from "@/server/actions/projects";
import { ReprovisionButton } from "@/components/reprovision-button";
@@ -25,13 +21,16 @@ export default async function AgentsPage({
const project = getProject(slug);
if (!project || project.archived_at) notFound();
- // Best-effort cron count per agent.
+ // Best-effort cron count per agent (keyed by agent_id, since slugs now
+ // encode names — the cron rows still bucket by full agent id).
const cronByAgent = new Map<string, number>();
try {
const view = await listCronsForProject(project.slug);
for (const g of view.groups) cronByAgent.set(g.agent, g.crons.length);
} catch {}
+ const projectAgents = await listProjectAgents(project.slug);
+
// Bind the project slug into the server action for the client button.
const reprovision = reprovisionAgentsAction.bind(null, project.slug);
@@ -41,20 +40,23 @@ export default async function AgentsPage({
<div>
<h1 className="text-2xl font-semibold tracking-tight">Agents</h1>
<p className="text-sm text-muted-foreground">
- Project <span className="font-mono">{project.slug}</span> · {TEMPLATES.length}{" "}
- agents available · all running on OpenClaw with your configured model + fallback chain
+ Project <span className="font-mono">{project.slug}</span> ·{" "}
+ {projectAgents.length} agent
+ {projectAgents.length === 1 ? "" : "s"} · all running on OpenClaw
+ with your configured model + fallback chain
</p>
</div>
<ReprovisionButton action={reprovision} />
</header>
<div className="grid gap-4">
- {TEMPLATES.map((t) => {
- const agentSlug = urlSlugForTemplate(t.key as AgentTemplateKey);
- const fullId = agentNameFor(project.slug, t.key as AgentTemplateKey);
- const crons = cronByAgent.get(agentSlug) ?? 0;
+ {projectAgents.map((agent) => {
+ const role = agent.template_key
+ ? TEMPLATES.find((t) => t.key === agent.template_key)
+ : undefined;
+ const crons = cronByAgent.get(agent.agent_id) ?? 0;
return (
- <Card key={t.key}>
+ <Card key={agent.agent_id}>
<CardHeader className="flex flex-row items-start justify-between space-y-0">
<div className="flex items-start gap-3">
<div className="flex size-9 shrink-0 items-center justify-center rounded-md bg-muted">
@@ -62,12 +64,22 @@ export default async function AgentsPage({
</div>
<div className="space-y-1">
<div className="flex flex-wrap items-baseline gap-x-2">
- <h2 className="text-base font-semibold">{t.display_name}</h2>
+ <h2 className="text-base font-semibold">{agent.name}</h2>
+ {role && (
+ <Badge
+ variant="outline"
+ className="text-[10px] font-medium uppercase tracking-wider"
+ >
+ {role.display_name}
+ </Badge>
+ )}
<Badge variant="outline" className="text-[10px] font-mono">
- {fullId}
+ {agent.agent_id}
</Badge>
</div>
- <p className="text-sm text-muted-foreground">{t.description}</p>
+ <p className="text-sm text-muted-foreground">
+ {role?.description ?? agent.description ?? ""}
+ </p>
</div>
</div>
<div className="flex shrink-0 items-center gap-2">
@@ -81,23 +93,25 @@ export default async function AgentsPage({
</Link>
)}
<Button asChild size="sm">
- <Link href={projectHref(slug, `/agents/${agentSlug}/chat`)}>
+ <Link href={projectHref(slug, `/agents/${agent.slug}/chat`)}>
<MessageSquare className="mr-1.5 size-4" />
Chat
</Link>
</Button>
</div>
</CardHeader>
- <CardContent>
- <ul className="grid grid-cols-1 gap-1.5 text-sm md:grid-cols-2">
- {t.capabilities.map((c) => (
- <li key={c} className="flex items-start gap-2">
- <Check className="mt-0.5 size-3.5 shrink-0 text-emerald-600" />
- <span>{c}</span>
- </li>
- ))}
- </ul>
- </CardContent>
+ {role && (
+ <CardContent>
+ <ul className="grid grid-cols-1 gap-1.5 text-sm md:grid-cols-2">
+ {role.capabilities.map((c) => (
+ <li key={c} className="flex items-start gap-2">
+ <Check className="mt-0.5 size-3.5 shrink-0 text-emerald-600" />
+ <span>{c}</span>
+ </li>
+ ))}
+ </ul>
+ </CardContent>
+ )}
</Card>
);
})}
diff --git a/src/app/(app)/[project]/page.tsx b/src/app/(app)/[project]/page.tsx
index 1900ff8f..e343080c 100644
--- a/src/app/(app)/[project]/page.tsx
+++ b/src/app/(app)/[project]/page.tsx
@@ -15,11 +15,8 @@ import { costToday } from "@/server/db/cost";
import { listPendingApprovals } from "@/server/db/approvals";
import { listTasks } from "@/server/db/tasks";
import { listAgentActions } from "@/server/db/agent-actions";
-import {
- TEMPLATES,
- urlSlugForTemplate,
- type AgentTemplateKey,
-} from "@/server/agent-templates";
+import { TEMPLATES } from "@/server/agent-templates";
+import { listProjectAgents } from "@/server/agent-meta";
import { projectHref } from "@/lib/project-href";
function formatUsd(n: number) {
@@ -47,6 +44,14 @@ export default async function ProjectHomePage({
const pending = listPendingApprovals(project.slug);
const tasks = listTasks(project.slug);
const recent = listAgentActions(project.slug, 8);
+ const projectAgents = await listProjectAgents(project.slug);
+ // CMO's URL slug (e.g. "cmo-greg") for any "chat with CMO" deep links
+ // on this page. Falls back to a sensible empty path; the project home
+ // is fine if CMO somehow isn't provisioned yet.
+ const cmoAgent = projectAgents.find((a) => a.template_key === "cmo");
+ const cmoChatHref = cmoAgent
+ ? projectHref(slug, `/agents/${cmoAgent.slug}/chat`)
+ : projectHref(slug, "");
// Intentionally NOT calling openclaw here. The cron tab is the source of
// truth for scheduled jobs; calling `openclaw cron list` from the home page
@@ -63,7 +68,7 @@ export default async function ProjectHomePage({
</p>
</div>
<Button asChild>
- <Link href={projectHref(slug, "/agents/cmo/chat")}>
+ <Link href={cmoChatHref}>
<MessageSquare className="mr-1.5 size-4" />
Chat with CMO
</Link>
@@ -116,20 +121,31 @@ export default async function ProjectHomePage({
</div>
</CardHeader>
<CardContent className="space-y-2">
- {TEMPLATES.map((t) => {
- const agentSlug = urlSlugForTemplate(t.key as AgentTemplateKey);
+ {projectAgents.map((agent) => {
+ const role = agent.template_key
+ ? TEMPLATES.find((t) => t.key === agent.template_key)
+ : undefined;
return (
<Link
- key={t.key}
- href={projectHref(slug, `/agents/${agentSlug}/chat`)}
+ key={agent.agent_id}
+ href={projectHref(slug, `/agents/${agent.slug}/chat`)}
className="flex items-center gap-3 rounded-md border bg-card p-3 transition-colors hover:bg-accent/50"
>
<div className="flex size-8 shrink-0 items-center justify-center rounded-md bg-muted">
<Bot className="size-4" />
</div>
<div className="min-w-0 flex-1">
- <div className="font-medium">{t.display_name}</div>
- <p className="line-clamp-1 text-xs text-muted-foreground">{t.description}</p>
+ <div className="flex items-baseline gap-2">
+ <span className="font-medium">{agent.name}</span>
+ {role && (
+ <span className="text-[10px] uppercase tracking-wide text-muted-foreground">
+ {role.display_name}
+ </span>
+ )}
+ </div>
+ <p className="line-clamp-1 text-xs text-muted-foreground">
+ {role?.description ?? agent.description ?? ""}
+ </p>
</div>
<MessageSquare className="size-4 shrink-0 text-muted-foreground" />
</Link>
diff --git a/src/app/(app)/[project]/tasks/[id]/page.tsx b/src/app/(app)/[project]/tasks/[id]/page.tsx
index 83595816..ce58ed1f 100644
--- a/src/app/(app)/[project]/tasks/[id]/page.tsx
+++ b/src/app/(app)/[project]/tasks/[id]/page.tsx
@@ -3,14 +3,17 @@ import { notFound, redirect } from "next/navigation";
import { readAgentMeta } from "@/server/agent-meta";
import { getProject } from "@/server/db/projects";
import { getTask } from "@/server/db/tasks";
-import { urlSlugForTemplate, type AgentTemplateKey } from "@/server/agent-templates";
+import {
+ TEMPLATES,
+ agentUrlSlug,
+ type AgentTemplateKey,
+} from "@/server/agent-templates";
import { projectHref } from "@/lib/project-href";
/**
* Deep-link destination for task IDs. The canonical view lives in the agent
* workspace, so we resolve the task's owning agent and redirect there with
- * the task pre-selected. Keeps existing orchestration-summary links + emails
- * + bookmarks working through the rework.
+ * the task pre-selected.
*/
export default async function TaskDetailPage({
params,
@@ -24,15 +27,26 @@ export default async function TaskDetailPage({
const task = getTask(id);
if (!task || task.project_slug !== project.slug) notFound();
- // Resolve the assignee's URL slug. Templates predate cloned agents — fall
- // back to the template default if no per-agent slug is stored.
- const meta = await readAgentMeta(task.agent_id);
- const templateKey = (meta?.template_key as AgentTemplateKey | undefined) ?? "google_ads";
- const agentSlug = meta?.slug ?? urlSlugForTemplate(templateKey);
+ // Resolve the assignee's URL slug. For template agents the slug is
+ // `<role>-<personal-name>`; for clones we use the slug stored on the
+ // meta sidecar.
+ const meta = readAgentMeta(task.agent_id);
+ let agentSlug: string;
+ if (meta?.template_key) {
+ const template = TEMPLATES.find((t) => t.key === meta.template_key);
+ const role = (meta.template_key as AgentTemplateKey) ?? "google_ads";
+ const name = meta.name ?? template?.default_name ?? "agent";
+ agentSlug = agentUrlSlug(role, name);
+ } else if (meta?.slug) {
+ agentSlug = meta.slug;
+ } else {
+ // No meta on disk yet — fall back to the agent_id's tail.
+ agentSlug = task.agent_id.replace(`${slug}-`, "");
+ }
// Use the human-readable display_id in the canonical URL so the path
// someone bookmarks reads "?task=demo7-3" not a UUID. getTask in the
- // workspace accepts either form, so legacy UUID deep-links still resolve.
+ // workspace accepts either form.
redirect(
projectHref(slug, `/agents/${agentSlug}/tasks?task=${task.display_id}`),
);
diff --git a/src/components/agent-nav.test.tsx b/src/components/agent-nav.test.tsx
index e7577bc1..266c2aab 100644
--- a/src/components/agent-nav.test.tsx
+++ b/src/components/agent-nav.test.tsx
@@ -30,20 +30,22 @@ import { AgentNav } from "./agent-nav";
const agents = [
{
key: "proj-cmo",
- slug: "cmo",
- display_name: "CMO",
+ slug: "cmo-greg",
+ name: "Greg",
+ role_label: "CMO",
template_key: "cmo" as const,
},
{
key: "proj-google-ads",
- slug: "google-ads",
- display_name: "Google Ads",
+ slug: "google-ads-ana",
+ name: "Ana",
+ role_label: "Google Ads",
template_key: "google_ads" as const,
},
{
key: "proj-custom",
slug: "custom",
- display_name: "Custom Bot",
+ name: "Custom Bot",
},
];
@@ -58,13 +60,15 @@ afterEach(() => {
describe("AgentNav", () => {
it("renders one entry per agent linking to the tasks tab", () => {
render(<AgentNav projectSlug="proj" agents={agents} />);
- expect(screen.getByRole("link", { name: /CMO/i })).toHaveAttribute(
+ // The link's accessible name includes the personal name + role pill
+ // text, so /Greg|CMO/i / /Ana|Google Ads/i both match.
+ expect(screen.getByRole("link", { name: /Greg/i })).toHaveAttribute(
"href",
- "/proj/agents/cmo/tasks",
+ "/proj/agents/cmo-greg/tasks",
);
- expect(screen.getByRole("link", { name: /Google Ads/i })).toHaveAttribute(
+ expect(screen.getByRole("link", { name: /Ana/i })).toHaveAttribute(
"href",
- "/proj/agents/google-ads/tasks",
+ "/proj/agents/google-ads-ana/tasks",
);
expect(screen.getByRole("link", { name: /Custom Bot/i })).toHaveAttribute(
"href",
@@ -73,20 +77,20 @@ describe("AgentNav", () => {
});
it("marks the active agent when the pathname equals the agent base", () => {
- pathnameRef.current = "/proj/agents/cmo";
+ pathnameRef.current = "/proj/agents/cmo-greg";
render(<AgentNav projectSlug="proj" agents={agents} />);
const buttons = screen.getAllByTestId("sidebar-button");
- const cmoButton = buttons.find((b) => b.textContent?.includes("CMO"));
+ const cmoButton = buttons.find((b) => b.textContent?.includes("Greg"));
expect(cmoButton?.getAttribute("data-active")).toBe("true");
const customButton = buttons.find((b) => b.textContent?.includes("Custom Bot"));
expect(customButton?.getAttribute("data-active")).toBe("false");
});
it("marks the active agent when the pathname is nested under the agent base", () => {
- pathnameRef.current = "/proj/agents/google-ads/skills";
+ pathnameRef.current = "/proj/agents/google-ads-ana/skills";
render(<AgentNav projectSlug="proj" agents={agents} />);
const buttons = screen.getAllByTestId("sidebar-button");
- const target = buttons.find((b) => b.textContent?.includes("Google Ads"));
+ const target = buttons.find((b) => b.textContent?.includes("Ana"));
expect(target?.getAttribute("data-active")).toBe("true");
});
diff --git a/src/components/agent-nav.tsx b/src/components/agent-nav.tsx
index 158a40e2..9fc09b75 100644
--- a/src/components/agent-nav.tsx
+++ b/src/components/agent-nav.tsx
@@ -10,13 +10,19 @@ import {
} from "@/components/ui/sidebar";
import { RunningDot } from "@/components/running-dot";
import type { AgentTemplateKey } from "@/server/agent-templates";
+import { colorForRole } from "@/lib/agent-colors";
+import { cn } from "@/lib/utils";
import { projectHref } from "@/lib/project-href";
type AgentNavEntry = {
/** Stable key for React, e.g. the agent_id. */
key: string;
slug: string;
- display_name: string;
+ /** Personal name shown as the primary sidebar label (e.g. "Greg"). */
+ name: string;
+ /** Role label for the pill next to the name (e.g. "CMO"). Undefined for
+ * cloned/custom agents that aren't backed by a template. */
+ role_label?: string;
description?: string;
/** Filled for template agents; undefined for cloned/custom ones. */
template_key?: AgentTemplateKey;
@@ -55,12 +61,23 @@ export function AgentNav({ projectSlug, agents, inFlightCounts = {} }: Props) {
pathname === agentBase || pathname?.startsWith(`${agentBase}/`);
const Icon = a.template_key ? TEMPLATE_ICONS[a.template_key] ?? Bot : Bot;
const liveCount = inFlightCounts[a.key] ?? 0;
+ const rolePalette = a.template_key ? colorForRole(a.template_key) : null;
return (
<SidebarMenuItem key={a.key}>
<SidebarMenuButton asChild isActive={isActive}>
<Link href={href}>
<Icon />
- <span>{a.display_name}</span>
+ <span className="truncate">{a.name}</span>
+ {a.role_label && rolePalette && (
+ <span
+ className={cn(
+ "ml-1 rounded-sm border px-1 py-px text-[9px] font-medium uppercase tracking-wider leading-none",
+ rolePalette.chip,
+ )}
+ >
+ {a.role_label}
+ </span>
+ )}
{liveCount > 0 && (
<span className="ml-auto inline-flex items-center gap-1.5">
<RunningDot size="sm" aria-label={`${liveCount} running`} />
diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx
index f40df3e7..7bd1ac9d 100644
--- a/src/components/app-sidebar.tsx
+++ b/src/components/app-sidebar.tsx
@@ -27,6 +27,7 @@ import { listProjects } from "@/server/db/projects";
import { getActiveProject } from "@/server/active-project";
import { actionableApprovalCount } from "@/server/db/approvals";
import { listProjectAgents } from "@/server/agent-meta";
+import { TEMPLATES } from "@/server/agent-templates";
import { inFlightCountsByAgent } from "@/server/db/tasks";
import { projectHref } from "@/lib/project-href";
import { ProjectSwitcher } from "./project-switcher";
@@ -105,7 +106,10 @@ export async function AppSidebar() {
agents={agentEntries.map((a) => ({
key: a.agent_id,
slug: a.slug,
- display_name: a.display_name,
+ name: a.name,
+ role_label: a.template_key
+ ? TEMPLATES.find((t) => t.key === a.template_key)?.display_name
+ : undefined,
description: a.description,
template_key: a.template_key,
}))}
diff --git a/src/components/onboarding-flow.test.tsx b/src/components/onboarding-flow.test.tsx
index d01fa247..6d1f8075 100644
--- a/src/components/onboarding-flow.test.tsx
+++ b/src/components/onboarding-flow.test.tsx
@@ -238,11 +238,15 @@ describe("OnboardingFlow — ConnectStep", () => {
);
});
- it("pushes the CMO tasks URL when the user clicks Skip", () => {
+ it("pushes the project home when the user clicks Skip", () => {
setStep("connect", "acme");
render(<OnboardingFlow />);
fireEvent.click(screen.getByRole("button", { name: /Skip Google Ads/i }));
- expect(routerPush).toHaveBeenCalledWith("/acme/agents/cmo/tasks");
+ // After the agent-identity refactor, CMO URL slugs encode the user-
+ // chosen name (`cmo-<name>`), so we can't hardcode `/agents/cmo/tasks`
+ // here. Sending the user to the project home is correct — the sidebar
+ // surfaces the named CMO from there.
+ expect(routerPush).toHaveBeenCalledWith("/acme");
});
});
@@ -272,8 +276,8 @@ describe("OnboardingFlow — AccountStep", () => {
screen.getByRole("link", { name: /Retry from start/i }),
).toHaveAttribute("href", "/onboarding");
expect(
- screen.getByRole("link", { name: /Skip to chat/i }),
- ).toHaveAttribute("href", "/acme/agents/cmo/chat");
+ screen.getByRole("link", { name: /Skip to project/i }),
+ ).toHaveAttribute("href", "/acme");
});
it("renders the no-accounts state with reconnect link when the list is empty", async () => {
@@ -305,6 +309,7 @@ describe("OnboardingFlow — AccountStep", () => {
ok: true,
project: {},
task_display_id: "AUDIT-1",
+ cmo_agent_slug: "cmo-greg",
});
setStep("account", "acme");
render(<OnboardingFlow />);
@@ -313,7 +318,7 @@ describe("OnboardingFlow — AccountStep", () => {
);
await waitFor(() =>
expect(routerReplace).toHaveBeenCalledWith(
- "/acme/agents/cmo/tasks?task=AUDIT-1",
+ "/acme/agents/cmo-greg/tasks?task=AUDIT-1",
),
);
});
@@ -370,6 +375,7 @@ describe("OnboardingFlow — AccountStep", () => {
ok: true,
project: {},
task_display_id: "TASK-9",
+ cmo_agent_slug: "cmo-greg",
});
setStep("account", "acme");
render(<OnboardingFlow />);
@@ -382,7 +388,7 @@ describe("OnboardingFlow — AccountStep", () => {
);
await waitFor(() =>
expect(routerReplace).toHaveBeenCalledWith(
- "/acme/agents/cmo/tasks?task=TASK-9",
+ "/acme/agents/cmo-greg/tasks?task=TASK-9",
),
);
});
diff --git a/src/components/onboarding-flow.tsx b/src/components/onboarding-flow.tsx
index 6bb10f1b..b9c8ba77 100644
--- a/src/components/onboarding-flow.tsx
+++ b/src/components/onboarding-flow.tsx
@@ -158,7 +158,7 @@ function NameStep({ onCreated }: { onCreated: (slug: string) => void }) {
<CardContent>
<form action={formAction} className="space-y-4">
<div className="space-y-2">
- <Label htmlFor="display_name">Name</Label>
+ <Label htmlFor="display_name">Project name</Label>
<Input
id="display_name"
name="display_name"
@@ -169,6 +169,54 @@ function NameStep({ onCreated }: { onCreated: (slug: string) => void }) {
disabled={isPending}
/>
</div>
+
+ <div className="rounded-md border border-dashed bg-muted/30 p-3 space-y-3">
+ <div className="space-y-1">
+ <Label className="text-xs uppercase tracking-wide text-muted-foreground">
+ Your team
+ </Label>
+ <p className="text-xs text-muted-foreground">
+ Name your CMO and Google Ads specialist. Pick something
+ memorable — these stay fixed for the life of the project.
+ </p>
+ </div>
+ <div className="grid grid-cols-2 gap-3">
+ <div className="space-y-1.5">
+ <Label
+ htmlFor="agent_name_cmo"
+ className="text-xs font-medium text-foreground"
+ >
+ CMO
+ </Label>
+ <Input
+ id="agent_name_cmo"
+ name="agent_name_cmo"
+ defaultValue="Greg"
+ placeholder="Greg"
+ maxLength={32}
+ disabled={isPending}
+ required
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label
+ htmlFor="agent_name_google_ads"
+ className="text-xs font-medium text-foreground"
+ >
+ Google Ads
+ </Label>
+ <Input
+ id="agent_name_google_ads"
+ name="agent_name_google_ads"
+ defaultValue="Ana"
+ placeholder="Ana"
+ maxLength={32}
+ disabled={isPending}
+ required
+ />
+ </div>
+ </div>
+ </div>
<div className="space-y-2">
<Label htmlFor="website_url">
Website URL{" "}
@@ -223,7 +271,10 @@ function ConnectStep({ slug }: { slug: string }) {
const router = useRouter();
const [busy, setBusy] = useState(false);
const connectionsHref = projectHref(slug, "/connections");
- const cmoTasksHref = projectHref(slug, "/agents/cmo/tasks");
+ // Project home — sidebar leads the user to the CMO from there.
+ // (We can't hardcode /agents/<role-name>/tasks because the URL slug is
+ // user-customizable as <role>-<name>.)
+ const projectHome = projectHref(slug, "");
async function onConnect() {
setBusy(true);
@@ -249,7 +300,7 @@ function ConnectStep({ slug }: { slug: string }) {
// Without Google Ads connected, there's nothing for the CMO to audit
// yet — drop the user on the CMO's task tab so they can see "no tasks
// assigned, connect Google Ads to start".
- router.push(cmoTasksHref);
+ router.push(projectHome);
}
return (
@@ -356,7 +407,7 @@ function AccountStep({ slug }: { slug: string }) {
router.replace(
projectHref(
slug,
- `/agents/cmo/tasks?task=${encodeURIComponent(result.task_display_id)}`,
+ `/agents/${result.cmo_agent_slug}/tasks?task=${encodeURIComponent(result.task_display_id)}`,
),
);
})();
@@ -374,7 +425,7 @@ function AccountStep({ slug }: { slug: string }) {
router.replace(
projectHref(
slug,
- `/agents/cmo/tasks?task=${encodeURIComponent(result.task_display_id)}`,
+ `/agents/${result.cmo_agent_slug}/tasks?task=${encodeURIComponent(result.task_display_id)}`,
),
);
} catch (err) {
@@ -412,7 +463,7 @@ function AccountStep({ slug }: { slug: string }) {
<Link href="/onboarding">Retry from start</Link>
</Button>
<Button variant="outline" asChild>
- <Link href={projectHref(slug, "/agents/cmo/chat")}>Skip to chat</Link>
+ <Link href={projectHref(slug, "")}>Skip to project</Link>
</Button>
</div>
</CardContent>
@@ -441,7 +492,7 @@ function AccountStep({ slug }: { slug: string }) {
</Link>
</Button>
<Button variant="outline" asChild>
- <Link href={projectHref(slug, "/agents/cmo/chat")}>Skip to chat</Link>
+ <Link href={projectHref(slug, "")}>Skip to project</Link>
</Button>
</div>
</CardContent>
diff --git a/src/components/tasks-board.tsx b/src/components/tasks-board.tsx
index 808e1967..4c9690a1 100644
--- a/src/components/tasks-board.tsx
+++ b/src/components/tasks-board.tsx
@@ -248,7 +248,7 @@ export function TasksBoard({ projectSlug, tasks, agents }: Props) {
>
{active && <Check className="size-2.5" />}
</span>
- <span className="truncate">{a.display_name}</span>
+ <span className="truncate">{a.name}</span>
<span className="ml-auto font-mono text-[10px] text-muted-foreground">
{countForAgent(filteredTasks, tasks, a.agent_id)}
</span>
@@ -496,7 +496,7 @@ function KanbanView({
key={t.id}
task={t}
projectSlug={projectSlug}
- assignee={agentById.get(t.agent_id)?.display_name ?? t.agent_id}
+ assignee={agentById.get(t.agent_id)?.name ?? t.agent_id}
/>
))
)}
@@ -630,7 +630,7 @@ function ListView({
)}
</span>
<span className="truncate text-muted-foreground">
- {agentById.get(t.agent_id)?.display_name ?? t.agent_id}
+ {agentById.get(t.agent_id)?.name ?? t.agent_id}
</span>
<span className="truncate text-right text-[11px] text-muted-foreground">
{relativeTime(t.updated_at)}
@@ -649,7 +649,7 @@ function agentLabel(
agentById: Map<string, ProjectAgentEntry>,
agentId: string,
): string {
- return agentById.get(agentId)?.display_name ?? agentId;
+ return agentById.get(agentId)?.name ?? agentId;
}
function countForAgent(
diff --git a/src/lib/agent-colors.ts b/src/lib/agent-colors.ts
index 87588b78..049da004 100644
--- a/src/lib/agent-colors.ts
+++ b/src/lib/agent-colors.ts
@@ -90,15 +90,41 @@ function hashSlug(slug: string): number {
return Math.abs(h);
}
+/**
+ * Color for a template ROLE (cmo, google_ads, seo). Canonical lookup for
+ * the sidebar role pill + cron calendar swatches — both should agree on
+ * "CMO is blue" regardless of any personal-name suffix in the URL slug.
+ * Stable across the lifetime of the project.
+ */
+export function colorForRole(role: AgentTemplateKey): AgentColor {
+ return PALETTE[role];
+}
+
/**
* Resolve a color for an agent slug as it appears in our cron view.
- * Templates (cmo / google-ads / seo) get their reserved hue. Anything else
- * gets a stable color from the extras palette via slug hash — never the
- * zinc fallback, which reads as "disabled".
+ * Templates (cmo / google-ads / seo, with or without a `-<name>` suffix)
+ * get their reserved hue. Anything else gets a stable color from the
+ * extras palette via slug hash — never the zinc fallback, which reads
+ * as "disabled".
+ *
+ * Accepts both legacy bare slugs (`cmo`) and the new role-plus-name
+ * shape (`cmo-greg`) — the role prefix is matched against the palette
+ * before falling through to the hash bucket.
*/
export function colorForAgentSlug(slug: string): AgentColor {
- const normalized = slug.replace(/-/g, "_") as AgentTemplateKey;
- const fromTemplate = PALETTE[normalized];
- if (fromTemplate) return fromTemplate;
+ // Try a direct lookup first (handles legacy "cmo" / "seo" slugs).
+ const direct = PALETTE[slug.replace(/-/g, "_") as AgentTemplateKey];
+ if (direct) return direct;
+ // New shape: <role>-<name>. Walk the role keys longest-first so
+ // "google_ads" matches before "cmo" wouldn't accidentally match
+ // "cmo-anything".
+ const roleKeys = Object.keys(PALETTE) as AgentTemplateKey[];
+ const sorted = roleKeys.slice().sort((a, b) => b.length - a.length);
+ for (const role of sorted) {
+ const rolePrefix = role.replace(/_/g, "-");
+ if (slug === rolePrefix || slug.startsWith(`${rolePrefix}-`)) {
+ return PALETTE[role];
+ }
+ }
return EXTRA_PALETTE[hashSlug(slug) % EXTRA_PALETTE.length]!;
}
diff --git a/src/server/actions/agents.test.ts b/src/server/actions/agents.test.ts
index c908790c..8b185523 100644
--- a/src/server/actions/agents.test.ts
+++ b/src/server/actions/agents.test.ts
@@ -119,7 +119,7 @@ describe("listOpenClawAgentsAction", () => {
it("merges openclaw list with project agent ids and marks membership", async () => {
getActiveProjectMock.mockResolvedValueOnce(project());
listProjectAgentsMock.mockResolvedValueOnce([
- { agent_id: "acme-cmo", slug: "cmo", display_name: "CMO", is_template_default: true },
+ { agent_id: "acme-cmo", slug: "cmo-greg", name: "Greg", template_key: "cmo", is_template_default: true },
]);
listAllAgentsMock.mockResolvedValueOnce({
agents: [
@@ -180,7 +180,7 @@ describe("listProjectAgentsAction", () => {
it("returns project agents on happy path", async () => {
getActiveProjectMock.mockResolvedValueOnce(project());
listProjectAgentsMock.mockResolvedValueOnce([
- { agent_id: "acme-cmo", slug: "cmo", display_name: "CMO", is_template_default: true },
+ { agent_id: "acme-cmo", slug: "cmo-greg", name: "Greg", template_key: "cmo", is_template_default: true },
]);
const r = await listProjectAgentsAction();
expect(r.ok).toBe(true);
@@ -371,193 +371,18 @@ describe("removeCronsAction", () => {
});
describe("renameAgentAction", () => {
- it("rejects when no active project", async () => {
- getActiveProjectMock.mockResolvedValueOnce(null);
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: "Bar",
- });
- expect(r.ok).toBe(false);
- });
-
- it("rejects when new display name is blank", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: " ",
- });
- expect(r.ok).toBe(false);
- if (r.ok) return;
- expect(r.error).toMatch(/Name cannot be empty/);
- });
-
- it("rejects when slugify fails (e.g. all symbols)", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: "@@@",
- });
- expect(r.ok).toBe(false);
- if (r.ok) return;
- expect(r.error).toMatch(/Invalid name/);
- });
-
- it("rejects when meta sidecar is missing", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- readAgentMetaMock.mockReturnValueOnce(null);
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: "Bar",
- });
- expect(r.ok).toBe(false);
- if (r.ok) return;
- expect(r.error).toMatch(/no meta on disk/);
- });
-
- it("rejects when meta says agent belongs to a different project", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project("acme"));
- readAgentMetaMock.mockReturnValueOnce({
- agent_id: "other-foo",
- project_slug: "other",
- slug: "foo",
- display_name: "Foo",
- created_at: "now",
- });
- const r = await renameAgentAction({
- agent_id: "other-foo",
- new_display_name: "Bar",
- });
- expect(r.ok).toBe(false);
- if (r.ok) return;
- expect(r.error).toMatch(/different project/);
- });
-
- it("display-name-only change returns full_rename:false and rewrites meta", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- readAgentMetaMock.mockReturnValueOnce({
- agent_id: "acme-foo",
- project_slug: "acme",
- slug: "foo",
- display_name: "Foo",
- created_at: "now",
- });
- // "FOO!" slugifies back to "foo" so the slug is unchanged → display-only.
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: "FOO!",
- });
- expect(r.ok).toBe(true);
- if (!r.ok) return;
- expect(r.data.full_rename).toBe(false);
- expect(r.data.display_name).toBe("FOO!");
- expect(writeAgentMetaMock).toHaveBeenCalled();
- expect(revalidatePathMock).toHaveBeenCalled();
- });
-
- it("no-op rename (same slug AND same display name) returns full_rename:false without writing meta", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- readAgentMetaMock.mockReturnValueOnce({
- agent_id: "acme-foo",
- project_slug: "acme",
- slug: "foo",
- display_name: "Foo",
- created_at: "now",
- });
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: "Foo",
- });
- expect(r.ok).toBe(true);
- if (!r.ok) return;
- expect(r.data.full_rename).toBe(false);
- expect(writeAgentMetaMock).not.toHaveBeenCalled();
- });
-
- it("full rename rejected when destination slug already exists", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- readAgentMetaMock.mockReturnValueOnce({
- agent_id: "acme-foo",
- project_slug: "acme",
- slug: "foo",
- display_name: "Foo",
- created_at: "now",
- });
- agentExistsInProjectMock.mockReturnValueOnce(true);
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: "Bar",
- });
- expect(r.ok).toBe(false);
- if (r.ok) return;
- expect(r.error).toMatch(/already exists/);
- });
-
- it("full rename calls relocateAgent (clone + delete) and returns new ids", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- readAgentMetaMock.mockReturnValueOnce({
- agent_id: "acme-foo",
- project_slug: "acme",
- slug: "foo",
- display_name: "Foo",
- template_key: "google_ads",
- created_at: "2024-01-01T00:00:00Z",
- });
- agentExistsInProjectMock.mockReturnValueOnce(false);
- // relocateAgent's call to cloneAgent
- cloneAgentMock.mockResolvedValueOnce({
- new_agent_id: "acme-bar",
- new_slug: "bar",
- files_copied: 0,
- sessions_copied: 0,
- source_crons: [],
- new_cron_ids: [],
- });
- // relocateAgent calls writeAgentMeta + cascadeDeleteAgent (which calls deleteAgent, listCronsForProject, rm, etc.)
- writeAgentMetaMock.mockResolvedValue(undefined);
- listCronsForProjectMock.mockResolvedValue({ groups: [] });
- deleteAgentMock.mockResolvedValue(undefined);
- existsSyncMock.mockReturnValue(false);
-
- const r = await renameAgentAction({
- agent_id: "acme-foo",
- new_display_name: "Bar",
- });
- expect(r.ok).toBe(true);
- if (!r.ok) return;
- expect(r.data.full_rename).toBe(true);
- expect(r.data.agent_id).toBe("acme-bar");
- expect(r.data.slug).toBe("bar");
- expect(cloneAgentMock).toHaveBeenCalledWith(
- expect.objectContaining({
- source_agent_id: "acme-foo",
- project_slug: "acme",
- new_slug: "bar",
- display_name: "Bar",
- slug_is_canonical: true,
- }),
- );
- expect(revalidatePathMock).toHaveBeenCalledWith("/", "layout");
- });
-
- it("full rename surfaces relocate failures with a 'Rename failed' message", async () => {
- getActiveProjectMock.mockResolvedValueOnce(project());
- readAgentMetaMock.mockReturnValueOnce({
- agent_id: "acme-foo",
- project_slug: "acme",
- slug: "foo",
- display_name: "Foo",
- created_at: "now",
- });
- agentExistsInProjectMock.mockReturnValueOnce(false);
- cloneAgentMock.mockRejectedValueOnce(new Error("clone failed"));
+ // Agents are immutable per the identity refactor — the name set at
+ // onboarding (or clone time) is permanent. The action exists only so
+ // import sites keep typechecking; every call must refuse with a
+ // clear, actionable error message.
+ it("refuses with an immutability error", async () => {
const r = await renameAgentAction({
agent_id: "acme-foo",
new_display_name: "Bar",
});
expect(r.ok).toBe(false);
if (r.ok) return;
- expect(r.error).toMatch(/Rename failed/);
- expect(r.error).toMatch(/clone failed/);
+ expect(r.error).toMatch(/immutable/i);
});
});
@@ -587,12 +412,14 @@ describe("relocateAgent", () => {
preserve_created_at: "2024-01-01T00:00:00Z",
});
expect(r).toEqual({ new_agent_id: "newproj-foo", new_slug: "foo" });
+ // Template agents don't persist `slug` on the sidecar (it's computed
+ // from template_key + name). The relocate writer is expected to omit
+ // it when preserve_template_key is set.
expect(writeAgentMetaMock).toHaveBeenCalledWith(
expect.objectContaining({
agent_id: "newproj-foo",
project_slug: "newproj",
- slug: "foo",
- display_name: "Foo",
+ name: "Foo",
template_key: "google_ads",
source_agent_id: "src-id",
created_at: "2024-01-01T00:00:00Z",
@@ -677,7 +504,7 @@ describe("getAgentDeletionSummaryAction", () => {
agent_id: "acme-foo",
project_slug: "acme",
slug: "foo",
- display_name: "Foo Agent",
+ name: "Foo Agent",
template_key: "google_ads",
source_agent_id: "src",
created_at: "now",
diff --git a/src/server/actions/agents.ts b/src/server/actions/agents.ts
index 2b32489a..a0097968 100644
--- a/src/server/actions/agents.ts
+++ b/src/server/actions/agents.ts
@@ -99,7 +99,7 @@ export async function createAgentAction(
agent_id: agentId,
project_slug: project.slug,
slug: slug.slug,
- display_name: input.display_name.trim(),
+ name: input.display_name.trim(),
created_at: new Date().toISOString(),
});
} catch (err) {
@@ -213,11 +213,13 @@ export async function relocateAgent(
// Overwrite meta to drop the clone-provenance fields that cloneAgent set,
// and preserve the caller-supplied identity (template_key, source, created).
+ // Template agents don't persist `slug` (it's computed); clones do.
+ const isTemplateAgent = !!input.preserve_template_key;
await writeAgentMeta({
agent_id: cloneResult.new_agent_id,
project_slug: input.new_project_slug,
- slug: cloneResult.new_slug,
- display_name: input.new_display_name,
+ ...(isTemplateAgent ? {} : { slug: cloneResult.new_slug }),
+ name: input.new_display_name,
...(input.preserve_template_key ? { template_key: input.preserve_template_key } : {}),
...(input.preserve_source_agent_id
? { source_agent_id: input.preserve_source_agent_id }
@@ -256,100 +258,23 @@ export type RenameAgentData = {
};
/**
- * Rename an agent. OpenClaw treats the agent_id as immutable, so a "real"
- * rename — where the URL slug, cron names, workspace dir, and sessions dir all
- * pick up the new name — has to be done by self-cloning into a new agent_id
- * and deleting the old one.
+ * Per the agent-identity refactor, agents are IMMUTABLE after creation:
+ * the name set during onboarding (or clone time) is permanent and the URL
+ * slug is computed from it. This action is preserved so internal callers
+ * (project-rename cascade via relocateAgent) keep working, but the
+ * user-facing rename UI has been removed.
*
- * When the new display name slugifies to the same value as the current slug,
- * we short-circuit and just update our meta sidecar. Cheap, no data motion.
+ * For template agents the action refuses — template names are part of the
+ * sidebar/role-pill identity the user named at onboarding. For cloned/
+ * custom agents the action also refuses; they were already named at clone
+ * time.
*/
export async function renameAgentAction(
- input: RenameAgentInput,
+ _input: RenameAgentInput,
): Promise<ActionResult<RenameAgentData>> {
- const project = await getActiveProject();
- if (!project) return { ok: false, error: "No active project." };
-
- const newName = input.new_display_name.trim();
- if (!newName) return { ok: false, error: "Name cannot be empty." };
-
- const newSlugResult = slugify(newName);
- if (!newSlugResult.ok) {
- return { ok: false, error: `Invalid name: ${newSlugResult.reason}` };
- }
- const newSlug = newSlugResult.slug;
-
- const existingMeta = readAgentMeta(input.agent_id);
- if (!existingMeta) {
- return { ok: false, error: `Agent '${input.agent_id}' has no meta on disk.` };
- }
- if (existingMeta.project_slug !== project.slug) {
- return { ok: false, error: "Agent belongs to a different project." };
- }
-
- // Display-name-only change → just rewrite the meta sidecar.
- if (newSlug === existingMeta.slug) {
- if (newName === existingMeta.display_name) {
- return {
- ok: true,
- data: {
- agent_id: input.agent_id,
- slug: existingMeta.slug,
- display_name: existingMeta.display_name,
- full_rename: false,
- },
- };
- }
- await writeAgentMeta({ ...existingMeta, display_name: newName });
- revalidatePath("/", "layout");
- return {
- ok: true,
- data: {
- agent_id: input.agent_id,
- slug: existingMeta.slug,
- display_name: newName,
- full_rename: false,
- },
- };
- }
-
- // Real rename — different slug. Refuse if the new slug is taken.
- if (agentExistsInProject(project.slug, newSlug)) {
- return {
- ok: false,
- error: `An agent named "${newSlug}" already exists in this project.`,
- };
- }
-
- let relocated: RelocateAgentResult;
- try {
- relocated = await relocateAgent({
- old_agent_id: input.agent_id,
- source_project_slug: project.slug,
- new_project_slug: project.slug,
- new_slug: newSlug,
- new_display_name: newName,
- preserve_template_key: existingMeta.template_key,
- preserve_created_at: existingMeta.created_at,
- // Renames intentionally drop the clone provenance — the new agent is
- // not a clone of the old one, it IS the old one with a new identity.
- });
- } catch (err) {
- return {
- ok: false,
- error: `Rename failed: ${err instanceof Error ? err.message : String(err)}`,
- };
- }
-
- revalidatePath("/", "layout");
return {
- ok: true,
- data: {
- agent_id: relocated.new_agent_id,
- slug: relocated.new_slug,
- display_name: newName,
- full_rename: true,
- },
+ ok: false,
+ error: "Agents are immutable once created. To use a different name, clone the agent and delete the original.",
};
}
@@ -398,7 +323,7 @@ export async function getAgentDeletionSummaryAction(
ok: true,
data: {
agent_id,
- display_name: meta?.display_name ?? agent_id,
+ display_name: meta?.name ?? agent_id,
exists_in_openclaw: existsInOpenclaw,
threads,
crons,
diff --git a/src/server/actions/projects.ts b/src/server/actions/projects.ts
index 7ba61554..f33012ac 100644
--- a/src/server/actions/projects.ts
+++ b/src/server/actions/projects.ts
@@ -98,6 +98,19 @@ export async function createProjectForOnboardingAction(
const website_url = String(formData.get("website_url") ?? "").trim() || null;
const codebase_path = String(formData.get("codebase_path") ?? "").trim() || null;
+ // Personal names for the team. Pre-filled with template defaults on the
+ // client; we still read off the form rather than baking the defaults
+ // here so the user's choice is the single source of truth. Blank
+ // values fall back to template.default_name inside ensureProjectAgents.
+ const agent_name_cmo = String(formData.get("agent_name_cmo") ?? "").trim();
+ const agent_name_google_ads = String(
+ formData.get("agent_name_google_ads") ?? "",
+ ).trim();
+ const agent_names = {
+ ...(agent_name_cmo ? { cmo: agent_name_cmo } : {}),
+ ...(agent_name_google_ads ? { google_ads: agent_name_google_ads } : {}),
+ } as Partial<Record<"cmo" | "google_ads" | "seo", string>>;
+
const result = createProject({ display_name, website_url, codebase_path });
if (!result.ok) return { ok: false, error: result.reason };
@@ -105,6 +118,7 @@ export async function createProjectForOnboardingAction(
const provisionPromise = ensureProjectAgents(
result.project.slug,
DEFAULT_ONBOARDING_TEMPLATE_KEYS,
+ agent_names,
);
startProvisioning(result.project.slug, provisionPromise);
// After provisioning resolves, mint + start the CMO's project-onboarding
@@ -327,7 +341,7 @@ export async function renameProjectFullAction(
source_project_slug: current.slug,
new_project_slug: newSlug,
new_slug: a.slug,
- new_display_name: a.display_name,
+ new_display_name: a.name,
preserve_template_key: a.template_key,
preserve_source_agent_id: meta?.source_agent_id,
preserve_created_at: meta?.created_at,
diff --git a/src/server/agent-meta.test.ts b/src/server/agent-meta.test.ts
index f8d8517c..11a665ac 100644
--- a/src/server/agent-meta.test.ts
+++ b/src/server/agent-meta.test.ts
@@ -74,18 +74,21 @@ vi.mock("./agent-templates", () => ({
{
key: "cmo",
display_name: "CMO",
+ default_name: "Greg",
description: "Chief Marketing Officer.",
default_onboarding: true,
},
{
key: "google_ads",
display_name: "Google Ads",
+ default_name: "Ana",
description: "Google Ads specialist.",
default_onboarding: true,
},
{
key: "seo",
display_name: "SEO",
+ default_name: "Sam",
description: "SEO specialist.",
// Opt-in template: not pre-seeded, only appears via meta sidecar.
default_onboarding: false,
@@ -94,6 +97,13 @@ vi.mock("./agent-templates", () => ({
agentNameFor: (slug: string, key: string) =>
`${slug}-${key.replace(/_/g, "-")}`,
urlSlugForTemplate: (key: string) => key.replace(/_/g, "-"),
+ agentUrlSlug: (key: string, n: string) =>
+ `${key.replace(/_/g, "-")}-${n
+ .toLowerCase()
+ .trim()
+ .replace(/[^a-z0-9]+/g, "-")
+ .replace(/^-+|-+$/g, "")
+ .slice(0, 32)}`,
}));
import {
@@ -117,7 +127,7 @@ function makeMeta(overrides: Partial<AgentMeta> = {}): AgentMeta {
agent_id: "acme-cmo",
project_slug: "acme",
slug: "cmo",
- display_name: "CMO",
+ name: "CMO",
template_key: "cmo",
created_at: "2026-01-01T00:00:00Z",
...overrides,
@@ -181,7 +191,7 @@ describe("writeAgentMeta + readAgentMeta", () => {
const meta = makeMeta({
agent_id: "acme-supa-clone",
slug: "supa-clone",
- display_name: "Supabase Clone",
+ name: "Supabase Clone",
source_agent_id: "acme-cmo",
});
await writeAgentMeta(meta);
@@ -217,7 +227,7 @@ describe("listProjectAgents", () => {
makeMeta({
agent_id: "acme-seo",
slug: "seo",
- display_name: "SEO",
+ name: "SEO",
template_key: "seo",
}),
);
@@ -234,7 +244,7 @@ describe("listProjectAgents", () => {
const r = await listProjectAgents("acme");
const cmo = r.find((e) => e.agent_id === "acme-cmo");
expect(cmo?.is_template_default).toBe(false);
- expect(cmo?.display_name).toBe("CMO");
+ expect(cmo?.name).toBe("CMO");
});
it("includes a cloned/custom agent with its source_agent_id surfaced", async () => {
@@ -242,7 +252,7 @@ describe("listProjectAgents", () => {
makeMeta({
agent_id: "acme-supa-clone",
slug: "supa-clone",
- display_name: "Supa Clone",
+ name: "Supa Clone",
template_key: undefined,
source_agent_id: "acme-cmo",
}),
@@ -252,7 +262,7 @@ describe("listProjectAgents", () => {
expect(clone).toMatchObject({
agent_id: "acme-supa-clone",
slug: "supa-clone",
- display_name: "Supa Clone",
+ name: "Supa Clone",
source_agent_id: "acme-cmo",
is_template_default: false,
});
@@ -263,7 +273,7 @@ describe("listProjectAgents", () => {
makeMeta({
agent_id: "acme-z-tool",
slug: "z-tool",
- display_name: "Z Tool",
+ name: "Z Tool",
template_key: undefined,
}),
);
@@ -271,16 +281,17 @@ describe("listProjectAgents", () => {
makeMeta({
agent_id: "acme-a-tool",
slug: "a-tool",
- display_name: "A Tool",
+ name: "A Tool",
template_key: undefined,
}),
);
const r = await listProjectAgents("acme");
// Onboarding-default templates first in declared order (SEO is opt-in
- // and not seeded), then custom alphabetically by slug.
+ // and not seeded), then custom alphabetically by slug. Template slugs
+ // are computed `<role>-<slugified-name>` from the default_name.
expect(r.map((e) => e.slug)).toEqual([
- "cmo",
- "google-ads",
+ "cmo-greg",
+ "google-ads-ana",
"a-tool",
"z-tool",
]);
@@ -292,7 +303,7 @@ describe("listProjectAgents", () => {
agent_id: "globex-cmo",
project_slug: "globex",
slug: "cmo",
- display_name: "Globex CMO",
+ name: "Globex CMO",
}),
);
const r = await listProjectAgents("acme");
@@ -313,21 +324,23 @@ describe("listProjectAgents", () => {
});
describe("resolveAgentBySlug", () => {
- it("resolves a template URL slug to its agent_id", async () => {
+ it("resolves a template URL slug (role-name shape) to its agent_id", async () => {
fsState.missingDirs.add("/data/agents");
- const r = await resolveAgentBySlug("acme", "google-ads");
+ // Template agents are pre-seeded with their default_name → the URL
+ // slug is `<role>-<default_name>` for the placeholder entry.
+ const r = await resolveAgentBySlug("acme", "google-ads-ana");
expect(r).toEqual({
agent_id: "acme-google-ads",
- display_name: "Google Ads",
- slug: "google-ads",
+ name: "Ana",
+ slug: "google-ads-ana",
template_key: "google_ads",
});
});
- it("resolves the bare 'cmo' slug", async () => {
+ it("returns null for the bare role slug (the new shape is role-name)", async () => {
fsState.missingDirs.add("/data/agents");
const r = await resolveAgentBySlug("acme", "cmo");
- expect(r?.agent_id).toBe("acme-cmo");
+ expect(r).toBeNull();
});
it("resolves a custom (non-template) agent by its meta slug", async () => {
@@ -335,14 +348,14 @@ describe("resolveAgentBySlug", () => {
makeMeta({
agent_id: "acme-supa-clone",
slug: "supa-clone",
- display_name: "Supa Clone",
+ name: "Supa Clone",
template_key: undefined,
}),
);
const r = await resolveAgentBySlug("acme", "supa-clone");
expect(r).toEqual({
agent_id: "acme-supa-clone",
- display_name: "Supa Clone",
+ name: "Supa Clone",
slug: "supa-clone",
template_key: undefined,
});
diff --git a/src/server/agent-meta.ts b/src/server/agent-meta.ts
index ef9b38de..3dfb0037 100644
--- a/src/server/agent-meta.ts
+++ b/src/server/agent-meta.ts
@@ -5,6 +5,7 @@ import { join } from "node:path";
import {
TEMPLATES,
agentNameFor,
+ agentUrlSlug,
urlSlugForTemplate,
type AgentTemplateKey,
} from "./agent-templates";
@@ -21,10 +22,20 @@ export type AgentMeta = {
agent_id: string;
/** Project slug this agent belongs to. */
project_slug: string;
- /** URL-friendly slug (post-project prefix), e.g. `cmo`, `supa-clone`. */
- slug: string;
- /** Display name shown in sidebar / chat headers. */
- display_name: string;
+ /**
+ * Personal name the user assigned (e.g. "Greg", "Ana"). IMMUTABLE —
+ * set once at agent-create time. The URL slug is computed from this
+ * + template_key (see agentUrlSlug); the sidebar shows this as the
+ * primary label next to a role pill.
+ */
+ name: string;
+ /**
+ * URL slug — stored ONLY for non-template (cloned/custom) agents,
+ * where there's no role+name pair to compute from. Template agents
+ * always compute their slug from template_key + name and never write
+ * this field.
+ */
+ slug?: string;
/** If from one of our bootstrap templates, which one. */
template_key?: AgentTemplateKey;
/** When cloned, the source agentId. */
@@ -58,10 +69,16 @@ export function readAgentMeta(agentId: string): AgentMeta | null {
export type ProjectAgentEntry = {
agent_id: string;
+ /**
+ * URL slug. For template agents: `<role>-<slugified-name>` computed
+ * from template_key + name. For cloned/custom: the stored slug.
+ */
slug: string;
- display_name: string;
- description?: string;
+ /** Personal name (e.g. "Greg"). */
+ name: string;
+ /** Role identifier (template key). Undefined for cloned/custom agents. */
template_key?: AgentTemplateKey;
+ description?: string;
source_agent_id?: string;
is_template_default: boolean;
};
@@ -84,10 +101,14 @@ export async function listProjectAgents(project_slug: string): Promise<ProjectAg
for (const t of TEMPLATES) {
if (!t.default_onboarding) continue;
const agentId = agentNameFor(project_slug, t.key);
+ // Placeholder entry shown before a meta sidecar exists on disk.
+ // Uses the template's default_name as the personal name so the
+ // sidebar reads sensibly even during the brief window between
+ // project-create and ensureProjectAgents finishing.
result.set(agentId, {
agent_id: agentId,
- slug: urlSlugForTemplate(t.key),
- display_name: t.display_name,
+ slug: agentUrlSlug(t.key, t.default_name),
+ name: t.default_name,
description: t.description,
template_key: t.key,
is_template_default: true,
@@ -109,10 +130,19 @@ export async function listProjectAgents(project_slug: string): Promise<ProjectAg
if (!entry.startsWith(prefix)) continue;
const meta = readAgentMeta(entry);
if (!meta) continue;
+ // Template agents: slug is COMPUTED from template_key + name; we
+ // ignore any stored slug (templates don't write one).
+ // Cloned/custom: slug came from the sidecar (clone-agent writes it).
+ const template = meta.template_key
+ ? TEMPLATES.find((t) => t.key === meta.template_key)
+ : undefined;
+ const slug = template
+ ? agentUrlSlug(template.key, meta.name)
+ : meta.slug ?? slugifyForCustom(meta.name);
result.set(meta.agent_id, {
agent_id: meta.agent_id,
- slug: meta.slug,
- display_name: meta.display_name,
+ slug,
+ name: meta.name,
template_key: meta.template_key,
source_agent_id: meta.source_agent_id,
is_template_default: false,
@@ -134,9 +164,25 @@ export function workspaceDirFor(agentId: string): string {
return join(notfairDataDir(), "agents", agentId);
}
+/**
+ * Fallback slug generator for cloned/custom agents (no template_key) whose
+ * sidecar lacks an explicit `slug` field. Same shape as slugifyName but
+ * lives here to avoid the agent-templates dependency for non-template
+ * code paths.
+ */
+function slugifyForCustom(s: string): string {
+ return s
+ .toLowerCase()
+ .trim()
+ .replace(/[^a-z0-9]+/g, "-")
+ .replace(/^-+|-+$/g, "")
+ .slice(0, 32);
+}
+
export type ResolvedAgent = {
agent_id: string;
- display_name: string;
+ /** Personal name (e.g. "Greg"). */
+ name: string;
slug: string;
template_key?: AgentTemplateKey;
};
@@ -155,7 +201,7 @@ export async function resolveAgentBySlug(
if (!hit) return null;
return {
agent_id: hit.agent_id,
- display_name: hit.display_name,
+ name: hit.name,
slug: hit.slug,
template_key: hit.template_key,
};
diff --git a/src/server/agent-templates.ts b/src/server/agent-templates.ts
index 66029278..e8f9419e 100644
--- a/src/server/agent-templates.ts
+++ b/src/server/agent-templates.ts
@@ -2,7 +2,7 @@ import { mkdir, writeFile } from "node:fs/promises";
import { homedir } from "node:os";
import { join } from "node:path";
import { openclaw } from "@/server/openclaw/cli";
-import { writeAgentMeta } from "@/server/agent-meta";
+import { readAgentMeta, writeAgentMeta } from "@/server/agent-meta";
import {
cleanupLegacyOrchestrationRows,
ensureOrchestrationMcpInstalled,
@@ -99,7 +99,21 @@ Style:
export type AgentTemplate = {
key: "cmo" | "google_ads" | "seo";
+ /**
+ * Label for the ROLE this template represents (e.g. "CMO", "Google
+ * Ads"). Used in the sidebar role pill + anywhere the UI says
+ * "what kind of agent is this". Distinct from the agent's PERSONAL
+ * name (e.g. "Greg"); the personal name lives on AgentMeta.
+ */
display_name: string;
+ /**
+ * Suggested personal name pre-filled into the onboarding form when
+ * the user provisions this template. Short + memorable so the
+ * sidebar reads like a team of named colleagues rather than a roster
+ * of job titles. Users can override during onboarding; the choice
+ * becomes immutable once the agent is created.
+ */
+ default_name: string;
description: string;
capabilities: string[];
model: string;
@@ -144,6 +158,7 @@ export const TEMPLATES: AgentTemplate[] = [
{
key: "cmo",
display_name: "CMO",
+ default_name: "Greg",
description: "Chief Marketing Officer. Owns strategy and orchestrates the specialist agents.",
capabilities: [
"Talk through marketing strategy and prioritization",
@@ -161,6 +176,7 @@ ${CMO_ROLE}`,
{
key: "google_ads",
display_name: "Google Ads",
+ default_name: "Ana",
description: "Runs Google Ads campaigns, keywords, bids, budgets, search terms, negatives.",
capabilities: [
"Audit account health + identify wasted spend",
@@ -189,6 +205,7 @@ for files in your workspace, and the orchestration MCP for coordination.`,
{
key: "seo",
display_name: "SEO",
+ default_name: "Sam",
description: "SEO audits, content recommendations, ranking + click tracking, technical SEO.",
capabilities: [
"Audit on-page + technical SEO",
@@ -216,11 +233,48 @@ for files in your workspace, and the orchestration MCP for coordination.`,
export function agentNameFor(project_slug: string, template_key: AgentTemplate["key"]): string {
// OpenClaw agent name format: <project-slug>-<template-key>
- // Avoids reserved names; lowercase + hyphen-only.
+ // Avoids reserved names; lowercase + hyphen-only. Note this is the
+ // BACKEND id used by OpenClaw — distinct from the URL slug, which
+ // also encodes the personal name (see agentUrlSlug).
const safe_template = template_key.replace(/_/g, "-");
return `${project_slug}-${safe_template}`;
}
+/**
+ * URL slug for a template agent — `<role>-<slugified-name>`. The personal
+ * name is the user-chosen "Greg" / "Ana" etc; the role is the template
+ * key (cmo, google_ads → google-ads). Examples:
+ *
+ * role=cmo, name=Greg → "cmo-greg"
+ * role=google_ads, name="Ana Q4" → "google-ads-ana-q4"
+ *
+ * This slug appears in URLs (`/agents/cmo-greg/tasks`) and is what
+ * resolveAgentBySlug looks up. It is computed — never stored — so a
+ * future rename of an agent's name (currently not allowed) would just
+ * flow through here. Because names are immutable post-creation, the
+ * slug is effectively immutable too.
+ */
+export function agentUrlSlug(
+ template_key: AgentTemplate["key"],
+ name: string,
+): string {
+ const role = template_key.replace(/_/g, "-");
+ return `${role}-${slugifyName(name)}`;
+}
+
+/**
+ * Lowercase, hyphen-only, no leading/trailing dashes. Trims to a sane
+ * length so a misbehaving name input can't blow up the URL.
+ */
+export function slugifyName(name: string): string {
+ return name
+ .toLowerCase()
+ .trim()
+ .replace(/[^a-z0-9]+/g, "-")
+ .replace(/^-+|-+$/g, "")
+ .slice(0, 32);
+}
+
export type EnsureAgentsResult = {
created: string[];
existed: string[];
@@ -235,6 +289,12 @@ export type EnsureAgentsResult = {
* every template — preserved for back-compat with existing call sites like
* the reprovision endpoint.
*
+ * `names` is an optional partial map of template_key → user-chosen personal
+ * name (e.g. { cmo: "Greg", google_ads: "Ana" }). Names are immutable post-
+ * creation — when the meta sidecar already has a `name`, we keep it and
+ * IGNORE this argument for that agent. Templates with no entry here fall
+ * back to the template's `default_name`.
+ *
* The result includes `failed`: when a subprocess fails for one agent, the
* loop logs + continues (partial provisioning is recoverable) and the
* caller can decide whether `failed.length > 0` is fatal for their flow.
@@ -242,6 +302,7 @@ export type EnsureAgentsResult = {
export async function ensureProjectAgents(
project_slug: string,
scope?: AgentTemplateKey[],
+ names?: Partial<Record<AgentTemplateKey, string>>,
): Promise<EnsureAgentsResult> {
const created: string[] = [];
const existed: string[] = [];
@@ -252,24 +313,27 @@ export async function ensureProjectAgents(
: TEMPLATES;
for (const template of templates) {
- const name = agentNameFor(project_slug, template.key);
- const workspaceAbs = workspaceDirFor(name);
- const already = await agentExists(name);
+ const agentId = agentNameFor(project_slug, template.key);
+ const workspaceAbs = workspaceDirFor(agentId);
+ const already = await agentExists(agentId);
if (already) {
// Idempotently refresh the IDENTITY.md so prompt edits propagate to
// existing agents without forcing the user to delete + recreate.
- await writeIdentityFile(workspaceAbs, template, project_slug, name);
- // Backfill the notfair meta sidecar in case this agent was created
- // before we started writing it (so the sidebar still finds them).
+ await writeIdentityFile(workspaceAbs, template, project_slug, agentId);
+ // Read any existing meta so we PRESERVE the previously-chosen name
+ // (immutable per the agent model). Only when no sidecar exists yet
+ // do we fall back to the onboarding `names` map / template default.
+ const existing = readAgentMeta(agentId);
+ const personalName =
+ existing?.name ?? names?.[template.key] ?? template.default_name;
await writeAgentMeta({
- agent_id: name,
+ agent_id: agentId,
project_slug,
- slug: urlSlugForTemplate(template.key),
- display_name: template.display_name,
+ name: personalName,
template_key: template.key,
- created_at: new Date().toISOString(),
+ created_at: existing?.created_at ?? new Date().toISOString(),
});
- existed.push(name);
+ existed.push(agentId);
continue;
}
try {
@@ -283,26 +347,26 @@ export async function ensureProjectAgents(
await openclaw([
"agents",
"add",
- name,
+ agentId,
"--non-interactive",
"--workspace",
workspaceAbs,
]);
- await writeIdentityFile(workspaceAbs, template, project_slug, name);
+ await writeIdentityFile(workspaceAbs, template, project_slug, agentId);
+ const personalName = names?.[template.key] ?? template.default_name;
await writeAgentMeta({
- agent_id: name,
+ agent_id: agentId,
project_slug,
- slug: urlSlugForTemplate(template.key),
- display_name: template.display_name,
+ name: personalName,
template_key: template.key,
created_at: new Date().toISOString(),
});
- created.push(name);
+ created.push(agentId);
} catch (err) {
// Surface but don't crash the loop; partial provisioning recoverable on retry.
const message = err instanceof Error ? err.message : String(err);
- console.error(`Failed to create agent ${name}:`, err);
- failed.push({ name, error: message });
+ console.error(`Failed to create agent ${agentId}:`, err);
+ failed.push({ name: agentId, error: message });
}
}
diff --git a/src/server/onboarding/accounts.test.ts b/src/server/onboarding/accounts.test.ts
index d547eabc..d83868b1 100644
--- a/src/server/onboarding/accounts.test.ts
+++ b/src/server/onboarding/accounts.test.ts
@@ -50,6 +50,17 @@ vi.mock("@/server/db/tasks", () => ({
}));
vi.mock("@/server/agent-templates", () => ({
agentNameFor: (slug: string, key: string) => `${slug}-${key.replace(/_/g, "-")}`,
+ agentUrlSlug: (key: string, name: string) =>
+ `${key.replace(/_/g, "-")}-${name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`,
+ TEMPLATES: [
+ { key: "cmo", default_name: "Greg" },
+ { key: "google_ads", default_name: "Ana" },
+ { key: "seo", default_name: "Sam" },
+ ],
+}));
+
+vi.mock("@/server/agent-meta", () => ({
+ readAgentMeta: () => null,
}));
import {
diff --git a/src/server/onboarding/accounts.ts b/src/server/onboarding/accounts.ts
index 6eb316bc..16ae09ac 100644
--- a/src/server/onboarding/accounts.ts
+++ b/src/server/onboarding/accounts.ts
@@ -121,7 +121,14 @@ function parseAccountsPayload(
}
export type SetAccountResult =
- | { ok: true; project: Project; task_display_id: string }
+ | {
+ ok: true;
+ project: Project;
+ task_display_id: string;
+ /** URL slug for the CMO so the client can navigate to its tasks
+ * page without recomputing `<role>-<name>` itself. */
+ cmo_agent_slug: string;
+ }
| { ok: false; error: string };
/**
@@ -224,6 +231,20 @@ export async function setOnboardingAccountAction(
// /api/chat (which atomically claims). For the resubmit branch
// (audit already running/done) /api/chat is a safe no-op.
+ // Resolve the CMO's URL slug so the client can land on its tasks page
+ // without computing the role-name slug itself.
+ const { readAgentMeta } = await import("@/server/agent-meta");
+ const { agentUrlSlug, TEMPLATES } = await import("@/server/agent-templates");
+ const cmoMeta = readAgentMeta(cmoAgentId);
+ const cmoName =
+ cmoMeta?.name ?? TEMPLATES.find((t) => t.key === "cmo")!.default_name;
+ const cmo_agent_slug = agentUrlSlug("cmo", cmoName);
+
revalidatePath("/", "layout");
- return { ok: true, project: updated, task_display_id: task.display_id };
+ return {
+ ok: true,
+ project: updated,
+ task_display_id: task.display_id,
+ cmo_agent_slug,
+ };
}
diff --git a/src/server/openclaw/clone-agent.test.ts b/src/server/openclaw/clone-agent.test.ts
index fab0f5fa..826c49df 100644
--- a/src/server/openclaw/clone-agent.test.ts
+++ b/src/server/openclaw/clone-agent.test.ts
@@ -469,12 +469,12 @@ describe("cloneAgent", () => {
expect(meta.agent_id).toBe("metaproj-metaclone");
expect(meta.project_slug).toBe("metaproj");
expect(meta.slug).toBe("metaclone");
- expect(meta.display_name).toBe("Custom Display");
+ expect(meta.name).toBe("Custom Display");
expect(meta.source_agent_id).toBe("meta-src");
expect(typeof meta.created_at).toBe("string");
});
- it("defaults display_name to the source agent id when not provided", async () => {
+ it("defaults name to the source agent id when display_name is not provided", async () => {
listAgentFilesMock.mockResolvedValueOnce({ agentId: "no-display-src", workspace: "/ws", files: [] });
createAgentViaRpcMock.mockResolvedValueOnce(undefined);
await cloneAgent({
@@ -488,6 +488,6 @@ describe("cloneAgent", () => {
"utf8",
),
);
- expect(meta.display_name).toBe("no-display-src");
+ expect(meta.name).toBe("no-display-src");
});
});
diff --git a/src/server/openclaw/clone-agent.ts b/src/server/openclaw/clone-agent.ts
index 63626f5d..f615cc82 100644
--- a/src/server/openclaw/clone-agent.ts
+++ b/src/server/openclaw/clone-agent.ts
@@ -160,12 +160,15 @@ export async function cloneAgent(input: CloneAgentInput): Promise<CloneAgentResu
console.error("clone: could not list crons:", err);
}
- // 6) Meta sidecar so the sidebar shows the new agent.
+ // 6) Meta sidecar so the sidebar shows the new agent. Cloned agents
+ // aren't backed by a template — they keep the user-chosen `slug`
+ // on the sidecar (the rest of the system computes template agents'
+ // slugs from template_key + name instead).
await writeAgentMeta({
agent_id: newAgentId,
project_slug: input.project_slug,
slug: newSlug,
- display_name: displayName,
+ name: displayName,
source_agent_id: input.source_agent_id,
created_at: new Date().toISOString(),
});
diff --git a/src/server/openclaw/project-delete.test.ts b/src/server/openclaw/project-delete.test.ts
index 8e0926d7..9050d19d 100644
--- a/src/server/openclaw/project-delete.test.ts
+++ b/src/server/openclaw/project-delete.test.ts
@@ -95,15 +95,15 @@ describe("getProjectDeletionSummary", () => {
listProjectAgentsMock.mockResolvedValueOnce([
{
agent_id: "demo-cmo",
- slug: "cmo",
- display_name: "CMO",
+ slug: "cmo-greg",
+ name: "Greg",
template_key: "cmo",
is_template_default: true,
},
{
agent_id: "demo-google-ads",
- slug: "google-ads",
- display_name: "Google Ads",
+ slug: "google-ads-ana",
+ name: "Ana",
template_key: "google_ads",
is_template_default: true,
},
@@ -111,7 +111,7 @@ describe("getProjectDeletionSummary", () => {
{
agent_id: "demo-ghost",
slug: "ghost",
- display_name: "Ghost",
+ name: "Ghost",
is_template_default: false,
},
]);
@@ -190,8 +190,8 @@ describe("getProjectDeletionSummary", () => {
listProjectAgentsMock.mockResolvedValueOnce([
{
agent_id: "demo-cmo",
- slug: "cmo",
- display_name: "Chief Marketing Officer",
+ slug: "cmo-greg",
+ name: "Chief Marketing Officer",
template_key: "cmo",
is_template_default: true,
},
diff --git a/src/server/openclaw/project-delete.ts b/src/server/openclaw/project-delete.ts
index 960d6ccc..7a810d25 100644
--- a/src/server/openclaw/project-delete.ts
+++ b/src/server/openclaw/project-delete.ts
@@ -57,7 +57,7 @@ export async function getProjectDeletionSummary(
const threadCount = exists ? listSessionsForAgent(e.agent_id).length : 0;
return {
template: e.template_key,
- display_name: e.display_name,
+ display_name: e.name,
agentId: e.agent_id,
exists,
threadCount,
diff --git a/src/server/orchestration/handlers.ts b/src/server/orchestration/handlers.ts
index f53bdcea..533e93d0 100644
--- a/src/server/orchestration/handlers.ts
+++ b/src/server/orchestration/handlers.ts
@@ -662,7 +662,7 @@ export async function handleListProjectAgents(
data: entries.map((e) => ({
agent_id: e.agent_id,
slug: e.slug,
- display_name: e.display_name,
+ display_name: e.name,
description: e.description ?? "",
template_key: e.template_key ?? null,
is_template_default: Boolean(e.is_template_default),