perf(plugins): classify cached tool candidates once (#96948) · openclaw/openclaw@c1336b6
ly-wang19
·
2026-06-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -707,6 +707,17 @@ function createCachedDescriptorPluginTool(params: {
|
707 | 707 | throw new Error(`plugin tool runtime unavailable (${pluginId}): ${toolName}`); |
708 | 708 | } |
709 | 709 | const requestedToolName = normalizeToolName(toolName); |
| 710 | +const matchingNamedCandidates: PluginToolRegistration[] = []; |
| 711 | +const unnamedCandidates: PluginToolRegistration[] = []; |
| 712 | +for (const candidate of candidates) { |
| 713 | +if (candidate.names.length === 0) { |
| 714 | +unnamedCandidates.push(candidate); |
| 715 | +continue; |
| 716 | +} |
| 717 | +if (candidate.names.some((name) => normalizeToolName(name) === requestedToolName)) { |
| 718 | +matchingNamedCandidates.push(candidate); |
| 719 | +} |
| 720 | +} |
710 | 721 | const resolveCandidateTool = ( |
711 | 722 | candidate: PluginToolRegistration, |
712 | 723 | ): AnyAgentTool | undefined => { |
@@ -724,12 +735,6 @@ function createCachedDescriptorPluginTool(params: {
|
724 | 735 | } |
725 | 736 | return undefined; |
726 | 737 | }; |
727 | | -const matchingNamedCandidates = candidates.filter( |
728 | | -(candidate) => |
729 | | -candidate.names.length > 0 && |
730 | | -candidate.names.some((name) => normalizeToolName(name) === requestedToolName), |
731 | | -); |
732 | | -const unnamedCandidates = candidates.filter((candidate) => candidate.names.length === 0); |
733 | 738 | for (const candidate of [...matchingNamedCandidates, ...unnamedCandidates]) { |
734 | 739 | let matchedTool: AnyAgentTool | undefined; |
735 | 740 | try { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。