Skip to content

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

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

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

Conversation

@LCubero
Copy link
Copy Markdown

@LCubero LCubero commented Apr 27, 2026

Closes #7372

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 default agent). This breaks plugins that define multiple agents with a specific intended order.

The fix adds order (positive integer, optional) to both ConfigAgent.Info and Agent.Info. Sorting becomes:

  1. Default agent first (unchanged)
  2. By order ascending (new)
  3. By name ascending (unchanged fallback)

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 verified

  • Two new unit tests: order field sorting and mixed ordered/unordered agents
  • Existing alphabetical sort test renamed and still passes
  • Backward compatible: agents without order sort alphabetically as before

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 github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

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

Potential Duplicate PRs Found

Based on my search, I found 3 potentially related PRs:

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

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

  3. 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"

Why they're related: All three PRs are implementing the same feature - adding an order field to agent configuration to control the cycling/sorting order of agents instead of relying on alphabetical sorting. This appears to be a frequently attempted feature addressing the same underlying issue.

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

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Configurable Agent Cycling Order (Tab)

1 participant