AGENTS.md, not in code.
Overview
The setup has three parts:- AutonomousAgent with a workspace directory and one custom tool (
ocr_extract_text) - TelegramInterface in CHAT mode for conversational context
- Workspace files (
AGENTS.md,SOUL.md) that define the agent’s behavior and identity
Project Structure
Environment Variables
Installation
Usage
0.0.0.0:8000 and registers the Telegram webhook.
| Message | What happens |
|---|---|
| Photo of a receipt | OCR reads text, agent parses and saves to expenses.csv |
| ”summary” or “this month” | Agent reads CSV and returns category breakdown |
/reset | Clears conversation context |
How It Works
| Component | Role |
|---|---|
| AutonomousAgent | Reads workspace files, manages CSV, handles all logic |
ocr_extract_text | The only custom tool: EasyOCR reads receipt images |
| AGENTS.md | Defines receipt workflow, CSV format, duplicate rules, summary logic |
| SOUL.md | Agent identity and personality |
| TelegramInterface | Webhook-based chat with conversation memory |
Flow
- User sends a receipt photo in Telegram
- Agent calls
ocr_extract_text(auto-detects the image path) - Agent parses OCR output following rules in
AGENTS.md: converts dates, normalizes amounts, picks a category - Agent reads
expenses.csvto check for duplicates, then appends the new row - Agent replies with a short confirmation and monthly running total
Complete Implementation
main.py
tools.py
Workspace: AGENTS.md
The key to this example. Instead of hardcoding CSV logic in Python, the agent reads its instructions fromAGENTS.md:
- Receipt workflow: call OCR, parse output, check duplicates, save, confirm
- CSV schema: columns, types, format rules (dates as YYYY-MM-DD, amounts as floats)
- Summary logic: group by category, compute percentages, show totals
- Rules: always use
ocr_extract_textfor images, never delete data files
AGENTS.md. The agent adapts without touching code.
Notes
- OCR language is set to Turkish (
tr). Change thelanguagesparameter intools.pyfor other languages. - Install with
upsonic[ocr]to get EasyOCR and its dependencies. - The agent has full filesystem access within the workspace but no shell access (
enable_shelldefaults to disabled for this setup).

