Skip to content

feat(agent): add order field for configurable agent cycling order#24691

Open
LCubero wants to merge 1 commit intoanomalyco:devfrom
LCubero:feat/agent-order
Open

feat(agent): add order field for configurable agent cycling order#24691
LCubero wants to merge 1 commit intoanomalyco:devfrom
LCubero:feat/agent-order

Conversation

@LCubero
Copy link
Copy Markdown

@LCubero LCubero commented Apr 27, 2026

Issue for this PR

Closes #7372

Type of change

  • New feature

What does this PR do?

Adds an optional order field (PositiveInt) to agent config so users and plugins can control Tab cycling order instead of being forced into alphabetical sort.

Currently Agent.list() sorts agents alphabetically by name (after the default agent). This breaks plugins that define multiple agents with a specific intended order. For example, oh-my-opencode defines Sisyphus → Hephaestus → Prometheus → Atlas, but alphabetical sort produces Atlas → Hephaestus → Prometheus → Sisyphus.

Sorting becomes:

  1. Default agent first (unchanged)
  2. By order ascending (new) — agents without order get Infinity
  3. By name ascending (unchanged fallback)

Fully backward compatible — configs without order behave exactly as before.

Changes:

  • packages/opencode/src/config/agent.ts: Add order to AgentSchema + KNOWN_KEYS
  • packages/opencode/src/agent/agent.ts: Add order to Info schema, merge logic, and sortBy
  • packages/opencode/test/agent/agent.test.ts: Add 2 tests for order field sorting

How did you verify your code works?

Two new unit tests cover the behavior:

  1. Order field sorting — agents with order: 1, 2, 3 appear in that sequence after the default agent
  2. Mixed ordered/unordered — agents with order appear before those without, fall back to alphabetical

The existing alphabetical sort test was renamed for clarity and still passes. Backward compatibility is verified: agents without order sort alphabetically as before.

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Adds an optional `order` field (PositiveInt) to agent config so
users and plugins can control Tab cycling order.

Sorting in Agent.list() becomes:
1. Default agent first (unchanged)
2. By order ascending (new)
3. By name ascending (unchanged fallback)

Fully backward-compatible — agents without `order` behave as before.

Closes anomalyco#7372
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate PRs Found

  1. PR feat(agent): add order field for configurable agent cycling order #19127 - feat(agent): add order field for configurable agent cycling order

  2. PR feat(opencode): add order field to agent config for explicit list sorting #22343 - feat(opencode): add order field to agent config for explicit list sorting

Both of these PRs appear to address the same issue (sorting agents by configurable order field instead of alphabetically) that your PR #24691 is implementing.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Configurable Agent Cycling Order (Tab)

1 participant