add_step

View as MarkdownOpen in Claude

Add a new step to this context. When called with only name, the returned Step can be configured via method chaining. When keyword arguments are provided, the step is fully configured in one call.

Raises ValueError if the step name already exists in this context or the maximum steps per context limit (100) is exceeded.

Parameters

name
strRequired

Step name. Must be unique within this context.

task
str

Text for a “Task” POM section. Equivalent to calling step.add_section("Task", task).

bullets
list[str]

List of bullet strings for a “Process” POM section. Equivalent to calling step.add_bullets("Process", bullets). Requires task to also be set.

criteria
str

Step-completion criteria. Equivalent to calling step.set_step_criteria(criteria).

functions
str | list[str]

Tool names the step may call, or "none" to disable all tools. Equivalent to calling step.set_functions(functions).

valid_steps
list[str]

Names of steps the agent may transition to. Equivalent to calling step.set_valid_steps(valid_steps).

Returns

Step — The new step for optional further chaining.

Examples

Compact syntax

1from signalwire import AgentBase
2
3agent = AgentBase(name="my-agent", route="/agent")
4
5contexts = agent.define_contexts()
6ctx = contexts.add_context("default")
7
8ctx.add_step("get_name",
9 task="Ask for the customer's full name.",
10 criteria="Customer has provided their full name",
11 valid_steps=["get_email"]
12)
13ctx.add_step("get_email").set_text("Ask for the customer's email address.")
14
15agent.serve()

Method chaining

1from signalwire import AgentBase
2
3agent = AgentBase(name="my-agent", route="/agent")
4
5contexts = agent.define_contexts()
6ctx = contexts.add_context("default")
7
8ctx.add_step("get_name") \
9 .add_section("Task", "Ask for the customer's full name.") \
10 .set_step_criteria("Customer has provided their full name") \
11 .set_valid_steps(["get_email"])
12ctx.add_step("get_email").set_text("Ask for the customer's email address.")
13
14agent.serve()