{"record":{"id":"a5c6756e66507b5b","repo":"microsoft/semantic-kernel","slug":"step-name-builder-name-is-already-used-assign-a","errorCode":null,"errorMessage":"Step name {builder.Name} is already used, assign a different name for step","messagePattern":"Step name (.+?) is already used, assign a different name for step","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Experimental/Process.Core/ProcessBuilder.cs","lineNumber":167,"sourceCode":"        this._steps.Add(stepBuilder);\n    }\n\n    /// <summary>\n    /// Check to ensure stepName is not used yet in another step\n    /// </summary>\n    private bool StepNameAlreadyExists(string stepName)\n    {\n        return this._steps.Select(step => step.Name).Contains(stepName);\n    }\n\n    /// <summary>\n    /// Verify step is unique and add to the process.\n    /// </summary>\n    private TBuilder AddStep<TBuilder>(TBuilder builder, IReadOnlyList<string>? aliases) where TBuilder : ProcessStepBuilder\n    {\n        if (this.StepNameAlreadyExists(builder.Name))\n        {\n            throw new InvalidOperationException($\"Step name {builder.Name} is already used, assign a different name for step\");\n        }\n\n        if (aliases != null && aliases.Count > 0)\n        {\n            builder.Aliases = aliases;\n        }\n\n        this._steps.Add(builder);\n\n        return builder;\n    }\n\n    #region Public Interface\n\n    /// <summary>\n    /// A read-only collection of steps in the process.\n    /// </summary>\n    public IReadOnlyList<ProcessStepBuilder> Steps => this._steps.AsReadOnly();","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Experimental/Process.Core/ProcessBuilder.cs#L149-L185","documentation":"Thrown by ProcessBuilder.AddStep when a step with the same Name has already been added to the process's _steps list. Step names must be unique within a process because they serve as identifiers for edge routing and state persistence.","triggerScenarios":"Calling AddStepFromType, AddStepFromAgent, or AddStepFromProcess twice with steps that resolve to the same name. The default name for AddStepFromType is typeof(TStep).Name, so adding two instances of the same step type without an explicit id triggers this.","commonSituations":"Adding two steps of the same type (e.g., two ProcessStepBuilder<MyStep>) without providing unique id parameters. Adding a step whose name collides with a previously added sub-process or map step. Reusing the same builder instance or name across different parts of the process.","solutions":["Provide a unique 'id' parameter when adding multiple steps of the same type: AddStepFromType<MyStep>(id: \"step1\") and AddStepFromType<MyStep>(id: \"step2\").","Rename steps or use different step types if uniqueness cannot be achieved via id.","Audit existing step names in the process before adding a new one."],"exampleFix":"// before — two steps of the same type, default name collides\nprocess.AddStepFromType<MyStep>();\nprocess.AddStepFromType<MyStep>(); // throws — both named 'MyStep'\n\n// after\nprocess.AddStepFromType<MyStep>(id: \"step1\");\nprocess.AddStepFromType<MyStep>(id: \"step2\");","handlingStrategy":"validation","validationCode":"public static void EnsureUniqueStepName(ProcessBuilder process, string stepName)\n{\n    if (process.Steps.Any(s => s.Name == stepName))\n    {\n        throw new InvalidOperationException($\"Step name '{stepName}' already exists in process '{process.Name}'.\");\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a unique 'id' to AddStepFromType when adding multiple instances of the same step type.","Check process.Steps for name collisions before adding a new step.","Use a naming convention or auto-incrementing suffix for repeated step types."],"tags":["semantic-kernel","process-framework","step-builder","duplicate","validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}