***

title: add_context
slug: /reference/python/agents/context-builder/add-context
description: Create a new named context and add it to the builder.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[context]: /docs/server-sdks/reference/python/agents/context-builder/context

Create a new context and add it to the builder. Returns the Context object for
method chaining.

Raises `ValueError` if the context name already exists or the maximum context limit
(50) is exceeded.

<Warning>
  A single-context agent must name its context `"default"` or validation will fail.
  Multi-context agents can use any names.
</Warning>

## **Parameters**

<ParamField path="name" type="str" required={true} toc={true}>
  Unique context name. When using a single context, it **must** be named `"default"`.
</ParamField>

## **Returns**

[`Context`][context] -- The newly
created context, ready for adding steps.

## **Examples**

### Single context

```python {6}
from signalwire import AgentBase

agent = AgentBase(name="order-agent", route="/order")

contexts = agent.define_contexts()
default = contexts.add_context("default")
default.add_step("greet").set_text("Greet the caller and ask how you can help.")

agent.serve()
```

### Multiple contexts

```python {6-8}
from signalwire import AgentBase

agent = AgentBase(name="support-agent", route="/support")

contexts = agent.define_contexts()
main = contexts.add_context("default")
sales = contexts.add_context("sales")
support = contexts.add_context("support")

main.add_step("menu").set_text("Ask whether the caller needs sales or support.")
sales.add_step("qualify").set_text("Understand what product the caller wants.")
support.add_step("diagnose").set_text("Understand the customer's issue.")

agent.serve()
```