Documentation Index
Fetch the complete documentation index at: https://polos.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Build an interactive chat agent that maintains conversation history.
from polos import Agent, max_steps, MaxStepsConfig
chat_assistant = Agent(
id="chat_assistant",
provider="openai",
model="gpt-4o-mini",
system_prompt="""You are a friendly assistant. You can:
- Tell the current time using get_current_time
- Get weather using get_weather
- Perform calculations using calculator""",
tools=[get_current_time, get_weather, calculator],
stop_conditions=[max_steps(MaxStepsConfig(limit=10))],
)
Maintain conversation context
# Use conversation_id to maintain history across messages
conversation_id = "user-123-session"
# First message
result1 = await chat_assistant.stream(
polos,
"What's the weather in Tokyo?",
conversation_id=conversation_id,
)
# Follow-up uses same context
result2 = await chat_assistant.stream(
polos,
"How about London?", # Agent remembers we're asking about weather
conversation_id=conversation_id,
)
Run it
git clone https://github.com/polos-dev/polos.git
cd polos/python-examples/04-conversational-chat
cp .env.example .env # Add your POLOS_PROJECT_ID and API key
uv sync
python main.py
Open http://localhost:5173 to view your agents and workflows, run them from the UI, and see execution traces.
Python example on GitHub | TypeScript example on GitHub