Skip to content

Commit b06e33f

Browse files
hobostayclaude
andcommitted
feat(agent): add optional title field for better display in agent lists
This PR addresses issue anomalyco#4825 where agent descriptions are too long and unreadable in the `/agents` command list. **Changes:** - Added optional `title` field to Agent config schema (recommended: 2-5 words) - Updated agent dialog UI to prioritize title over description - Added fallback logic: 1. Use `title` if provided 2. Otherwise truncate `description` to 60 characters 3. Fall back to agent name if neither exists **Benefits:** - Agent lists are now readable with concise titles - Long descriptions can still be used for AI context - Backward compatible - existing agents work without changes - Users can optionally add `title` to new or existing agents **Example:** ```json { "title": "Database Query Expert", "description": "This agent specializes in writing and optimizing SQL queries..." } ``` In the agent list, this will show as "Database Query Expert" instead of the full description. Fixes anomalyco#4825 Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 1d041c8 commit b06e33f

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/opencode/src/cli/cmd/tui/component/dialog-agent.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@ import { useLocal } from "@tui/context/local"
33
import { DialogSelect } from "@tui/ui/dialog-select"
44
import { useDialog } from "@tui/ui/dialog"
55

6+
function truncate(str: string | undefined, maxLength: number): string {
7+
if (!str) return ""
8+
if (str.length <= maxLength) return str
9+
return str.slice(0, maxLength - 3) + "..."
10+
}
11+
612
export function DialogAgent() {
713
const local = useLocal()
814
const dialog = useDialog()
915

1016
const options = createMemo(() =>
1117
local.agent.list().map((item) => {
18+
// Use title if available, otherwise truncate description for display
19+
const displayTitle = item.title || truncate(item.description, 60) || item.name
1220
return {
1321
value: item.name,
1422
title: item.name,
15-
description: item.native ? "native" : item.description,
23+
description: item.native ? "native" : displayTitle,
1624
}
1725
}),
1826
)

‎packages/opencode/src/config/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ export namespace Config {
683683
prompt: z.string().optional(),
684684
tools: z.record(z.string(), z.boolean()).optional().describe("@deprecated Use 'permission' field instead"),
685685
disable: z.boolean().optional(),
686+
title: z.string().optional().describe("Short title for display in agent lists (recommended: 2-5 words)"),
686687
description: z.string().optional().describe("Description of when to use the agent"),
687688
mode: z.enum(["subagent", "primary", "all"]).optional(),
688689
hidden: z

0 commit comments

Comments
 (0)