Telegram Reasoning Agent
ReasoningTools + DuckDuckGo search on Telegram
Code
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os.app import AgentOS
from agno.os.interfaces.telegram import Telegram
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.reasoning import ReasoningTools
agent_db = SqliteDb(db_file="tmp/persistent_memory.db")
reasoning_agent = Agent(
name="Reasoning Research Agent",
model=OpenAIChat(id="gpt-5.2"),
db=agent_db,
tools=[
ReasoningTools(add_instructions=True),
DuckDuckGoTools(),
],
instructions="Use tables to display data. When you use thinking tools, keep the thinking brief.",
add_datetime_to_context=True,
markdown=True,
)
agent_os = AgentOS(
agents=[reasoning_agent],
interfaces=[Telegram(agent=reasoning_agent)],
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="reasoning_agent:app", reload=True)Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet Environment Variables
Use this secret as secret_token when registering the public webhook in the setup guide. Keep the same value in the server and registration terminals. APP_ENV=development bypasses webhook authentication, so clear it for this public callback flow.
export TELEGRAM_TOKEN=your-bot-token-from-botfather
export OPENAI_API_KEY=your-openai-api-key
export TELEGRAM_WEBHOOK_SECRET_TOKEN=replace-with-a-long-random-secret
unset APP_ENVInstall dependencies
uv pip install -U "agno[os,telegram]" openai ddgsRun Example
python reasoning_agent.pyThe bot needs a public webhook URL to receive messages. See Telegram setup.
Key Features
- Chain-of-Thought Reasoning: ReasoningTools enables structured thinking for complex queries
- Web Search: DuckDuckGo integration for up-to-date information retrieval
- Data Presentation: Uses tables to display structured data
- Persistent Memory: SQLite database for session storage