Skip to content

Commit 47baffc

Browse files
committed
feat(agent): add order field for configurable agent cycling order
Add an optional `order` field to the agent config schema that controls agent sorting in the Tab cycle. Agents with lower order values appear first. Agents without an explicit order fall back to alphabetical sorting, preserving backward compatibility. This allows plugins and users to control the exact ordering of agents in the Tab cycle without relying on name-based alphabetical sorting. Closes anomalyco#7372
1 parent 0c0c6f3 commit 47baffc

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎packages/opencode/src/agent/agent.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export namespace Agent {
3333
hidden: z.boolean().optional(),
3434
topP: z.number().optional(),
3535
temperature: z.number().optional(),
36+
order: z.number().int().optional(),
3637
color: z.string().optional(),
3738
permission: Permission.Ruleset,
3839
model: z
@@ -256,6 +257,7 @@ export namespace Agent {
256257
item.color = value.color ?? item.color
257258
item.hidden = value.hidden ?? item.hidden
258259
item.name = value.name ?? item.name
260+
item.order = value.order ?? item.order
259261
item.steps = value.steps ?? item.steps
260262
item.options = mergeDeep(item.options, value.options ?? {})
261263
item.permission = Permission.merge(item.permission, Permission.fromConfig(value.permission ?? {}))
@@ -288,6 +290,7 @@ export namespace Agent {
288290
values(),
289291
sortBy(
290292
[(x) => (cfg.default_agent ? x.name === cfg.default_agent : x.name === "build"), "desc"],
293+
[(x) => x.order ?? Infinity, "asc"],
291294
[(x) => x.name, "asc"],
292295
),
293296
)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,11 @@ export namespace Config {
723723
disable: z.boolean().optional(),
724724
description: z.string().optional().describe("Description of when to use the agent"),
725725
mode: z.enum(["subagent", "primary", "all"]).optional(),
726+
order: z
727+
.number()
728+
.int()
729+
.optional()
730+
.describe("Sorting order for agent cycling (Tab). Lower values appear first. Agents without order are sorted alphabetically after ordered agents."),
726731
hidden: z
727732
.boolean()
728733
.optional()
@@ -755,6 +760,7 @@ export namespace Config {
755760
"temperature",
756761
"top_p",
757762
"mode",
763+
"order",
758764
"hidden",
759765
"color",
760766
"steps",

0 commit comments

Comments
 (0)