# Show Agent Reasoning on WhatsApp (/examples/agent-os/interfaces/whatsapp/reasoning-agent)



Enable the WhatsApp interface's show\_reasoning option. The interface sends available reasoning content as a separate formatted message before sending the Agent's final response.

```python title="reasoning_agent.py"
"""
Show Agent Reasoning on WhatsApp
================================

Enable the WhatsApp interface's show_reasoning option. The interface sends
available reasoning content as a separate formatted message before sending the
Agent's final response.

Prerequisites: OPENAI_API_KEY and the four WHATSAPP_* credentials in README.md
Run: .venvs/demo/bin/python cookbook/05_agent_os/19_whatsapp/reasoning_agent.py
Try: Ask for a concise comparison of two public companies
"""

from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
from agno.os.interfaces.whatsapp import Whatsapp
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools

# ---------------------------------------------------------------------------
# Create the Reasoning WhatsApp AgentOS
# ---------------------------------------------------------------------------

db = SqliteDb(
    id="whatsapp-reasoning-db",
    db_file="tmp/whatsapp_reasoning.db",
)

finance_agent = Agent(
    id="whatsapp-reasoning-agent",
    name="WhatsApp Reasoning Agent",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    tools=[
        ReasoningTools(add_instructions=True),
        YFinanceTools(),
    ],
    instructions=[
        "Compare the requested companies using current financial data.",
        "Keep reasoning focused and the final answer concise for WhatsApp.",
    ],
    add_datetime_to_context=True,
)

agent_os = AgentOS(
    id="whatsapp-reasoning-os",
    description="An AgentOS that exposes reasoning through WhatsApp messages.",
    agents=[finance_agent],
    interfaces=[
        Whatsapp(
            agent=finance_agent,
            show_reasoning=True,
        )
    ],
)
app = agent_os.get_app()

# ---------------------------------------------------------------------------
# Run the Reasoning WhatsApp Server
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    agent_os.serve(app=app)
```

## Run the Example [#run-the-example]

<Steps>
    <Step title="Set up your virtual environment">
      <CodeBlockTabs defaultValue="Mac">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="Mac">
            Mac
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="Windows">
            Windows
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="Mac">
          ```bash
          uv venv --python 3.12
          source .venv/bin/activate
          ```
        </CodeBlockTab>

        <CodeBlockTab value="Windows">
          ```bash
          uv venv --python 3.12
          .venv\Scripts\activate
          ```
        </CodeBlockTab>
      </CodeBlockTabs>
    </Step>

  <Step title="Install dependencies">
    ```bash
    uv pip install -U "agno[os]" openai yfinance
    ```
  </Step>

  <Step title="Export environment variables">
    <CodeBlockTabs defaultValue="Mac/Linux">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac/Linux">
          Mac/Linux
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac/Linux">
        ```bash
        export OPENAI_API_KEY="your_openai_api_key_here"
        export WHATSAPP_ACCESS_TOKEN="your_whatsapp_access_token_here"
        export WHATSAPP_APP_SECRET="your_whatsapp_app_secret_here"
        export WHATSAPP_PHONE_NUMBER_ID="your_whatsapp_phone_number_id_here"
        export WHATSAPP_VERIFY_TOKEN="your_whatsapp_verify_token_here"
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```bash
        $Env:OPENAI_API_KEY="your_openai_api_key_here"
        $Env:WHATSAPP_ACCESS_TOKEN="your_whatsapp_access_token_here"
        $Env:WHATSAPP_APP_SECRET="your_whatsapp_app_secret_here"
        $Env:WHATSAPP_PHONE_NUMBER_ID="your_whatsapp_phone_number_id_here"
        $Env:WHATSAPP_VERIFY_TOKEN="your_whatsapp_verify_token_here"
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Step>

  <Step title="Expose the server">
    Install ngrok and start a tunnel in another terminal. Keep it running and copy its public HTTPS URL:

    ```bash
    ngrok http 7777
    ```
  </Step>

  <Step title="Run the example">
    Save the code above as `reasoning_agent.py`, then run:

    ```bash
    python reasoning_agent.py
    ```
  </Step>

  <Step title="Register the webhook">
    Keep AgentOS and ngrok running. Follow [WhatsApp setup](/agent-os/interfaces/whatsapp/setup): set the callback to `https://<your-ngrok-url>/whatsapp/webhook`, use the same `WHATSAPP_VERIFY_TOKEN`, and subscribe to the `messages` field. Add and verify a test recipient when using Meta's test phone number, then message the bot.
  </Step>
</Steps>

Full source: [cookbook/05\_agent\_os/19\_whatsapp/reasoning\_agent.py](https://github.com/agno-agi/agno/blob/8f36eaf2d18e91afa7b327eec66a3cd3685dcb87/cookbook/05_agent_os/19_whatsapp/reasoning_agent.py)
