fix(tools): isolate tool schemas and waterfall failures

This commit is contained in:
Tianyi Cui
2026-06-17 21:26:12 +08:00
parent 922e2f913e
commit 87df09e3c3
4 changed files with 66 additions and 3 deletions

View File

@@ -123,8 +123,11 @@ export class SystemPrompt extends Service {
*/
assemble(): Promise<PromptAssembly> {
const assembly: PromptAssembly = {
sections: [...this.sections].sort((a, b) => a.order - b.order),
tools: this.toolProviders.flatMap(provider => provider()),
sections: this.sections
.map(section => ({ ...section }))
.sort((a, b) => a.order - b.order),
tools: this.toolProviders.flatMap(provider =>
provider().map(tool => ({ ...tool, parameters: structuredClone(tool.parameters) }))),
}
return this.ctx.waterfall(this, 'system-prompt/assemble', assembly, () => Promise.resolve(assembly))
}