Skip to content

fix: stabilize agent and skill ordering in prompt descriptions#18261

Merged
rekram1-node merged 5 commits intoanomalyco:devfrom
jorgitin02:fix/18215-deterministic-prompt-ordering
Mar 19, 2026
Merged

fix: stabilize agent and skill ordering in prompt descriptions#18261
rekram1-node merged 5 commits intoanomalyco:devfrom
jorgitin02:fix/18215-deterministic-prompt-ordering

Conversation

@jorgitin02
Copy link
Contributor

Issue for this PR

Closes #18215

Type of change

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

What does this PR do?

This makes the agent and skill lists deterministic anywhere they become part of the prompt.

The main fix is sorting subagents in task.ts, sorting skills in skill.ts, and giving Agent.list() a stable secondary sort by agent name while still keeping the configured default agent first.

I also sorted the skill list in session/system.ts because that prompt section could still change byte-for-byte across calls even after fixing the tool descriptions, which would still hurt prompt cache reuse.

Tests cover the new ordering behavior and repeated-call stability for agent listing, task tool descriptions, skill tool descriptions, and the system prompt skill section.

How did you verify your code works?

Ran in packages/opencode:

  • bun test test/agent/agent.test.ts test/tool/skill.test.ts test/tool/task.test.ts test/session/system.test.ts
  • ./node_modules/.bin/tsgo --noEmit
  • bun test

Results:

  • focused regression tests: 42 pass / 0 fail
  • full suite: 1374 pass / 8 skip / 0 fail

Screenshots / recordings

Not a UI change.

Checklist

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

@rekram1-node
Copy link
Collaborator

For e2e stuff it doesn't seem like it's relataed to ur changes, I think our CI is flaky, let's avoid changing that in this PR

@rekram1-node
Copy link
Collaborator

/review

@github-actions
Copy link
Contributor

lgtm

@rekram1-node rekram1-node merged commit 2dbcd79 into anomalyco:dev Mar 19, 2026
6 of 8 checks passed
raf1hh pushed a commit to raf1hh/opencode that referenced this pull request Mar 20, 2026
…lyco#18261)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
demostanis pushed a commit to demostanis/opencode that referenced this pull request Mar 20, 2026
…lyco#18261)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
pengzha0 pushed a commit to pengzha0/dwtcode that referenced this pull request Mar 23, 2026
…lyco#18261)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
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.

Non-deterministic agent/skill ordering in tool descriptions breaks prompt caching

2 participants