Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(agent): add agent description to profile and agents list (#21387)

Rdmclin27e7dbbcfb56f
diff --git a/locales/en-US/setting.json b/locales/en-US/setting.json
index ee417d65c3d..bff0d592042 100644
--- a/locales/en-US/setting.json
+++ b/locales/en-US/setting.json
@@ -1274,6 +1274,9 @@
"settingAgent.avatar.title": "Avatar",
"settingAgent.backgroundColor.title": "Background Color",
"settingAgent.description.desc": "A brief introduction to your agent, not for character setting",
+ "settingAgent.description.hint": "Other agents read this when they look up who to hand work to.",
+ "settingAgent.description.inputPlaceholder": "What it handles and when to use it, e.g. Reviews pull requests and runs the test suite",
+ "settingAgent.description.label": "Description",
"settingAgent.description.placeholder": "Enter agent description",
"settingAgent.description.title": "Agent Description",
"settingAgent.devicePolicy.noPublicDevice": "No public devices",
diff --git a/locales/zh-CN/setting.json b/locales/zh-CN/setting.json
index 535771d8e60..10bf054c50f 100644
--- a/locales/zh-CN/setting.json
+++ b/locales/zh-CN/setting.json
@@ -1274,6 +1274,9 @@
"settingAgent.avatar.title": "助理头像",
"settingAgent.backgroundColor.title": "头像背景色",
"settingAgent.description.desc": "简单介绍你的助理,不作为角色设定",
+ "settingAgent.description.hint": "其他助理查找协作对象时会读取这段描述。",
+ "settingAgent.description.inputPlaceholder": "它负责什么、什么时候找它,例如:审查 PR 并运行测试",
+ "settingAgent.description.label": "描述",
"settingAgent.description.placeholder": "请输入助理描述",
"settingAgent.description.title": "助理描述",
"settingAgent.devicePolicy.noPublicDevice": "暂无公开设备",
diff --git a/packages/locales/src/default/setting.ts b/packages/locales/src/default/setting.ts
index bea94c896bf..fd906b41c4b 100644
--- a/packages/locales/src/default/setting.ts
+++ b/packages/locales/src/default/setting.ts
@@ -1110,6 +1110,10 @@ export default {
'settingAgent.artwork.uploadFailed': 'Could not upload the image. Try again.',
'settingAgent.backgroundColor.title': 'Background Color',
'settingAgent.description.desc': 'A brief introduction to your agent, not for character setting',
+ 'settingAgent.description.hint': 'Other agents read this when they look up who to hand work to.',
+ 'settingAgent.description.inputPlaceholder':
+ 'What it handles and when to use it, e.g. Reviews pull requests and runs the test suite',
+ 'settingAgent.description.label': 'Description',
'settingAgent.description.placeholder': 'Enter agent description',
'settingAgent.description.title': 'Agent Description',
'settingAgent.export.dialogTitle': 'Export Agent Profile',
diff --git a/src/features/AgentIdentityModal/Content.tsx b/src/features/AgentIdentityModal/Content.tsx
index 9f48c2054c5..6924db3dd8f 100644
--- a/src/features/AgentIdentityModal/Content.tsx
+++ b/src/features/AgentIdentityModal/Content.tsx
@@ -1,7 +1,16 @@
'use client';
import { randomAgentName } from '@lobechat/const';
-import { ActionIcon, Button, cssVar, Flexbox, Input, Text, useModalContext } from '@lobehub/ui';
+import {
+ ActionIcon,
+ Button,
+ cssVar,
+ Flexbox,
+ Input,
+ Text,
+ TextArea,
+ useModalContext,
+} from '@lobehub/ui';
import { DicesIcon } from 'lucide-react';
import { memo, type ReactNode, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
@@ -31,8 +40,11 @@ interface AgentIdentityContentProps {
agentId: string;
}
+/** Matches the `agents.description` column width. */
+const DESCRIPTION_MAX_LENGTH = 1000;
+
/**
- * The three identity fields as a real form. They used to be inline inputs in the
+ * The identity fields as a real form. They used to be inline inputs in the
* profile header, which crowded it and left no room for a per-field label or
* error. All behaviour lives in {@link useAgentIdentityForm}.
*/
@@ -82,6 +94,24 @@ const AgentIdentityContent = memo<AgentIdentityContentProps>(({ agentId }) => {
onChange={(e) => form.setTitle(e.target.value)}
/>
</Field>
+ {/* Other agents read this when they list agents to pick a teammate, so
+ the hint says who the text is for. */}
+ <Field
+ label={t('settingAgent.description.label', { ns: 'setting' })}
+ hint={
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {t('settingAgent.description.hint', { ns: 'setting' })}
+ </Text>
+ }
+ >
+ <TextArea
+ autoSize={{ maxRows: 6, minRows: 2 }}
+ maxLength={DESCRIPTION_MAX_LENGTH}
+ placeholder={t('settingAgent.description.inputPlaceholder', { ns: 'setting' })}
+ value={form.description}
+ onChange={(e) => form.setDescription(e.target.value)}
+ />
+ </Field>
{/* A builtin agent's identifier is not an editable field at all, so it is
not dressed as one: a disabled input still reads as "a control you
can't use right now" and needs a sentence explaining itself. Rendering
diff --git a/src/features/AgentIdentityModal/index.tsx b/src/features/AgentIdentityModal/index.tsx
index c5616769a39..3c5feb5b51e 100644
--- a/src/features/AgentIdentityModal/index.tsx
+++ b/src/features/AgentIdentityModal/index.tsx
@@ -5,7 +5,7 @@ import { t } from 'i18next';
import AgentIdentityContent from './Content';
-/** Open the identity form (name / role / slug) for a specific agent. */
+/** Open the identity form (name / role / description / slug) for a specific agent. */
export const createAgentIdentityModal = (agentId: string) =>
createModal({
content: <AgentIdentityContent agentId={agentId} />,
diff --git a/src/features/AgentIdentityModal/useAgentIdentityForm.test.ts b/src/features/AgentIdentityModal/useAgentIdentityForm.test.ts
index 7bd62ac8169..fd3e35736e6 100644
--- a/src/features/AgentIdentityModal/useAgentIdentityForm.test.ts
+++ b/src/features/AgentIdentityModal/useAgentIdentityForm.test.ts
@@ -4,7 +4,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { useAgentIdentityForm } from './useAgentIdentityForm';
const mocks = vi.hoisted(() => ({
- agentMap: {} as Record<string, { name?: string; slug?: string; title?: string }>,
+ agentMap: {} as Record<
+ string,
+ { description?: string; name?: string; slug?: string; title?: string }
+ >,
confirmAgentSlug: vi.fn(),
refreshAgentConfig: vi.fn(),
updateAgentMeta: vi.fn(),
@@ -48,7 +51,14 @@ const setup = () => {
beforeEach(() => {
vi.clearAllMocks();
- mocks.agentMap = { 'agent-a': { name: 'Alice', slug: 'old-slug', title: 'Health Assistant' } };
+ mocks.agentMap = {
+ 'agent-a': {
+ description: 'Tracks sleep and workouts',
+ name: 'Alice',
+ slug: 'old-slug',
+ title: 'Health Assistant',
+ },
+ };
mocks.updateAgentSlug.mockResolvedValue({ success: true });
mocks.updateAgentMeta.mockResolvedValue(undefined);
});
@@ -60,6 +70,7 @@ describe('useAgentIdentityForm', () => {
expect(result.current.name).toBe('Alice');
expect(result.current.title).toBe('Health Assistant');
expect(result.current.slug).toBe('old-slug');
+ expect(result.current.description).toBe('Tracks sleep and workouts');
});
it('saves name and role through the meta patch, leaving an unchanged slug alone', async () => {
@@ -71,6 +82,7 @@ describe('useAgentIdentityForm', () => {
});
expect(mocks.updateAgentMeta).toHaveBeenCalledExactlyOnceWith('agent-a', {
+ description: 'Tracks sleep and workouts',
name: '小艾',
title: 'Health Assistant',
});
@@ -78,6 +90,35 @@ describe('useAgentIdentityForm', () => {
expect(onSaved).toHaveBeenCalled();
});
+ it('saves the trimmed description with the rest of the identity', async () => {
+ const { result } = setup();
+
+ act(() => result.current.setDescription(' Reviews pull requests\n'));
+ await act(async () => {
+ await result.current.save();
+ });
+
+ expect(mocks.updateAgentMeta).toHaveBeenCalledExactlyOnceWith('agent-a', {
+ description: 'Reviews pull requests',
+ name: 'Alice',
+ title: 'Health Assistant',
+ });
+ });
+
+ it('clears the description when the field is emptied', async () => {
+ const { result } = setup();
+
+ act(() => result.current.setDescription(' '));
+ await act(async () => {
+ await result.current.save();
+ });
+
+ expect(mocks.updateAgentMeta).toHaveBeenCalledWith(
+ 'agent-a',
+ expect.objectContaining({ description: '' }),
+ );
+ });
+
it('routes identity changes through the optimistic sidebar projection', async () => {
const { result } = setup();
@@ -168,6 +209,7 @@ describe('useAgentIdentityForm', () => {
expect(mocks.updateAgentSlug).not.toHaveBeenCalled();
expect(mocks.updateAgentMeta).toHaveBeenCalledExactlyOnceWith('agent-a', {
+ description: '',
name: '',
title: 'Lobe AI',
});
diff --git a/src/features/AgentIdentityModal/useAgentIdentityForm.ts b/src/features/AgentIdentityModal/useAgentIdentityForm.ts
index 68795ad778c..fa386377275 100644
--- a/src/features/AgentIdentityModal/useAgentIdentityForm.ts
+++ b/src/features/AgentIdentityModal/useAgentIdentityForm.ts
@@ -16,11 +16,11 @@ interface UseAgentIdentityFormOptions {
const BUILTIN_SLUGS: ReadonlySet<string> = new Set<string>(Object.values(BUILTIN_AGENT_SLUGS));
/**
- * Drives the three identity fields of the agent form.
+ * Drives the identity fields of the agent form.
*
- * `name` and `title` ride the ordinary meta patch; `slug` has its own validated
+ * `name`, `title` and `description` ride the ordinary meta patch; `slug` has its own validated
* endpoint (see `updateAgentSlug`). The slug is committed FIRST so a rejected
- * one can keep the form open with its reason — saving the other two first would
+ * one can keep the form open with its reason — saving the others first would
* leave them persisted behind a form the user still has to fix.
*/
export const useAgentIdentityForm = ({ agentId, onSaved }: UseAgentIdentityFormOptions) => {
@@ -34,6 +34,7 @@ export const useAgentIdentityForm = ({ agentId, onSaved }: UseAgentIdentityFormO
const [name, setName] = useState(meta.name || '');
const [title, setTitle] = useState(meta.title || '');
+ const [description, setDescription] = useState(meta.description || '');
const [nextSlug, setNextSlug] = useState(slug || '');
const [error, setError] = useState<string | undefined>();
const [saving, setSaving] = useState(false);
@@ -62,7 +63,11 @@ export const useAgentIdentityForm = ({ agentId, onSaved }: UseAgentIdentityFormO
await refreshAgentConfig(agentId);
}
- await updateAgentMeta(agentId, { name: name.trim(), title: title.trim() });
+ await updateAgentMeta(agentId, {
+ description: description.trim(),
+ name: name.trim(),
+ title: title.trim(),
+ });
onSaved();
} catch {
setError(t('settingAgent.identity.saveFailed'));
@@ -72,10 +77,12 @@ export const useAgentIdentityForm = ({ agentId, onSaved }: UseAgentIdentityFormO
};
return {
+ description,
error,
name,
save,
saving,
+ setDescription,
setName,
setSlug: (value: string) => {
setNextSlug(value);
diff --git a/src/features/AgentViewAll/AgentRow.tsx b/src/features/AgentViewAll/AgentRow.tsx
index 68f6fdf8a6d..a0b41aef8d0 100644
--- a/src/features/AgentViewAll/AgentRow.tsx
+++ b/src/features/AgentViewAll/AgentRow.tsx
@@ -4,7 +4,7 @@ import { AGENT_CHAT_URL, DEFAULT_AVATAR, GROUP_CHAT_URL } from '@lobechat/const'
import type { SidebarAgentItem } from '@lobechat/types';
import { agentDisplayName, agentSecondaryDisplayName } from '@lobechat/types';
import { ContextMenuTrigger, type DropdownItem, Flexbox, Tooltip } from '@lobehub/ui';
-import { ActionIcon, Avatar, createStaticStyles, cssVar, Tag, Text } from '@lobehub/ui';
+import { ActionIcon, Avatar, createStaticStyles, cssVar, Text } from '@lobehub/ui';
import dayjs from 'dayjs';
import { EyeIcon, EyeOffIcon } from 'lucide-react';
import { memo, type MouseEvent, useCallback, useRef, useState } from 'react';
@@ -23,6 +23,11 @@ export const ACTION_COL_WIDTH = 64;
const AUTHOR_COL_WIDTH = 20;
const styles = createStaticStyles(({ css, cssVar }) => ({
+ // Second line, so name, role and description no longer compete for one
+ // line; rows without a description stay single-line.
+ description: css`
+ line-height: 18px;
+ `,
// The link spans the name column (not the whole row) — a management list
// is for scanning and acting, and a full-row link turns clicks on the
// author / timestamp / action columns into a navigation. The name column
@@ -43,6 +48,12 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
text-decoration: underline;
}
`,
+ // Plain secondary text (as in the sidebar), not a filled tag: a tag weighed
+ // as much as the name. Shrinks before the name, so the name stays readable.
+ role: css`
+ flex: 0 10 auto;
+ min-width: 0;
+ `,
row: css`
padding-block: 8px;
padding-inline: 12px;
@@ -100,7 +111,7 @@ interface AgentRowProps {
const AgentRow = memo<AgentRowProps>(
({ author, item, onToggleSidebar, showAuthor, sidebarHidden }) => {
const { t } = useTranslation('common');
- const { id, type, updatedAt } = item;
+ const { description, id, type, updatedAt } = item;
// Groups have no personal name, so this resolves to their title.
const displayTitle = agentDisplayName(item, t('agentViewAll.untitled'));
const roleTag = agentSecondaryDisplayName(item);
@@ -141,19 +152,35 @@ const AgentRow = memo<AgentRowProps>(
to={type === 'group' ? GROUP_CHAT_URL(id) : AGENT_CHAT_URL(id, false)}
>
<AgentAvatar item={item} size={28} />
- <Flexbox flex={1} style={{ minWidth: 0 }}>
- {/* Single-line row (Linear-style density) — the description only
- renders in card mode, where there is room to browse. */}
- <Flexbox horizontal align={'center'} gap={6} style={{ minWidth: 0 }}>
+ <Flexbox flex={1} gap={2} style={{ minWidth: 0 }}>
+ <Flexbox horizontal align={'baseline'} gap={8} style={{ minWidth: 0 }}>
<Text ellipsis className={'agent-row-title'} weight={500}>
{displayTitle}
</Text>
{roleTag ? (
- <Tag size={'small'} style={{ flex: 'none' }}>
+ <Text
+ ellipsis
+ className={styles.role}
+ fontSize={12}
+ title={roleTag}
+ type={'secondary'}
+ >
{roleTag}
- </Tag>
+ </Text>
) : null}
</Flexbox>
+ {description ? (
+ <Text
+ ellipsis
+ className={styles.description}
+ fontSize={12}
+ // Inline: Text's own color class would otherwise win.
+ style={{ color: cssVar.colorTextTertiary }}
+ title={description}
+ >
+ {description}
+ </Text>
+ ) : null}
</Flexbox>
</WorkspaceLink>
{/* Trailing cluster (Task-list-style): label pills + author avatar +
diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.test.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.test.tsx
index 3611c3bc7a3..7abec57e374 100644
--- a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.test.tsx
+++ b/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.test.tsx
@@ -223,6 +223,19 @@ describe('AgentHeader', () => {
expect(view.container.textContent).toContain('@brave-otter-lamp');
});
+ it('shows the description other agents read', () => {
+ mocks.agentStoreState.agentMap = {
+ 'agent-a': {
+ description: 'Reviews pull requests and runs the test suite',
+ name: 'Alice',
+ title: 'Code Reviewer',
+ },
+ };
+ const view = render(<AgentHeader />);
+
+ expect(view.container.textContent).toContain('Reviews pull requests and runs the test suite');
+ });
+
// Regression: the headline used to fall back to the name field's PLACEHOLDER,
// so every unnamed agent read as though it were called "Give it a name, …".
it('never renders the input placeholder as a headline', () => {
diff --git a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.tsx b/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.tsx
index 3ab2dcac2fc..656fe129346 100644
--- a/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.tsx
+++ b/src/routes/(main)/agent/profile/features/ProfileEditor/AgentHeader.tsx
@@ -32,6 +32,7 @@ const AgentHeader = memo(() => {
const { autoName, naming } = useAutoName(agentId);
const personalName = meta.name?.trim();
const role = meta.title?.trim();
+ const description = meta.description?.trim();
const suppressDuplicateRole =
!!config?.agencyConfig?.heterogeneousProvider &&
!!personalName &&
@@ -73,7 +74,7 @@ const AgentHeader = memo(() => {
if (canEdit) void updateMetaById(agentId, { backgroundColor });
}}
/>
- {/* Identity Section — display only. Editing all three fields happens in a
+ {/* Identity Section — display only. Editing the identity fields happens in a
form modal; inline inputs crowded the header and left no room for a
per-field label or error. */}
<Flexbox flex={1} gap={8} paddingInline={24} style={{ minWidth: 0 }}>
@@ -146,6 +147,13 @@ const AgentHeader = memo(() => {
</Tooltip>
) : null}
</Flexbox>
+ {/* Edited in the identity form; shown here so the owner sees what other
+ agents read about this one. */}
+ {description ? (
+ <Text ellipsis={{ rows: 2 }} style={{ color: cssVar.colorTextSecondary }}>
+ {description}
+ </Text>
+ ) : null}
</Flexbox>
</Flexbox>
);