ContextBuilder
ContextBuilder is the top-level container for defining structured conversation
workflows. It holds one or more Context
objects, each containing a sequence of Step
objects. Use it when your agent needs guided, multi-step conversations instead of
free-form prompting.
Access the builder by calling define_contexts() on an
AgentBase instance. The builder
validates the entire context tree when the SWML document is rendered.
Properties
agent
The parent agent that owns these contexts. Typically called internally by
AgentBase.define_contexts() rather than instantiated directly.
You rarely create a ContextBuilder directly. Call self.define_contexts() inside
your agent class, which creates the builder and wires it into SWML generation
automatically.
Methods
Create a new named context and add it to the builder.
Retrieve an existing context by name.
Convert all contexts to a dictionary for SWML generation.
Validate the entire context configuration tree.
Helper to create a standalone Context without a ContextBuilder.