Experiment with AI Agents
Inspired by a company wide hackathon, I tried my hand in building an agentic system.
This was my straw-man problem statement:
Summary: An org structure and working model for a scalable business run by aligned AI agents — applied to real estate industry as an example
What problem(s) are we trying to solve ?
Context: As we grow economically, ageing population and slowing workforce growth are major problems to be tackled in the next decade. Foreign labour brings its own challenges. High labour cost also eats into the bottomline of businesses.
Specific problem:
Buyer persona:
- Property buying is a very serious decision we make in our lives. While a lot of data is available publicly, we still rely on advisors. We do not know if those advisor’s incentives are aligned with ours.
Real estate advisory business owner persona:
- The business relies on a lot of agents and is labour intensive. Business owners like to be more profitable.
What is the solution hypothesis ?
High level: We need to build businesses that can rely on cheap AI agents to offer services locally and globally
Specific: A real estate advisory company run by an entrepreneur and AI agents
Tech Stack: Crew AI for the agent orchestration, one of the LLMs + Web app stack
How will you measure if you are successful (hypothesis is validated) ?
Proxies for the below to be measured:
- Successful property transactions (Number of transactions per month)
- Happy customers (CSAT)
- Profit
- AI Alignment & safety
I realised that the creativity within the company was too high, there was a deluge of interesting problems and I could not get engineers to signup for this idea. 😔Alright I agree I am a bad product manager !!
To explore how this can move ahead, I tried my hand in building a small part of this system. Disclaimer: I left professional programming ~16 years back
I could write code for a system that will take this as an input:
'buyer_requirements': """ As a <redacted> with husband, wife, 2 kids and one helper I would like
look for a 3 bed condo around north east line near Punggol, Buangkok, Sengkang, Hougang MRTs that is more than 1200 squarefeet.
This is the most important criterion. Further - the following requirements should be considered.
My son is in <redacted> and studying at <redacted>, we would like to stay very near to this school or I will have
to change my son's school. My daugher studies in <redacted> in <redacted>. I would like to stay near
MRT station so that she can go to school easily. My budget is <redacted>, I am flexible for a good deal.
My wife does not like properties on the ground floor, patio or properties that are penthouses.
I want to make sure that the property in 10 or 15 years is a reasonably good investment as well"""
Will search google and scrape property sites. Used an API for scraping to avoid figuring out low level scraping issues and converted it to a tool in CrewAI. In fact the API also uses Gen AI internally for extracting data
from scrapegraph_py import Client
from scrapegraph_py.logger import sgai_logger
from crewai.tools import tool
@tool("my PropertyScraper Tool")
def myPropertyScraperTool(input_url: str) -> str:
"""Scrapes the proprty site url provided as argument and returns the property details in json format. The input string should be the exact url to be scraped"""
sgai_logger.set_logging(level="INFO")
# Initialize the client
sgai_client = Client(api_key="<redacted>")
# SmartScraper request
response = sgai_client.smartscraper(
website_url = input_url,
user_prompt="Extract property details including name, price, price_per_square_feet, number of beds, number of baths, other relevant details, url for property details page"
)
sgai_client.close()
# Print the response
print(f"Request ID: {response['request_id']}")
return (response['result'])
Coordinate the work by delegating to independent agents that use appropriate tools
real_estate_agency_crew = Crew(
agents=[property_listing_researcher,
property_listing_evaluator],
tasks=[listing_research_task,
listing_evaluation_task],
manager_llm=ChatOpenAI(model="gpt-4o-mini",
temperature=0.7),
process=Process.hierarchical,
verbose=True
)
And provides an output like this:
{
"properties": [
{
"match": "Excellent match",
"name": "The Luxurie",
"price": "S$ 1,750,000",
"price_per_square_feet": "S$ 1,658.77 psf",
"number_of_beds": 3,
"number_of_baths": 3,
"other_relevant_details": "2 min (200 m) from NE16 Sengkang MRT Station, Built: 2015, Condominium, 99-year Leasehold",
"url": "https://www.propertyguru.com.sg/listing/for-sale-the-luxurie-25484515"
},
{
"match": "Excellent match",
"name": "Esparina Residences",
"price": "S$ 2,180,000",
"price_per_square_feet": "S$ 1,300.72",
"number_of_beds": 3,
"number_of_baths": 2,
"other_details": "1,676 sqft, 4 min (360 m) from NE15 Buangkok MRT Station, Built: 2014, Executive Condominium, 99-year Leasehold",
"url": "https://www.propertyguru.com.sg/listing/for-sale-esparina-residences-25416656"
},
{
"match": "Good match",
"name": "Kovan Jewel",
"price": "S$ 2,421,800",
"price_per_square_feet": "S$ 2,122.52 psf",
"number_of_beds": 3,
"number_of_baths": 2,
"other_relevant_details": "New Project: 2025, Condominium, Freehold, 9 min (720 m) from NE13 Kovan MRT Station",
"url": "https://www.propertyguru.com.sg/listing/for-sale-kovan-jewel-25359104"
},
{
"match": "Good match",
"name": "Hundred Palms Residences",
"price": "S$ 1,888,000",
"price_per_square_feet": "S$ 1,898.27",
"number_of_beds": 3,
"number_of_baths": 3,
"other_relevant_details": "6 min (530 m) from CR9 Serangoon North MRT Station, Built: 2020, Executive Condominium, 99-year Leasehold",
"url": "https://www.propertyguru.com.sg/listing/for-sale-hundred-palms-residences-25426801"
}
]
}
Learnings
- Most of the logic can be written in plain english as instructions to agents
# Task for property_listing_researcher Agent: Search and extract property details
listing_evaluation_task = Task(
description=(
"Analyze the list of properties available to you by extracting relevant details from their urls"
"and decide if the property matches the criterion of the buyer based on ({buyer_requirements})"
"Note that the urls of property sites follow a structured format "
"Use the tools to gather content, get more details, extract details"
),
expected_output=(
"For each property available to you, a decision on how close the match is to the buyer's requirement."
"Classify the properties into - excellent match, good match, average match, bad match"
"Make sure that you copy over the url and other relvant details to the final list along with each property"
"Sort the list with excellent match followed by good match and so on..."
"We expect at least 5 listings that are excellent or good matches"
),
agent=property_listing_researcher,
async_execution=False
)
- The system is not deterministic. I could write deterministic code, but then I will have to fall back to the programming language and write more low level code (Irony: I used to code in assembly language and C when I was an engineer)
- As of now it is just a prototype for a part of the system. There is a huge chasm between a prototype to working product and from a working product to working business
- I believe that this can be improved and most tasks that rely on collecting data from the web and synthesising it will undergo some level of automation