validate

View as MarkdownOpen in Claude

Validate the entire context configuration. Called automatically during SWML rendering, but can be called manually to catch errors early.

Checks performed:

  • At least one context exists.
  • A single context is named "default".
  • Every context has at least one step.
  • All step-level valid_steps references point to steps that exist within the same context (the special value "next" is always allowed).
  • All valid_contexts references at the context level point to contexts that exist in the builder.
  • All valid_contexts references at the step level point to contexts that exist in the builder.
  • All gather_info configurations have at least one question, no duplicate keys, and valid completion_action targets.

Returns

None — Raises ValueError with a descriptive message if validation fails.

Example

1from signalwire import AgentBase
2
3agent = AgentBase(name="my-agent", route="/agent")
4
5contexts = agent.define_contexts()
6ctx = contexts.add_context("default")
7ctx.add_step("greet").set_text("Hello!")
8
9try:
10 contexts.validate()
11except ValueError as e:
12 print(f"Invalid context config: {e}")
13
14agent.serve()