Skip to content

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

Open
kuitos wants to merge 3 commits intoanomalyco:devfrom
kuitos:feat/agent-order-support
Open

feat(agent): add order field for configurable agent cycling order#19127
kuitos wants to merge 3 commits intoanomalyco:devfrom
kuitos:feat/agent-order-support

Conversation

@kuitos
Copy link

@kuitos kuitos commented Mar 25, 2026

Issue for this PR

Closes #7372

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an optional order field to agent config so users/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: number (optional) to both Config.Agent and Agent.Info. Sorting becomes:

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

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

Changes:

  • packages/opencode/src/config/config.ts: Add order to Config.Agent schema + knownKeys
  • packages/opencode/src/agent/agent.ts: Add order to Agent.Info, propagate from config, add to sortBy

How did you verify your code works?

Tested locally with oh-my-opencode plugin — agents with order 1-4 now cycle in the correct order instead of alphabetically. Verified that agents without order still sort alphabetically as before.

Screenshots / recordings

N/A — no UI changes, only sorting logic.

Checklist

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

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

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

kuitos added a commit to kuitos/oh-my-openagent that referenced this pull request Mar 25, 2026
…cycling

Inject an explicit `order` field (1-4) into the four core agents
(Sisyphus, Hephaestus, Prometheus, Atlas) via reorderAgentsByPriority().
This pre-empts OpenCode's alphabetical agent sorting so the intended
Tab cycle order is preserved once OpenCode merges order field support
(anomalyco/opencode#19127).

Refs anomalyco/opencode#7372
@kuitos
Copy link
Author

kuitos commented Mar 26, 2026

@thdxr @rekram1-node Could you pls take a look at this PR when you have time?

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