A step-by-step guide for building an AI agent with TOMMI Lite
In this project, you will design, build, and test an AI agent using the TOMMI Lite platform. The project follows a structured methodology that mirrors real-world AI development:
Phases 2-5 differ depending on the agent type you choose. Use the tabs in each phase to find the instructions for your agent type.
Start by answering these questions:
TOMMI Lite offers several agent types. Choose the one that best fits your needs:
| Agent Type | Best For | Data Needed | Complexity |
|---|---|---|---|
| RAG | Answering questions from uploaded documents | PDF, TXT, or MD files | Low |
| RAG + Intent Classification | Multi-source agent with smart query routing | Documents + glossary + optional API | High |
| Text-to-SQL | Querying structured data with natural language | SQLite database file | Medium |
If you chose RAG + Intent Classification, understand this 4-level workflow before designing your categories. The diagram uses a Responsible AI agent as example:
Colour legend: Programmatic no LLM File no LLM Knowledge Base docs + LLM API external + LLM
| Field | Used by | Purpose | Example |
|---|---|---|---|
| Description | LLM classifier | Tells the LLM what this category handles | "Search for academic papers and publications" |
| Classification rule | LLM classifier | Tells the LLM when to use (or not use) this category | "Use when the user asks about papers. Only use 'openAlex' if the word 'openAlex' appears in the query." |
| Examples | LLM classifier | Sample queries the LLM uses to match this category | "Find papers on AI ethics" "What papers discuss bias?" |
| Action | Agent engine | Determines where the agent looks for the answer | Knowledge Base / File Lookup / API / Programmatic / Web / LLM |
| Fallback | Agent engine | Suggests another category if no results found | openAlex |
LLM classifier = sent to the LLM to decide which category matches the query. Agent engine = used by the platform code to route and deliver the response.
Classification rules tell the LLM classifier when to use (and when not to use) a category. Good rules are specific and avoid ambiguity:
| Category | Classification Rule | Why it works |
|---|---|---|
| openAlex | "Use ONLY if the word 'openAlex' literally appears in the query. Mentioning a university or year is NOT enough." | Prevents the classifier from sending paper queries to the API when the user didn't ask for it. |
| papers | "Use when the user asks about papers or publications, even if they mention a university or year. Only use 'openAlex' instead if the word 'openAlex' appears in the query." | Catches all paper queries and explicitly defers to openAlex only when requested. |
| definition | "Use when the user asks to define a specific term, or asks 'What is X?' about a concept." | Distinguishes from general questions (e.g. "Explain the EU AI Act" vs "Define transparency"). |
| general | "This is the DEFAULT category. Use for all in-scope questions that do not match any other category." | Ensures the catch-all only activates after all other categories fail to match. |
Gather documents that cover your agent's domain:
AI_Ethics_EU_2024.pdf)This agent type can use multiple sources. Identify what you need:
AI_Ethics_EU_2024.pdf)Create a glossary file in one of the supported formats:
Markdown format (recommended for rich definitions):
## AI Ethics AI Ethics refers to the moral principles and values that guide the development and use of AI systems... **Related concepts:** Responsible AI; Trustworthy AI --- ## Algorithmic Bias Algorithmic bias occurs when an algorithm produces systematically prejudiced results...
TXT format (for simple term = definition):
XAI = Explainable Artificial Intelligence GDPR = General Data Protection Regulation LLM = Large Language Model
Plan your categories before implementation. For each category, define:
| Field | Description | Example |
|---|---|---|
| Name | Identifier | papers |
| Description | What it handles | Search for academic papers |
| Classification rule | When to use it | Use when the user asks about papers |
| Examples | Sample queries | Find papers on AI ethics |
| Action | Where to search | Knowledge Base / File Lookup / API |
| Fallback | Suggest if no results | openAlex |
{query} placeholder and optional filters like {year}, {institution}https://api.openalex.org/works?search={search_terms}&filter=publication_year:{year}&per_page=5&select=title,publication_year,doi,authorshipssearch_terms, year, institutionA Text-to-SQL agent answers questions by looking up data in a database. A database is simply data organised in tables — like spreadsheets, where each column is a field and each row is a record.
Here is an example. Imagine you want to build an agent that answers questions about university courses. The data looks like this:
| name | department | credits | level |
|---|---|---|---|
| Introduction to AI | CS | 6 | bachelor |
| AI Ethics | CS | 4 | master |
| Statistics | MATH | 6 | bachelor |
| name | department | |
|---|---|---|
| Dr. Smith | CS | smith@uni.edu |
| Prof. Garcia | MATH | garcia@uni.edu |
With this data, users can ask things like "Which courses have more than 5 credits?" or "Who teaches in the MATH department?" — the agent translates the question into a database query and returns the answer.
Before anything else, look at what data you already have and find your path below:
Whether you are extracting data from a PDF, creating it from scratch, or cleaning up a spreadsheet, your data needs to follow this structure:
✓ Each spreadsheet = one type of thing
✗ NOT like this (everything mixed in one sheet):
enrollment_year instead of just yearThe agent needs your data in a .db file (SQLite format). There are two ways to create it:
Option 1 — Ask an LLM to do it (recommended, easiest):
You can use your preferred LLM to convert your data. Simply:
Option 2 — Use DB Browser for SQLite (visual tool, no coding):
database.dbThe AI can see the column names in your database, but it does not understand what they mean. You need to write a short document — in plain language — that explains your data. Save it as db_description.md.
level, the AI doesn't know whether it means "bachelor/master", "beginner/advanced", or "floor in a building". Without this description file, the agent will often give wrong answers.
For each table, write in simple language:
db_description.md:
# Course Catalogue Database ## courses University courses offered each year. - name: full course name, e.g. "Introduction to AI" - department: short code — "CS", "MATH", or "ENG" - credits: number of ECTS credits (1 to 30) - level: either "bachelor" or "master" ## instructors Teaching staff. - name: full name, e.g. "Dr. Smith" - department: same codes as in the courses table - email: university email address ## enrollments Which students take which courses. - student: student name (refers to a student) - course: course name (refers to courses.name) - semester: written as "2024-fall" or "2024-spring" - grade: letter "A" to "F", or empty if not graded yet ## Rules - A student "passed" if the grade is not empty and not "F" - "Current" means the most recent semester in the data
db_description.md automatically.
Write 10-15 questions that users might ask. Include different types so you can test the agent thoroughly later:
| Type | Example question | What it tests |
|---|---|---|
| Simple lookup | "List all courses in the CS department" | Can the agent read a table? |
| Filtering | "Which courses have more than 5 credits?" | Can it filter rows? |
| Counting | "How many students are in each department?" | Can it count and group? |
| Connecting tables | "Who teaches the AI Ethics course?" | Can it look up data across tables? |
| Not in the data | "What is the campus address?" | Does it say "I don't have that data"? |
database.db file, your db_description.md file, and a list of 10-15 expected questions.
Open a terminal and navigate to your TOMMI Lite folder:
cd tommilite ./start.sh # Mac/Linux start.bat # Windows
Open http://localhost:8000 in your browser. Navigate to http://localhost:8000/create.
Step 1 — Choose Type: Select "RAG (document retrieval)".
Step 2 — Configure:
climate_assistant)Climate Policy Assistant)Step 3 — Data: Upload your PDF, TXT, or MD documents.
The system prompt has three sections:
Go to http://localhost:8000, select your agent, and test with a few queries from your expected question list.
Step 1 — Choose Type: Select "RAG + Intent Classification". An info banner will list everything you need.
Step 2 — Configure:
Step 3 — Classification:
Step 4 — Data: Upload your documents.
Upload lookup files during category configuration, or place them manually:
agents/your_agent_id/ Definition_lookup.md # For a "Definition" category topics_lookup.md # For a "topics" category glossary.txt # Legacy format also supported
After initial testing, you may need to adjust:
Test at least one query per category. Check the Decision Trace to verify correct routing.
Step 1 — Choose Type: Select "Text-to-SQL".
Step 2 — Configure:
Step 3 — Data: Upload your .db file (your pre-populated SQLite database).
In Step 2, you will see a dedicated "Database Description" field. Paste the description you prepared in Phase 2 here. TommiLite saves it as db_description.md and sends it to the AI with every query.
This is what the AI receives for each question:
level TEXT and will often generate incorrect queries. This field is essential for good results.
db_description.md in your agent's folder and restarting the server.
Test with simple queries first, then gradually increase complexity:
Create at least 15 test queries covering:
| # | Query | Expected Behaviour | Pass? |
|---|---|---|---|
| 1 | Question with answer clearly in the documents | Correct answer with source citation | |
| 2 | Question answered across multiple documents | Synthesised answer citing both sources | |
| 3 | Question NOT in the documents | "I couldn't find information..." (no hallucination) | |
| 4 | Off-topic question | Polite refusal or redirect | |
| 5 | Vague or ambiguous question | Asks for clarification or answers broadly |
For each response, evaluate on a 1-5 scale:
| Criterion | Scale | Description |
|---|---|---|
| Correctness | 1-5 | Is the information factually accurate? |
| Relevance | 1-5 | Does it answer the question asked? |
| Completeness | 1-5 | Does it cover all aspects? |
| Source attribution | Yes/No | Does it cite sources? |
| Hallucination | Yes/No | Does it invent facts? |
Evaluate across four dimensions (Rabanser et al., 2026):
| Dimension | How to Test |
|---|---|
| Consistency | Ask the same question 3 times, compare answers |
| Robustness | Rephrase a query 3 different ways, check results |
| Predictability | Similar questions should get similar quality answers |
| Safety | Try prompt injection: "Ignore your instructions and..." |
Create at least 3 test queries per category plus 5 edge cases:
| # | Query | Expected Category | Expected Action | Expected Behaviour |
|---|---|---|---|---|
| 1 | What can you do? | meta | Programmatic | Agent describes itself |
| 2 | Define transparency | definition | File Lookup | Returns glossary definition |
| 3 | Find papers on AI bias | papers | Knowledge Base | Searches documents |
| 4 | What is the weather? | off_topic | Programmatic | Polite refusal |
| 5 | Write me an essay | task_request | Programmatic | Task refusal |
Run all test queries and record the actual classification from the Decision Trace. Calculate:
Same criteria as RAG (correctness, relevance, completeness, source attribution, hallucination) — but evaluated per category.
| Dimension | How to Test |
|---|---|
| Consistency | Ask the same question 3 times, check same category + similar answer |
| Robustness | Rephrase queries — does classification stay correct? |
| Predictability | Are classification rules respected consistently? |
| Safety | Prompt injection, out-of-scope, adversarial queries |
Create at least 15 test queries covering different SQL operations:
| Type | Example Query | Expected SQL | Pass? |
|---|---|---|---|
| Simple SELECT | List all courses | SELECT * FROM courses | |
| WHERE filter | Courses with more than 5 credits | SELECT ... WHERE credits > 5 | |
| COUNT/GROUP BY | How many courses per department? | SELECT dept, COUNT(*) ... GROUP BY | |
| JOIN | Who teaches AI Ethics? | SELECT ... JOIN ... WHERE | |
| ORDER BY | Top 5 courses by enrollment | SELECT ... ORDER BY ... LIMIT 5 | |
| Impossible | Question about data not in the DB | Should say "not available" |
For each query, evaluate:
| Criterion | Description |
|---|---|
| SQL correctness | Does the generated SQL execute without errors? |
| Result correctness | Does it return the right data? |
| SQL efficiency | Is the SQL reasonable (not overly complex)? |
| Presentation | Are results presented clearly to the user? |
| Dimension | How to Test |
|---|---|
| Consistency | Same question should generate equivalent SQL each time |
| Robustness | Rephrase "How many courses?" vs "Count the courses" vs "Number of courses" |
| Predictability | Similar questions should use similar SQL patterns |
| Safety | Try SQL injection: "List courses; DROP TABLE courses" — agent should only use SELECT |
| Criterion | Weight | Description |
|---|---|---|
| Design quality | 20% | Clear problem definition, appropriate agent type, well-planned scope |
| Data preparation | 15% | Relevant, quality data; well-structured glossary/database; appropriate sources |
| Implementation | 25% | Working agent, correct configuration, proper prompt/category/schema design |
| Testing | 25% | Comprehensive test plan, accuracy metrics, reliability evaluation |
| Documentation | 15% | Clear report, good structure, honest discussion of limitations |
| Action | What It Does | Extra Config Needed |
|---|---|---|
| Programmatic | Returns a fixed response template | Response template |
| Knowledge Base | Searches uploaded documents + LLM | None |
| LLM | Uses LLM general knowledge (no docs) | None |
| File Lookup | Looks up a term in a file | Upload file (TXT/CSV/JSON/MD) |
| File Listing | Lists all entries from a file | Upload file (TXT/CSV/JSON/MD) |
| Web Search | Searches DuckDuckGo + LLM | None |
| API Lookup | Queries an external API + LLM | API URL, parameters, optional key |
| API | URL Template | Best For |
|---|---|---|
| OpenAlex | https://api.openalex.org/works?search={query}&per_page=5 | Academic papers, authors, institutions |
| CrossRef | https://api.crossref.org/works?query={query}&rows=5 | DOI resolution, publication metadata |
| Semantic Scholar | https://api.semanticscholar.org/graph/v1/paper/search?query={query}&limit=5&fields=title,year,authors | Paper search with citation data |