lsd-pi 1.2.3 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -872,16 +872,21 @@ export class AgentSession {
872
872
  const requestedToolNames = [...new Set([...toolNames, ...this._getBuiltinToolNames()])];
873
873
  const tools: AgentTool[] = [];
874
874
  const validToolNames: string[] = [];
875
+ const seenToolNames = new Set<string>();
875
876
  for (const name of requestedToolNames) {
876
877
  const tool = this._toolRegistry.get(name);
877
- if (tool) {
878
- tools.push(tool);
879
- validToolNames.push(name);
878
+ if (!tool) {
879
+ continue;
880
+ }
881
+ if (seenToolNames.has(tool.name)) {
882
+ continue;
880
883
  }
884
+ seenToolNames.add(tool.name);
885
+ tools.push(tool);
886
+ validToolNames.push(name);
881
887
  }
882
888
  this.agent.setTools(tools);
883
889
 
884
-
885
890
  // Rebuild base system prompt with new tool set
886
891
  this._baseSystemPrompt = this._rebuildSystemPrompt(validToolNames);
887
892
  this.agent.setSystemPrompt(this._baseSystemPrompt);
@@ -71,7 +71,8 @@ function loadAgentsFromDir(dir: string, source: "bundled" | "user" | "project"):
71
71
  const tools = frontmatter.tools
72
72
  ?.split(",")
73
73
  .map((t: string) => t.trim())
74
- .filter(Boolean);
74
+ .filter(Boolean)
75
+ .filter((tool: string, index: number, all: string[]) => all.indexOf(tool) === index);
75
76
 
76
77
  agents.push({
77
78
  name: frontmatter.name,
@@ -23,7 +23,8 @@ export function buildSubagentProcessArgs(
23
23
  ): string[] {
24
24
  const args: string[] = ["--mode", "json", "-p", "--no-session"];
25
25
  if (model) args.push("--model", model);
26
- if (agent.tools && agent.tools.length > 0) args.push("--tools", agent.tools.join(","));
26
+ const uniqueTools = agent.tools?.filter((tool, index, all) => all.indexOf(tool) === index);
27
+ if (uniqueTools && uniqueTools.length > 0) args.push("--tools", uniqueTools.join(","));
27
28
  if (tmpPromptPath) args.push("--append-system-prompt", tmpPromptPath);
28
29
  args.push(`Task: ${task}`);
29
30
  return args;