Skip to content

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

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

feat(agent): add order field for configurable agent cycling order#24689
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. For example, oh-my-opencode defines Sisyphus → Hephaestus → Prometheus → Atlas, but alphabetical sort produces Atlas → Hephaestus → Prometheus → Sisyphus.

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) — 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 ordering, rename existing test

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

Note: This is an improved version of #19127 with the unrelated test change removed, tests added, and Effect Schema patterns used (the codebase migrated from zod to Effect Schema).

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.

@LCubero LCubero closed this Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

Found potential related PRs:

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

  2. 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
    feat(opencode): add order field to agent config for explicit list sorting #22343

    • Related work on agent config sorting order field, addressing the same feature need.
  3. feat(agent): add order field for configurable agent cycling order #24690 - feat(agent): add order field for configurable agent cycling order
    feat(agent): add order field for configurable agent cycling order #24690

    • Appears to be a duplicate with nearly identical title to the current PR (24689).

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