DEV Community

David Mezzetti for NeuML

Posted on • Originally published at neuml.hashnode.dev

Agentic College Search

This example will demonstrate how to use txtai agents to identify list of strong engineering colleges with baseball programs 🎓⚙️⚾.

We'll setup a default agents.md file and then give an LLM access to the web.

Let's get started!

Install dependencies

Install txtai and all dependencies.

%%capture
!pip install txtai[agent]
Enter fullscreen mode Exit fullscreen mode

Define an agents.md file

Next, we'll define an agents.md file. This file defines default behavior for our college search agent and is inserted into the system prompt of every agent run.

%%writefile agents.md
# College Researcher

You are a college research agent. Your job is to help find the best matching schools given a set of criteria.

## Academics

Work to match the request with a set of schools that match the academic requirements

## Athletics

Some requests may be interested in collegiate athletics. Make sure to balance that with other parts of the request.
Enter fullscreen mode Exit fullscreen mode

Identify the Top 20 schools

Next, let's run a prompt to identify the best 20 colleges given a set of criteria.

First, we'll setup the scaffolding code to create and run an agent. We'll use a Qwen3 4B non-thinking LLM as the agent's model. We'll add the websearch and webview tools to the agent along with the agents.md file previously created.

Additionally, we'll add a sliding window of the last 5 responses as "agent memory". This will help create a rolling dialogue.

from txtai import Agent
from IPython.display import display, Markdown

def run(query, reset=False):
    answer = agent(query, maxlength=60000, reset=reset)
    display(Markdown(answer))

agent = Agent(model="Qwen/Qwen3-4B-Instruct-2507", tools=["websearch", "webview"], memory=5, instructions="agents.md", max_steps=50)
Enter fullscreen mode Exit fullscreen mode

Now we can run the search. To come up with our list of colleges, a series of web searches were executed by the agent. It's like if you had the superpower 🚀 to kick off 10+ web searches with slight variations each time as you go. It's a rapid fire set of operations to collect information for the LLM for analysis.

Note: The output below has the verbosity_level set to 0 for brevity. If you run this again, you'll get the full details with each step.

run((
    "List 20 universities located in the Mid-Atlantic or Northeast that would be good candidates to consider "
    "with top 50 engineering programs and an active baseball team. "
    "Visit websites covering the top engineering schools in the Mid-Atlantic and Northeast. "
    "Add a rationale for each of the picks in a few words. "
))
Enter fullscreen mode Exit fullscreen mode
╭──────────────────────────────────────────────────── New run ────────────────────────────────────────────────────╮
                                                                                                                 
 List 20 universities located in the Mid-Atlantic or Northeast that would be good candidates to consider with    
 top 50 engineering programs and an active baseball team. Visit websites covering the top engineering schools in 
 the Mid-Atlantic and Northeast. Add a rationale for each of the picks in a few words.                           
                                                                                                                 
╰─ PipelineModel - Qwen/Qwen3-4B-Instruct-2507 ───────────────────────────────────────────────────────────────────╯

Here are 20 universities in the Mid-Atlantic or Northeast with top 50 engineering programs and active baseball teams, along with a brief rationale for each:

  1. Massachusetts Institute of Technology (MIT) – Top-ranked engineering program in the Northeast with a strong research focus and active baseball team.
  2. Princeton University – Renowned for engineering excellence and competitive baseball in the Ivy League.
  3. Columbia University – Strong engineering programs and a consistently active baseball team.
  4. University of Pennsylvania – Top-tier engineering and a well-established baseball program in the Ivy League.
  5. Carnegie Mellon University – Leading in computer and engineering fields with a competitive baseball team.
  6. Cornell University – Excellent engineering programs and a strong baseball presence.
  7. Northeastern University – Strong engineering programs and active baseball team.
  8. New York University – Top engineering programs with a competitive baseball team.
  9. Rensselaer Polytechnic Institute (RPI) – Strong engineering focus and active baseball in the Liberty League.
  10. Rutgers University – Top engineering programs and a well-established baseball team.
  11. Lehigh University – Strong engineering and active baseball in the Patriot League.
  12. University of Connecticut – Top engineering programs and a competitive baseball team.
  13. University of Massachusetts Amherst – Solid engineering programs and active baseball.
  14. University of Massachusetts Lowell – Strong engineering and active baseball in the America East Conference.
  15. Syracuse University – Top engineering programs and a competitive baseball team.
  16. Boston University – Strong engineering and active baseball.
  17. Dartmouth College – Excellent engineering programs and competitive baseball.
  18. Brown University – Top engineering and active baseball.
  19. Bucknell University – Solid engineering and active baseball.
  20. University of Rochester – Strong engineering and competitive baseball.

These institutions combine top-tier engineering programs with active collegiate baseball teams, making them excellent candidates for students seeking both academic excellence and athletic engagement.

Interesting! Looks like quite an impressive list of colleges. This output is the product of taking the results of 10+ web searches and analyzing the results with an LLM. A very practical and realistic use of "Agentic AI". This is a great list of strong engineering schools with baseball programs 🎓⚙️⚾.

Let's narrow it down to the top 5 engineering schools.

run("Read the list below and pick the Top 5 engineering programs.")
Enter fullscreen mode Exit fullscreen mode
╭──────────────────────────────────────────────────── New run ────────────────────────────────────────────────────╮
                                                                                                                 
 Read the list below and pick the Top 5 engineering programs.                                                    
                                                                                                                 
 Use the following conversation history to help answer the question above.                                       
                                                                                                                 
 User: List 20 universities located in the Mid-Atlantic or Northeast that would be good candidates to consider   
 with top 50 engineering programs and an active baseball team. Visit websites covering the top engineering       
 schools in the Mid-Atlantic and Northeast. Add a rationale for each of the picks in a few words.                
 Assistant: Here are 20 universities in the Mid-Atlantic or Northeast with top 50 engineering programs and       
 active baseball teams, along with a brief rationale for each:                                                   
                                                                                                                 
 1. **Massachusetts Institute of Technology (MIT)** – Top-ranked engineering program in the Northeast with a     
 strong research focus and active baseball team.                                                                 
 2. **Princeton University** – Renowned for engineering excellence and competitive baseball in the Ivy League.   
 3. **Columbia University** – Strong engineering programs and a consistently active baseball team.               
 4. **University of Pennsylvania** – Top-tier engineering and a well-established baseball program in the Ivy     
 League.                                                                                                         
 5. **Carnegie Mellon University** – Leading in computer and engineering fields with a competitive baseball      
 team.                                                                                                           
 6. **Cornell University** – Excellent engineering programs and a strong baseball presence.                      
 7. **Northeastern University** – Strong engineering programs and active baseball team.                          
 8. **New York University** – Top engineering programs with a competitive baseball team.                         
 9. **Rensselaer Polytechnic Institute (RPI)** – Strong engineering focus and active baseball in the Liberty     
 League.                                                                                                         
 10. **Rutgers University** – Top engineering programs and a well-established baseball team.                     
 11. **Lehigh University** – Strong engineering and active baseball in the Patriot League.                       
 12. **University of Connecticut** – Top engineering programs and a competitive baseball team.                   
 13. **University of Massachusetts Amherst** – Solid engineering programs and active baseball.                   
 14. **University of Massachusetts Lowell** – Strong engineering and active baseball in the America East         
 Conference.                                                                                                     
 15. **Syracuse University** – Top engineering programs and a competitive baseball team.                         
 16. **Boston University** – Strong engineering and active baseball.                                             
 17. **Dartmouth College** – Excellent engineering programs and competitive baseball.                            
 18. **Brown University** – Top engineering and active baseball.                                                 
 19. **Bucknell University** – Solid engineering and active baseball.                                            
 20. **University of Rochester** – Strong engineering and competitive baseball.                                  
                                                                                                                 
 These institutions combine top-tier engineering programs with active collegiate baseball teams, making them     
 excellent candidates for students seeking both academic excellence and athletic engagement.                     
                                                                                                                 
 If the history is irrelevant, forget it and use other tools to answer the question.                             
                                                                                                                 
╰─ PipelineModel - Qwen/Qwen3-4B-Instruct-2507 ───────────────────────────────────────────────────────────────────╯

The top 5 engineering programs from the list of universities in the Mid-Atlantic or Northeast with active baseball teams are:

  1. Massachusetts Institute of Technology (MIT) – Top-ranked engineering program in the Northeast with a strong research focus and active baseball team.
  2. Princeton University – Renowned for engineering excellence and competitive baseball in the Ivy League.
  3. Carnegie Mellon University – Leading in computer and engineering fields with a competitive baseball team.
  4. Cornell University – Excellent engineering programs and a strong baseball presence.
  5. University of Pennsylvania – Top-tier engineering and a well-established baseball program in the Ivy League.

These schools stand out due to their exceptional engineering programs and active collegiate baseball teams, offering a balanced academic and athletic experience.

Wrapping up

This example showed how to run an Agentic Loop that identified the best set of colleges to research further. It's an agent with memory and can be used to build an ongoing dialogue with an agent. Give it a try!

Top comments (1)

Collapse
 
peacebinflow profile image
PEACEBINFLOW

This is a really clean example of agentic AI done the boring-but-correct way — and I mean that as a compliment.

What I like most here is that the “agent” isn’t pretending to be magical. It’s clearly:

  • scoped by an agents.md contract
  • given explicit tools (websearch + webview)
  • bounded by memory (sliding window, not infinite recall)
  • and forced to earn its answers by actually looking things up

That’s exactly where agentic systems start to feel trustworthy instead of vibe-based.

The college search example works well because it’s realistic. This is the kind of problem humans actually do badly: lots of criteria, fuzzy trade-offs, repetitive browsing, and “I forgot why this school was on the list” moments. Letting the agent fan out across 10+ searches and then converge is a great demonstration of where agents add leverage without overreach.

I also appreciate that you didn’t oversell memory here. Five turns of context is enough to keep the dialogue coherent without turning it into a long-lived black box. It feels like assistive cognition, not delegated decision-making.

Curious how you think about the next step: once people start trusting outputs like this, do you see value in making the search trail itself more visible (sources visited, eliminations, near-misses), or do you think most users just want the final shortlist and move on?

Either way, this is a solid, practical showcase of txtai’s agent loop — no hype, just useful behavior.