***

title: prompt_has_section
slug: /reference/python/agents/agent-base/prompt-has-section
description: Check whether a named section exists in the agent's prompt.
max-toc-depth: 3
---------------------

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

[prompt-add-section]: /docs/server-sdks/reference/python/agents/agent-base/prompt-add-section

Check whether a named section already exists in the agent's POM (Prompt Object Model)
prompt. Useful for conditionally adding content to avoid duplicate sections.

## **Parameters**

<ParamField path="title" type="str" required={true} toc={true}>
  The section title to look up. Must match the title passed to
  [`prompt_add_section()`][prompt-add-section].
</ParamField>

## **Returns**

`bool` -- `True` if a section with the given title exists, `False` otherwise.

## **Examples**

### Guard against duplicate sections

```python {5}
from signalwire import AgentBase

agent = AgentBase(name="assistant", route="/assistant")
agent.prompt_add_section("Greeting", body="Always greet the caller by name.")
if not agent.prompt_has_section("Policies"):
    agent.prompt_add_section("Policies", body="Follow company guidelines.")
agent.serve()
```

### Conditional prompt assembly in a subclass

```python {9}
from signalwire import AgentBase

class SupportAgent(AgentBase):
    def __init__(self):
        super().__init__(name="support", route="/support")
        self.prompt_add_section("Tone", body="Be empathetic and professional.")

    def add_escalation_rules(self):
        if not self.prompt_has_section("Escalation"):
            self.prompt_add_section("Escalation", bullets=[
                "Transfer to a human if the caller asks three times.",
                "Always confirm before transferring."
            ])
```