-
Notifications
You must be signed in to change notification settings - Fork 13.8k
fix: stabilize agent and skill ordering in prompt descriptions #18261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rekram1-node
merged 5 commits into
anomalyco:dev
from
jorgitin02:fix/18215-deterministic-prompt-ordering
Mar 19, 2026
+189
−5
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4466619
fix: stabilize prompt agent and skill ordering
jorgitin02 0f190d0
fix: stabilize workspace e2e path assertions
jorgitin02 82b5f1f
tweak: centralize skill sorting
rekram1-node 1a211f6
Merge branch 'dev' into fix/18215-deterministic-prompt-ordering
rekram1-node c88e4a5
cleanup: minimize diff
rekram1-node File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { describe, expect, test } from "bun:test" | ||
| import path from "path" | ||
| import { Agent } from "../../src/agent/agent" | ||
| import { Instance } from "../../src/project/instance" | ||
| import { SystemPrompt } from "../../src/session/system" | ||
| import { tmpdir } from "../fixture/fixture" | ||
|
|
||
| describe("session.system", () => { | ||
| test("skills output is sorted by name and stable across calls", async () => { | ||
| await using tmp = await tmpdir({ | ||
| git: true, | ||
| init: async (dir) => { | ||
| for (const [name, description] of [ | ||
| ["zeta-skill", "Zeta skill."], | ||
| ["alpha-skill", "Alpha skill."], | ||
| ["middle-skill", "Middle skill."], | ||
| ]) { | ||
| const skillDir = path.join(dir, ".opencode", "skill", name) | ||
| await Bun.write( | ||
| path.join(skillDir, "SKILL.md"), | ||
| `--- | ||
| name: ${name} | ||
| description: ${description} | ||
| --- | ||
|
|
||
| # ${name} | ||
| `, | ||
| ) | ||
| } | ||
| }, | ||
| }) | ||
|
|
||
| const home = process.env.OPENCODE_TEST_HOME | ||
| process.env.OPENCODE_TEST_HOME = tmp.path | ||
|
|
||
| try { | ||
| await Instance.provide({ | ||
| directory: tmp.path, | ||
| fn: async () => { | ||
| const build = await Agent.get("build") | ||
| const first = await SystemPrompt.skills(build!) | ||
| const second = await SystemPrompt.skills(build!) | ||
|
|
||
| expect(first).toBe(second) | ||
|
|
||
| const alpha = first!.indexOf("<name>alpha-skill</name>") | ||
| const middle = first!.indexOf("<name>middle-skill</name>") | ||
| const zeta = first!.indexOf("<name>zeta-skill</name>") | ||
|
|
||
| expect(alpha).toBeGreaterThan(-1) | ||
| expect(middle).toBeGreaterThan(alpha) | ||
| expect(zeta).toBeGreaterThan(middle) | ||
| }, | ||
| }) | ||
| } finally { | ||
| process.env.OPENCODE_TEST_HOME = home | ||
| } | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { describe, expect, test } from "bun:test" | ||
| import { Agent } from "../../src/agent/agent" | ||
| import { Instance } from "../../src/project/instance" | ||
| import { TaskTool } from "../../src/tool/task" | ||
| import { tmpdir } from "../fixture/fixture" | ||
|
|
||
| describe("tool.task", () => { | ||
| test("description sorts subagents by name and is stable across calls", async () => { | ||
| await using tmp = await tmpdir({ | ||
| config: { | ||
| agent: { | ||
| zebra: { | ||
| description: "Zebra agent", | ||
| mode: "subagent", | ||
| }, | ||
| alpha: { | ||
| description: "Alpha agent", | ||
| mode: "subagent", | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| await Instance.provide({ | ||
| directory: tmp.path, | ||
| fn: async () => { | ||
| const build = await Agent.get("build") | ||
| const first = await TaskTool.init({ agent: build }) | ||
| const second = await TaskTool.init({ agent: build }) | ||
|
|
||
| expect(first.description).toBe(second.description) | ||
|
|
||
| const alpha = first.description.indexOf("- alpha: Alpha agent") | ||
| const explore = first.description.indexOf("- explore:") | ||
| const general = first.description.indexOf("- general:") | ||
| const zebra = first.description.indexOf("- zebra: Zebra agent") | ||
|
|
||
| expect(alpha).toBeGreaterThan(-1) | ||
| expect(explore).toBeGreaterThan(alpha) | ||
| expect(general).toBeGreaterThan(explore) | ||
| expect(zebra).toBeGreaterThan(general) | ||
| }, | ||
| }) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.