fix(core): stabilize tool definition ordering (#38590)

This commit is contained in:
Kit Langton 2026-07-23 21:30:06 -04:00 committed by GitHub
commit c228fc4886
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 5 deletions

View file

@ -323,7 +323,10 @@ const registryLayer = Layer.effect(
const codemodeTool = (yield* codeMode.materialize(permissions)).tool
return {
definitions: [
...Array.from(direct, ([name, registration]) => toLLMDefinition(name, registration.tool)),
// Definitions are prompt-cache prefix bytes, so order only after effective registrations settle.
...Array.from(direct)
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))
.map(([name, registration]) => toLLMDefinition(name, registration.tool)),
...(codemodeTool ? [toLLMDefinition("execute", codemodeTool)] : []),
],
execute: (input: ExecuteInput) => {