For your convenience, all the code and instructions on how to run each Python script are provided in the following repository:
https://github.com/thomascherickal/ai-agents-examples
If you want to get the full hands-on experience, simply run the following command in the terminal:
git clone https://github.com/thomascherickal/ai-agents-examples.git
And follow the instructions in the README.MD to get started.
Linux is the best platform to do this, and you will need an OpenAI API key and other API keys as well.
Introduction to AI Agents
The year 2024 gave us powerful LLMs.
The year 2025 gave us AI Agents.
And if you are not paying attention, 2026 will leave you behind.
We are standing at the most significant inflection point in the history of knowledge work.
For the past two decades, digital workers have been defined by their ability to use tools—spreadsheets, databases, code editors, and communication platforms.
But a new class of workers has emerged that doesn’t just use tools.
They think, plan, execute, and learn autonomously.
They are called AI Agents, and they are about to transform every digital profession on the planet.
An AI Agent is not a chatbot.
A chatbot responds to prompts.
An AI Agent takes initiative.
It breaks down complex goals into steps.
It calls external APIs when needed.
It remembers context across sessions.
It corrects its own mistakes.
In essence, an AI Agent is an autonomous system that can perceive its environment, make decisions, and take actions to achieve specific objectives—without requiring constant human intervention.
Consider the difference this way: If you ask a chatbot to “write a quarterly report,” it will generate text based on its training data.
If you ask a high-quality AI Agent to do the same thing, it will first ask clarifying questions about which data sources to use.
It will connect to your CRM to fetch sales figures.
It will pull metrics from your analytics dashboard.
It will cross-reference with customer feedback databases.
It will synthesize everything into a coherent document, cite its sources, and ask if you want any revisions before finalizing.
The chatbot gives you a document.
The Agent gives you a complete workflow solution.
The implications of this shift cannot be overstated.
Every digital job that involves information gathering, analysis, synthesis, and document creation is a candidate for automation by AI Agents.
And unlike previous waves of automation that targeted manual labor, this wave targets cognitive work—the very thing that made human knowledge workers valuable in the first place.
This guide will take you from understanding what AI Agents are to building them yourself.
We will explore ten different agent frameworks, each one tackling a common office task with fully working code, and how to run them.
We will address the elephant in the room: hallucinations, and how to overcome them using modern tools like NotebookLM and Perplexity.ai.
And we will conclude with a provocative thesis:
Building AI Agents may be the only AI-safe job in the coming decade.
Are you ready to become obsolete, or are you ready to become an Agentic AI Engineer?
Why All Other Digital Jobs Will Fall to AI Agents in 2-5 Years
Let me make a prediction that will seem ridiculous today and obvious in three years:
Within five years, the concept of a “human-only” digital workforce will be as antiquated as the idea of a “human-only” manufacturing line is today.
Every company with more than fifty employees will have more AI Agents than human knowledge workers—and the humans will be there primarily to manage the agents.
The economics are irresistible.
A mid-level knowledge worker costs between eighty thousand and one hundred fifty thousand dollars annually when you factor in salary, benefits, training, overhead, and management time.
An AI Agent costs a fraction of that in API credits, runs twenty-four hours a day without burnout, never takes sick days, and improves with each update to the underlying models.
When an agent makes a mistake, you fix the system.
When a human makes a mistake, you have a conversation.
But cost is only part of the story.
The real advantage is speed and scale.
Imagine needing to analyze ten thousand customer support tickets to identify common complaints.
A human team of five might take a week to categorize and summarize everything, and will be prone to error and exhaustion.
An AI Agent system can process the entire dataset in minutes, categorize each ticket with consistent criteria, identify patterns across the entire corpus, and generate recommendations—all while you grab a coffee.
The two-to-five-year timeline is not arbitrary.
Here is why this decade matters so much.
First, the underlying language models are now good enough at reasoning and tool use to serve as the “brain” of autonomous agents.
Google Gemini 3.0, Claude 4.5 Opus, and their successors can follow complex instructions, admit uncertainty, and chain together multi-step reasoning.
Second, the tool ecosystems have matured.
Every major software platform now offers APIs that agents can call.
Third, developer tools have democratized.
You no longer need a PhD in machine learning to build an agent.
Fourth, enterprise adoption creates network effects.
As more companies deploy agents, the pressure to keep up becomes existential.
Let me be specific about which jobs are most vulnerable:
- Software development will see massive displacement of junior and mid-level programmers, but paradoxically, demand for agent engineers will explode.
- Data analysis will be transformed entirely—why pay an analyst to run queries when an agent can write the queries, execute them, visualize the results, and write the interpretation?
- Content creation will split between AI-generated drafts and high-touch human creative direction.
- Customer support will shift to agents handling tier-one inquiries, with humans escalating only the complex cases.
- Sales development will see agents qualifying leads, researching prospects, and even handling initial outreach.
- Even strategic functions like market research and competitive analysis will be augmented or replaced by agents that can synthesize information faster than any human team.
The survivors will be those who learn to build, direct, and refine AI Agents rather than compete with them.
This is not a prediction about technology capability.
It is a prediction about economics and competitive dynamics.
When your competitors can deliver results at one-tenth the cost and one-tenth the time, you either adapt or you disappear.
Guidelines: A Hands-On Approach to Building AI Agents
Before we dive into code, you need to understand the architecture of a production-ready AI Agent.
Building an agent is not just about connecting a language model to a prompt.
It requires careful design of several interconnected components that work together to achieve reliable autonomous behavior.
The first component is the Cognitive Loop
- This is the heart of any agent and follows a pattern that researchers call ReAct: Reason, Act, Observe.
- The agent receives a goal.
- It reasons about what to do next.
- It takes an action, usually calling a tool or API.
- It observes the result.
- Then it reasons about what to do based on that observation, and the cycle continues until the goal is complete.
- This loop is why agents can handle multi-step tasks that would overwhelm a simple chatbot.
The second component is Memory
- Without memory, every conversation starts from scratch.
- Agents need both short-term memory (the context window of the current conversation) and long-term memory (persistent storage of learned information).
- For long-term memory, vector databases have become the standard solution.
- When the agent needs to recall something, it converts the query to a vector embedding, searches the database for similar embeddings, and retrieves the relevant information.
- This allows agents to remember past interactions, learn from feedback, and maintain consistency across sessions.
The third component is Tooling
- An agent without tools is just a language model with expensive text generation.
- Tools extend an agent’s capabilities to interact with the real world.
- Common tool categories include web search for current information, API connectors for external services, database queries for structured data retrieval, file operations for document handling, and function calls for custom business logic.
- The key principle is that tools should be designed with clear inputs, outputs, and error conditions.
The fourth component is Planning
- Complex tasks require the agent to decompose goals into smaller steps and reason about the optimal sequence.
- This can be done through simple prompt engineering (ask the agent to create a plan), hierarchical decomposition (break tasks into subtasks), or explicit planning algorithms that maintain task state and dependencies.
When building your first agent, start simple.
- Define a narrow scope with clear success criteria.
- Implement the cognitive loop with basic tools.
- Add memory only when you need persistence.
- Test relentlessly with edge cases.
- And always have a human in the loop for sensitive operations.
Currently, the goal is not to replace humans (yet) but to augment them with reliable, autonomous assistants.
10 AI Agent Frameworks with 10 Different Common Office Tasks
This section forms the technical core of this guide.
For each framework, we will explore its philosophy, see it handle a realistic office task, and provide complete working code that you can run on your own machine.
1. LangChain — Document Summarization and Information Extraction
GitHub Link:
- LangChain has emerged as the most popular framework for building LLM-powered applications.
- Its agent system allows you to create chains of reasoning that can call various tools dynamically.
- What makes LangChain powerful is its extensive library of integrations with vector databases, APIs, and document loaders.
Office Task: Extracting Key Information from Meeting Transcripts
- Imagine you have hours of meeting transcripts and need to extract action items, decisions made, and questions raised.
- A human would need to read through everything carefully.
- A LangChain agent can process the document, identify relevant sections, and extract structured information automatically.
Source Code
import os
from langchain.agents import initialize_agent, AgentType
from langchain.chat_models import ChatOpenAI
from langchain.tools import Tool
from langchain.document_loaders import TextLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
# Initialize the language model
llm = ChatOpenAI(model="gpt-4", temperature=0)
# Load and prepare the document
loader = TextLoader("meeting_transcript.txt")
documents = loader.load()
text_splitter = RecursiveCharacterTextSplitter(
chunk_size=1000,
chunk_overlap=200
)
chunks = text_splitter.split_documents(documents)
# Define extraction prompt
extraction_prompt = PromptTemplate(
input_variables=["text"],
template="""Analyze the following meeting transcript and extract:
1. All action items with owners and deadlines
2. Key decisions made
3. Open questions that need follow-up
Transcript: {text}
Format your response as a structured markdown report."""
)
extraction_chain = LLMChain(llm=llm, prompt=extraction_prompt)
# Process each chunk and compile results
all_action_items = []
all_decisions = []
all_questions = []
for chunk in chunks:
result = extraction_chain.run({"text": chunk.page_content})
# Parse result into categories (simplified for demo)
print(f"Processed chunk {chunks.index(chunk) + 1}/{len(chunks)}")
# Generate final summary report
summary_prompt = PromptTemplate(
input_variables=["findings"],
template="""Compile all extracted findings into a single executive summary.
Findings:
{findings}
Create a clean, organized report with clear sections.""")
final_report = extraction_chain.run(
{"text": " ".join([c.page_content for c in chunks])}
)
print("\n=== EXTRACTED REPORT ===")
print(final_report)
# How to run this code:
# 1. pip install langchain openai
# 2. Set your OpenAI API key: os.environ["OPENAI_API_KEY"] = "your-key"
# 3. Save your transcript as "meeting_transcript.txt"
# 4. Run: python document_extractor.py
And do not forget to automate meeting transcripts with tools like Otter.ai or Fireflies.ai.
2. AutoGPT — Autonomous Internet Research
GitHub Link:
- AutoGPT made waves as one of the first truly autonomous agents that could pursue goals without continuous human guidance.
- It represents the “agentic” end of the spectrum—given a high-level objective, it creates its own task list and executes against it without prompting.
Office Task: Competitive Research and Market Analysis
- When you need to understand a competitor’s product strategy, AutoGPT can research across multiple sources, synthesize findings, and generate comprehensive reports without constant supervision.
Source Code
import os
import json
from auto_gpt_agent import AutoGPT
from auto_gpt_tools import SearchTool, FileTool, AnalysisTool
# Configure AutoGPT with your goals
goal = """Research Tesla's competitive position in the EV market as of 2024.
Include: market share data, product lineup comparison, pricing strategy,
technology advantages, and recent news. Create a comprehensive report."""
# Initialize the agent with tools
agent = AutoGPT(
name="MarketResearchAgent",
role="Expert market analyst specializing in automotive industry",
goals=[goal],
tools=[
SearchTool(),
FileTool(directory="./research_output"),
AnalysisTool()
],
api_key=os.environ.get("OPENAI_API_KEY")
)
# The agent will autonomously:
# 1. Break down the research goal into subtasks
# 2. Search for current market data
# 3. Analyze competitor websites and news
# 4. Compile findings into a structured report
# 5. Save results to local files
result = agent.run(max_iterations=50)
print("Research complete!")
print(f"Output saved to: ./research_output/final_report.md")
# How to run this code:
# 1. pip install auto-gpt
# 2. Set your API key in environment variables
# 3. Configure goals in the code above
# 4. Run: python autonomous_researcher.py
3. CrewAI — Multi-Agent Marketing Strategy Meeting
GitHub Link:
- CrewAI introduces a unique paradigm: multi-agent collaboration.
- Instead of a single agent working alone, you create a crew of agents with different roles who collaborate on complex tasks.
- This mirrors how human teams work together.
Office Task: Creating a Multi-Channel Marketing Campaign
- Marketing campaigns require multiple perspectives: market research, creative direction, budget planning, and channel strategy.
- CrewAI lets you create specialist agents for each role who collaborate to produce integrated campaigns.
Source Code
from crewai import Agent, Task, Crew, Process
from langchain.llms import OpenAI
# Initialize the language model
llm = OpenAI(model="gpt-4", temperature=0.7)
# Define specialized marketing agents
market_researcher = Agent(
role="Market Research Specialist",
goal="Uncover deep insights about target customers and market trends",
backstory="""You are an experienced market researcher who has
worked with Fortune 500 companies to launch successful products.
You excel at data analysis and trend identification.""",
llm=llm,
verbose=True
)
creative_director = Agent(
role="Creative Director",
goal="Develop compelling messaging and creative concepts",
backstory="""You have 15 years of experience in advertising,
having created campaigns for major brands. You have a gift
for finding the emotional core of any product.""",
llm=llm,
verbose=True
)
channel_strategist = Agent(
role="Digital Channel Strategist",
goal="Design optimal multi-channel distribution strategy",
backstory="""You are a digital marketing veteran who understands
the nuances of every platform from LinkedIn to TikTok.
You know which messages work where.""",
llm=llm,
verbose=True
)
# Define tasks for each agent
research_task = Task(
description="Research the SaaS project management tool market.",
expected_output="Comprehensive market analysis document",
agent=market_researcher
)
creative_task = Task(
description="Develop brand messaging and creative concepts",
expected_output="Campaign brief with messaging framework",
agent=creative_director
)
channel_task = Task(
description="Create a multi-channel marketing plan",
expected_output="Detailed channel strategy document",
agent=channel_strategist
)
# Assemble the crew
crew = Crew(
agents=[market_researcher, creative_director, channel_strategist],
tasks=[research_task, creative_task, channel_task],
process=Process.sequential,
verbose=True
)
# Execute the collaborative marketing project
result = crew.kickoff()
print("\n=== MARKETING CAMPAIGN OUTPUT ===")
print(result)
# How to run this code:
# 1. pip install crewai langchain openai
# 2. Set OPENAI_API_KEY in your environment
# 3. Run: python marketing_crew.py
4. Microsoft AutoGen — Coding Assistant and Debugging
GitHub Link:
- Microsoft’s AutoGen framework excels at creating conversational agents that can collaborate on complex problems.
- Its strength is multi-agent dialogue, where agents can debate, critique, and refine each other’s work.
Office Task: Pair Programming and Code Review
- AutoGen is particularly powerful for software development workflows.
- You can create a pair programming setup where one agent writes code and another reviews it, catching bugs and suggesting improvements before a human sees the code.
Source Code
import os
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager
from autogen.agentchat.contrib.gpt_assistant import GPTAssistantAgent
# Configure the coding agents
config_list = [{"model": "gpt-4", "api_key": os.environ.get("OPENAI_API_KEY")}]
# The code writer agent
coder = AssistantAgent(
name="SeniorCoder",
system_message="""You are a senior software engineer who writes
clean, well-documented Python code. You follow best practices,
include comprehensive docstrings, and handle edge cases.""",
llm_config={"config_list": config_list}
)
# The code reviewer agent
reviewer = AssistantAgent(
name="CodeReviewer",
system_message="""You are a meticulous code reviewer who catches
bugs, performance issues, security vulnerabilities, and style
violations. You suggest specific improvements with code examples.""",
llm_config={"config_list": config_list}
)
# Human oversight agent
human = UserProxyAgent(
name="HumanReviewer",
human_input_mode="TERMINATE",
max_consecutive_auto_reply=10
)
# Collaborative coding session
def write_feature_request(feature_description):
"""Orchestrate a collaborative coding session"""
# Coder writes the initial implementation
coder.initiate_chat(
reviewer,
message=f"""Please implement the following feature:
{feature_description}
Write complete, working Python code with tests.""",
summary_method="reflection_with_self_critique"
)
# Reviewer provides feedback
reviewer.send(
recipient=coder,
message="""I've reviewed your implementation. Please address
the following issues and provide an updated version.""",
silent=True
)
# Additional rounds of review until approved
# In production, this would loop until human approval
# Example: Build a data processing pipeline
write_feature_request(
"""Create a Python class that:
1. Reads CSV files with configurable delimiters
2. Validates data against a schema
3. Transforms data using user-defined functions
4. Exports to JSON with proper formatting"""
)
print("Code review complete. Final implementation ready for deployment.")
# How to run this code:
# 1. pip install pyautogen
# 2. Set OPENAI_API_KEY environment variable
# 3. Run: python pair_programming.py
5. LlamaIndex — RAG-Based Employee Handbook Q&A
GitHub Link:
- LlamaIndex specializes in Retrieval-Augmented Generation, the technique of grounding language model responses in specific documents.
- This makes it ideal for knowledge bases, documentation systems, and anything requiring factual accuracy.
Office Task: Building an HR Assistant for Employee Policy Questions
- Every company has an employee handbook that nobody reads.
- LlamaIndex can turn that handbook into an interactive Q&A system that answers policy questions with citations from the source document.
Source Code
import os
from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.tools import QueryEngineTool
from llama_index.agent import OpenAIAgent
from llama_index.query_engine import RetrieverQueryEngine
from llama_index.storage.storage_context import StorageContext
from llama_index.vector_stores import ChromaVectorStore
import chromadb
# Load employee handbook documents
documents = SimpleDirectoryReader("./handbook_docs").load_data()
# Create vector store for semantic search
chroma_client = chromadb.PersistentClient(path="./vector_db")
chroma_collection = chroma_client.create_group(name="employee_handbook")
vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
documents,
storage_context=storage_context,
show_progress=True
)
# Create query engine with source citation
query_engine = index.as_query_engine(
similarity_top_k=3,
response_mode="tree_summarize",
text_qa_template="""
You are a helpful HR assistant. Use the provided context
from the employee handbook to answer questions. Always cite
your sources by referencing the document sections.
Context: {context_str}
Question: {query_str}
"""
)
# Wrap in a tool for agent use
hr_tool = QueryEngineTool(
query_engine=query_engine,
name="hr_policy_search",
description="Search employee handbook for HR policy information"
)
# Create conversational agent
agent = OpenAIAgent.from_tools([hr_tool], verbose=True)
# Example conversation
conversations = [
"What is the vacation policy for new employees?",
"How do I submit expenses for reimbursement?",
"What are the remote work guidelines?",
"Can you explain the promotion review process?"
]
print("=== HR ASSISTANT SESSION ===\n")
for question in conversations:
print(f"Employee: {question}")
response = agent.chat(question)
print(f"HR Assistant: {response}\n")
print("-" * 50)
# How to run this code:
# 1. pip install llama-index chromadb
# 2. Create ./handbook_docs folder with PDF/TXT policy documents
# 3. Set OPENAI_API_KEY
# 4. Run: python hr_assistant.py
6. Phidata — Financial Data Analysis Assistant
GitHub Link:
- Phidata takes a minimalist approach to agent building, focusing on creating assistants that can reason about data and take actions.
- Its strength is in creating focused, task-specific agents that excel at their particular domain.
Office Task: Building a Financial Analysis Assistant
- Finance teams spend hours pulling data from multiple sources, calculating ratios, and building reports.
- A Phidata agent can automate much of this work, producing analysis-ready outputs with minimal human direction.
Source Code
import os
import yfinance as yf
import pandas as pd
from phidata.assistant import Assistant
from phidata.tools import FunctionTool
from phi.model.openai import OpenAIChat
# Define financial data functions
def get_stock_info(ticker: str) -> dict:
"""Get detailed stock information"""
stock = yf.Ticker(ticker)
info = stock.info
return {
"company_name": info.get("shortName"),
"current_price": info.get("currentPrice"),
"market_cap": info.get("marketCap"),
"pe_ratio": info.get("forwardPE"),
"dividend_yield": info.get("dividendYield"),
"fifty_two_week_high": info.get("fiftyTwoWeekHigh"),
"fifty_two_week_low": info.get("fiftyTwoWeekLow")
}
def compare_stocks(tickers: list) -> pd.DataFrame:
"""Compare multiple stocks side by side"""
data = []
for ticker in tickers:
info = get_stock_info(ticker)
info["ticker"] = ticker.upper()
data.append(info)
return pd.DataFrame(data)
def generate_analysis_report(stock_data: dict) -> str:
"""Generate investment analysis summary"""
analysis = []
for ticker, info in stock_data.items():
pe = info.get("pe_ratio", 0)
div = info.get("dividend_yield", 0)
if pe and pe < 20:
valuation = "potentially undervalued"
elif pe and pe > 30:
valuation = "potentially overvalued"
else:
valuation = "fairly valued"
analysis.append(f"""
{ticker.upper()} Analysis:
- Current valuation appears {valuation}
- P/E Ratio: {pe:.2f}
- Dividend Yield: {(div * 100):.2f}% if div else "N/A"
""")
return "\n".join(analysis)
# Initialize the financial assistant
financial_assistant = Assistant(
name="FinancialAnalyst",
model=OpenAIChat(id="gpt-4"),
description="I am a financial analysis assistant. I can fetch stock data, compare companies, and generate investment reports.",
tools=[
FunctionTool.from_function(get_stock_info),
FunctionTool.from_function(compare_stocks),
FunctionTool.from_function(generate_analysis_report)
],
show_tool_calls=True
)
# Example analysis session
financial_assistant.print_response("""
Compare Apple (AAPL), Microsoft (MSFT), and Google (GOOGL).
Which company appears most attractively valued based on P/E ratio?
""")
financial_assistant.print_response("""
Generate a comprehensive investment report for Tesla (TSLA)
and include recommendations based on current metrics.
""")
# How to run this code:
# 1. pip install phidata yfinance pandas openai
# 2. Set OPENAI_API_KEY environment variable
# 3. Run: python financial_assistant.py
7. OpenAI Assistants API — Calendar and Scheduling Management
GitHub Link:
- OpenAI’s Assistants API is a purpose-built solution for building AI assistants with persistent threads, built-in retrieval, and function calling capabilities.
- It abstracts away much of the infrastructure complexity.
Office Task: Intelligent Meeting Scheduler
- Scheduling meetings across multiple stakeholders is a classic coordination problem.
- An assistant built on the Assistants API can understand natural language requests, check calendars, find availability, and send invitations.
Source Code
import os
import time
from openai import OpenAI
# Initialize the client
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
# Create the scheduling assistant
assistant = client.beta.assistants.create(
name="MeetingScheduler",
instructions="""You are a professional scheduling assistant.
Help users schedule meetings by finding suitable times, checking
availability, and managing calendar conflicts. Be proactive about
suggesting alternatives when preferred times are unavailable.""",
model="gpt-4-turbo-preview",
tools=[
{
"type": "function",
"function": {
"name": "check_calendar_availability",
"description": "Check calendar for available time slots",
"parameters": {
"type": "object",
"properties": {
"date": {"type": "string", "description": "Date in YYYY-MM-DD format"},
"duration_minutes": {"type": "integer", "description": "Meeting duration"}
},
"required": ["date", "duration_minutes"]
}
}
},
{
"type": "function",
"function": {
"name": "send_calendar_invite",
"description": "Send calendar invitation to attendees",
"parameters": {
"type": "object",
"properties": {
"attendee_emails": {"type": "array", "items": {"type": "string"}},
"meeting_title": {"type": "string"},
"start_time": {"type": "string"},
"duration_minutes": {"type": "integer"}
},
"required": ["attendee_emails", "meeting_title", "start_time"]
}
}
}
]
)
# Create a new thread for the conversation
thread = client.beta.threads.create(
thread={"messages": []}
)
def schedule_meeting(user_request: str):
"""Handle a scheduling request"""
# Add user message to thread
client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=user_request
)
# Run the assistant
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id
)
# Poll for completion
while run.status in ["queued", "in_progress"]:
time.sleep(1)
run = client.beta.threads.runs.retrieve(thread_id=thread.id, run_id=run.id)
# Handle function calls if needed
if run.status == "requires_action":
# Function calling logic here
pass
# Display assistant response
messages = client.beta.threads.messages.list(thread_id=thread.id)
return messages.data[0].content[0].text.value
# Example scheduling conversations
print("=== SCHEDULING ASSISTANT ===\n")
response1 = schedule_meeting("Schedule a 1-hour meeting with the design team next Tuesday afternoon.")
print(f"User: Schedule a 1-hour meeting with the design team next Tuesday afternoon.")
print(f"Assistant: {response1}\n")
response2 = schedule_meeting("What times are available Thursday morning for a client demo?")
print(f"User: What times are available Thursday morning for a client demo?")
print(f"Assistant: {response2}\n")
# How to run this code:
# 1. pip install openai
# 2. Set OPENAI_API_KEY
# 3. Run: python scheduling_assistant.py
8. Haystack — Customer Support Ticket Classification
GitHub Link:
- Haystack is an open-source framework for building sophisticated search systems and question-answering applications.
- Its strength is in combining retrieval with generation for accurate, grounded responses.
Office Task: Intelligent Ticket Routing and Classification
- Customer support teams receive tickets across dozens of categories. Manual classification is slow and inconsistent.
- A Haystack-based system can automatically categorize tickets, suggest priority levels, and route them to the appropriate teams.
Source Code
import os
from haystack import Pipeline
from haystack.components.readers import ExtractiveReader
from haystack.components.retrievers import InMemoryBM25Retriever
from haystack.components.classifiers import TextClassificationClassifier
from haystack import Document
from haystack.document_stores.in_memory import InMemoryDocumentStore
# Define ticket categories
TICKET_CATEGORIES = [
"billing_issue",
"technical_bug",
"feature_request",
"account_access",
"general_inquiry",
"performance_complaint"
]
# Create training documents for classification
category_documents = [
Document(content="Billing discrepancy invoice wrong charge refund request", meta={"category": "billing_issue"}),
Document(content="Cannot login password reset not working account locked", meta={"category": "account_access"}),
Document(content="Application crashes error message freeze not responding", meta={"category": "technical_bug"}),
Document(content="Would like new integration API capability add feature", meta={"category": "feature_request"}),
Document(content="Slow performance page loading timeout response time", meta={"category": "performance_complaint"}),
Document(content="How to use product questions about functionality guide", meta={"category": "general_inquiry"}),
]
# Set up the document store
document_store = InMemoryDocumentStore()
document_store.write_documents(category_documents)
# Create the classification pipeline
pipeline = Pipeline()
# Add retriever for context
retriever = InMemoryBM25Retriever(document_store=document_store)
pipeline.add_component(instance=retriever, name="retriever")
# Add classifier
classifier = TextClassificationClassifier(
model="cross-encoder/nli-deberta-v3-small",
labels=TICKET_CATEGORIES
)
pipeline.add_component(instance=classifier, name="classifier")
# Add reader for additional context
reader = ExtractiveReader(model="distilbert-base-uncased-distilled-squad")
pipeline.add_component(instance=reader, name="reader")
# Connect components
pipeline.connect("retriever", "classifier")
pipeline.connect("retriever", "reader")
def classify_ticket(ticket_text: str, priority: str = "medium"):
"""Classify a support ticket and suggest routing"""
# Run classification
result = pipeline.run({
"retriever": {"query": ticket_text, "filters": None},
"classifier": {"text": ticket_text},
"reader": {"query": "What is the main issue?", "documents": []}
})
predicted_category = result["classifier"]["predictions"][0]
confidence = result["classifier"][" confidences"][0]
# Suggest routing based on category
routing_map = {
"billing_issue": "Finance Team - Response SLA: 4 hours",
"technical_bug": "Engineering Triage - Response SLA: 2 hours",
"feature_request": "Product Team - Response SLA: 24 hours",
"account_access": "Support Tier 1 - Response SLA: 1 hour",
"performance_complaint": "Engineering Priority - Response SLA: 2 hours",
"general_inquiry": "Support Tier 1 - Response SLA: 8 hours"
}
return {
"ticket_text": ticket_text,
"category": predicted_category,
"confidence": confidence,
"suggested_routing": routing_map.get(predicted_category, "General Support"),
"priority_suggestion": priority
}
# Example ticket classifications
tickets = [
"I was charged twice for my subscription this month. Please refund the duplicate charge.",
"The dashboard takes 30 seconds to load. This is unusable. Fix it now.",
"Can you add a dark mode to the application? It would really help my eyes.",
"I've tried to reset my password 5 times but the email never arrives. My account is [email protected]",
"Where can I find the documentation for the API endpoints?"
]
print("=== SUPPORT TICKET CLASSIFICATION ===\n")
for ticket in tickets:
result = classify_ticket(ticket)
print(f"Ticket: {ticket[:60]}...")
print(f"Category: {result['category']} (confidence: {result['confidence']:.2f})")
print(f"Route to: {result['suggested_routing']}")
print("-" * 50)
# How to run this code:
# 1. pip install farm-haystack[transformers,all]
# 2. Set OPENAI_API_KEY for classifier if needed
# 3. Run: python ticket_classifier.py
9. BabyAGI — Task List Prioritization and Execution
GitHub Link:
- BabyAGI demonstrates the power of task-driven agents.
- Given an objective, it automatically generates sub-tasks, prioritizes them, executes them, and creates new tasks based on results.
- It is minimalist but highly effective.
Office Task: Automated Project Management and Task Automation
- Project managers spend significant time tracking tasks, identifying dependencies, and prioritizing work.
- BabyAGI can automate much of this, creating an autonomous system that keeps projects moving forward.
Source Code
import os
from collections import deque
from typing import List, Tuple
from pydantic import BaseModel
from langchain import LLMChain, PromptTemplate
from langchain.llms import OpenAI
from langchain.vectorstores import FAISS
from langchain.embeddings import OpenAIEmbeddings
from langchain.schema import Document
# Define task structure
class Task(BaseModel):
task_id: int
name: str
status: str = "pending"
result: str = ""
# Initialize components
llm = OpenAI(model="gpt-4", temperature=0)
embedding_model = OpenAIEmbeddings()
vector_store = FAISS.from_texts(["Initial task memory"], embedding_model)
# Task generation prompt
task_generation_prompt = PromptTemplate(
input_variables=["objective", "result", "task_description"],
template="""You are a project management AI. Based on the original objective
and the result of the previous task, generate new tasks that need to be
completed to achieve the objective.
Original Objective: {objective}
Previous Task Result: {result}
Previous Task Description: {task_description}
Return a list of new tasks, one per line, in priority order."""
)
task_chain = LLMChain(llm=llm, prompt=task_generation_prompt)
# Task execution with result extraction
execution_prompt = PromptTemplate(
input_variables=["task", "context"],
template="""Execute the following task and provide a detailed result.
Task: {task}
Context: {context}
Result:""")
execution_chain = LLMChain(llm=llm, prompt=execution_prompt)
def babyagi(objective: str, initial_tasks: List[str]):
"""Execute BabyAGI workflow"""
task_queue = deque()
completed_tasks = []
# Initialize task queue
for i, task in enumerate(initial_tasks, 1):
task_queue.append(Task(task_id=i, name=task))
print(f"=== BABYAGI: {objective} ===\n")
iteration = 0
while task_queue and iteration < 20:
iteration += 1
current_task = task_queue.popleft()
current_task.status = "executing"
print(f"[{iteration}] Executing: {current_task.name}")
# Execute the task
context = "\n".join([f"- {t.name}: {t.result}" for t in completed_tasks[-5:]])
result = execution_chain.run({
"task": current_task.name,
"context": context or "No previous context"
})
current_task.result = result
current_task.status = "completed"
completed_tasks.append(current_task)
print(f" Result: {result[:100]}...")
# Generate new tasks based on result
new_tasks_text = task_chain.run({
"objective": objective,
"result": result,
"task_description": current_task.name
})
# Parse and add new tasks
new_tasks = [t.strip() for t in new_tasks_text.split("\n") if t.strip()]
for i, task_name in enumerate(new_tasks, len(task_queue) + 1):
task_queue.append(Task(task_id=i, name=task_name))
print(f" Added {len(new_tasks)} new tasks")
print(f" Queue size: {len(task_queue)}\n")
print(f"\n=== COMPLETED {len(completed_tasks)} TASKS ===")
return completed_tasks
# Example: Research and create a product launch plan
project_objective = "Research competitor pricing and create a product launch plan for a new SaaS product"
initial_tasks = [
"Identify top 5 competitors in the project management software space",
"Research each competitor's pricing model and features",
"Analyze market positioning and gaps",
"Define our unique value proposition",
"Create pricing strategy recommendation",
"Draft launch timeline with key milestones",
"Identify marketing channels and tactics"
]
completed = babyagi(project_objective, initial_tasks)
# Generate final summary
print("\n=== PROJECT SUMMARY ===")
for task in completed:
print(f"✓ {task.name}")
print(f" {task.result[:150]}...\n")
# How to run this code:
# 1. pip install langchain openai faiss-cpu
# 2. Set OPENAI_API_KEY
# 3. Run: python babyagi_project.py
10. Semantic Kernel — Email Drafting and Tone Adjustment
GitHub Link:
- Microsoft’s Semantic Kernel combines the power of language models with traditional software engineering patterns.
- It introduces concepts like plugins and planners that make it easy to build agents that can take actions in existing software systems.
Office Task: Intelligent Email Composition and Response System
- Every professional spends significant time on email.
- Semantic Kernel can help draft, revise, and personalize emails while maintaining an appropriate tone and ensuring that nothing is forgotten.
Source Code
import os
from semantic_kernel import Kernel
from semantic_kernel.contents import ChatHistory, TextContent
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.planning.basic_planner import BasicPlanner
# Initialize Semantic Kernel
kernel = Kernel()
kernel.add_service(OpenAIChatCompletion(service_id="chat", api_key=os.environ.get("OPENAI_API_KEY")))
# Define email composition skills
email_composition_prompt = """
You are a professional email writer. Compose an email based on the following parameters:
Recipient: {{$recipient}}
Subject: {{$subject}}
Tone: {{$tone}} (professional, friendly, urgent, apologetic, congratulatory)
Purpose: {{$purpose}}
Key Points to Include: {{$key_points}}
Requirements:
- Keep it concise and focused
- Include a clear call to action
- Match the specified tone
- Professional signature
"""
# Create email composition function
from semantic_kernel.functions import KernelFunction
compose_email = kernel.create_function_from_prompt(
prompt=email_composition_prompt,
function_name="compose_email",
description="Compose a professional email based on parameters"
)
# Define tone adjustment skill
tone_adjustment_prompt = """
Rewrite the following email to match the specified tone while preserving all key information.
Original Email:
{{$original_email}}
Desired Tone: {{$desired_tone}}
Rewritten Email:"""
adjust_tone = kernel.create_function_from_prompt(
prompt=tone_adjustment_prompt,
function_name="adjust_tone",
description="Adjust the tone of an email"
)
# Example email compositions
def generate_draft_email(recipient, subject, purpose, key_points, tone="professional"):
"""Generate a professional email draft"""
result = kernel.run(
compose_email,
input_text={
"recipient": recipient,
"subject": subject,
"tone": tone,
"purpose": purpose,
"key_points": key_points
}
)
return result.value[0].text
def adjust_email_tone(original_email, desired_tone):
"""Adjust the tone of an existing email"""
result = kernel.run(
adjust_tone,
input_text={
"original_email": original_email,
"desired_tone": desired_tone
}
)
return result.value[0].text
print("=== SEMANTIC KERNEL EMAIL ASSISTANT ===\n")
# Generate different email types
emails = [
{
"recipient": "[email protected]",
"subject": "Project Update - Q4 Deliverables",
"purpose": "Provide update on project milestones and next steps",
"key_points": "On track for deadline, two features completed, one in progress, meeting scheduled for review",
"tone": "professional"
},
{
"recipient": "[email protected]",
"subject": "Great News - Sales Target Exceeded!",
"purpose": "Celebrate team achievement and motivate continued effort",
"key_points": "120% of target reached, specific contributor mentions, optional celebration event",
"tone": "congratulatory"
}
]
for i, email_params in enumerate(emails, 1):
print(f"--- Email {i}: {email_params['tone'].title()} Tone ---")
draft = generate_draft_email(**email_params)
print(draft)
print("-" * 60 + "\n")
# Demonstrate tone adjustment
original = """Hey,
Sorry I'm late sending this. Kinda forgot about it. Maybe we can talk later?
-Bob"""
print("--- Tone Adjustment Demo ---")
print("Original (casual):")
print(original)
print("\nAdjusted (formal):")
formal_email = adjust_email_tone(original, "formal and apologetic")
print(formal_email)
# How to run this code:
# 1. pip install semantic-kernel
# 2. Set OPENAI_API_KEY
# 3. Run: python email_assistant.py
How to Overcome Hallucinations with NotebookLM and Perplexity.ai
Hallucinations are the Achilles’ heel of large language models.
When a model confidently states something that is completely false, it undermines trust in the entire system.
For agent systems that take autonomous actions, hallucinations can be costly or even dangerous.
Fortunately, new tools have emerged that help ground AI responses in factual sources.
NotebookLM
NotebookLM, Google’s AI-powered research and writing assistant, takes a fundamentally different approach to the hallucination problem.
You can read more about NotebookLM here:
The Internet Can’t Stop Talking About Google NotebookLM | HackerNoon
Instead of relying on the model’s training data alone, NotebookLM allows you to upload your own sources—PDFs, Google Docs, websites, and notes—and asks the model to generate responses that are explicitly grounded in those sources.
When you ask a question, NotebookLM searches your uploaded documents, finds relevant passages, and cites them directly in its response.
The model is constrained to discuss information present only in your sources, dramatically reducing hallucinations.
For agent builders, this approach is revolutionary.
You can build an agent that is an expert on your company’s internal documentation, your industry’s regulations, or any specific knowledge domain—and it will only say things it can verify from the provided materials.
Perplexity.ai
Perplexity.ai approaches the problem from a different angle: real-time information retrieval.
You can read more about Perplexity here:
Perplexity.ai - The New King of Search | HackerNoon
While language models are trained on static datasets that quickly become outdated, Perplexity searches the live web to answer questions with current information.
Each response includes citations to the specific web pages that supported the answer.
This makes Perplexity invaluable for fact-checking agent outputs and ensuring that claims about current events, recent research, or live services are accurate.
When building agents that need to access current information, using Perplexity as a verification layer can catch outdated or incorrect claims before they cause problems.
The most robust approach combines both strategies.
Use NotebookLM-style source grounding for domain-specific knowledge where you control the documents.
Use Perplexity-style web verification for claims about current events, market data, or factual information that changes over time.
Build your agent to explicitly cite sources for every factual claim, making it easy to verify accuracy.
And implement a confidence scoring system that flags statements made without supporting sources for human review.
The goal is not to eliminate hallucinations entirely—that may be mathematically impossible with current transformer architectures.
The goal is to build systems where hallucinations are the exception rather than the norm, where they are easily detected when they occur, and where their impact is limited because humans remain in the loop for consequential decisions.
Conclusion — Why Building AI Agents is the Only AI-Safe Job in the Future
We have covered a tremendous amount of ground in this guide.
You now understand what AI Agents are and why they represent such a fundamental shift in the nature of digital work.
You have seen the economic forces that will drive agent adoption across every industry in the coming years.
You have learned the architectural principles that underlie all successful agent systems.
You have examined ten different frameworks, each with working code for common office tasks.
And you have learned strategies for addressing the hallucination problem that limits current AI systems.
But the most important thing you can take away from this guide is this: The future belongs to the builders.
When automation threatens jobs, the people who design, build, and maintain the automated systems are always the last to be affected.
During the Industrial Revolution, the craftspeople who could operate the new machines were in higher demand than those they replaced.
During the Software Revolution, the engineers who built the systems that automated clerical work were never at risk of being automated themselves.
And in this coming Agent Revolution, the Agent Engineers, the AI Architects, and the Automation Strategists will be the most valuable professionals in any organization.
This is not a future to fear.
It is a future to embrace.
The agents you build will make knowledge workers more productive, freeing humans from repetitive cognitive tasks and enabling them to focus on creative, strategic, and interpersonal work that machines cannot replicate.
The automation you create will eliminate drudgery, allowing professionals to do the meaningful parts of their jobs without getting bogged down in administrative overhead.
But only if you start building today.
The frameworks are ready.
The APIs are available.
The use cases are everywhere around you.
Your company has processes that could be automated.
Your team has tasks that could be agent-assisted.
Your own work has repetitive elements that could be delegated to a well-designed system.
The question is not whether AI Agents will transform knowledge work.
That is already happening.
The question is whether you will be a passive observer of this transformation or an active participant shaping its direction.
Pick a framework.
Start with a simple task.
Build something small.
Watch it work.
Then build something bigger.
Iterate.
Learn.
Share what you discover with others.
The community of Agent Builders is growing every day, and there is plenty of room for everyone who wants to participate.
The agents of tomorrow are being designed today.
Make sure you are one of the architects.
The future is autonomous.
And it is yours to build.
Knowledge of Rust is preferable to Python, but you can always pick up Rust.
If you are having difficulty with Rust, you can go through the article below:
Here's How You Can Use AI to Teach You Rust - 15 Projects To Impress MAANG Recruiters | HackerNoon
Agents are the future - embrace AI agents today and gain a strategic advantage!
References and Further Reading
-
https://github.com/langchain-ai/langchain
The official GitHub repository for LangChain, one of the most popular frameworks for building LLM-powered applications with extensive integration support for vector databases, APIs, and document loaders. LangChain enables developers to create chains of reasoning that can call various tools dynamically.
-
https://github.com/Significant-Gravitas/AutoGPT
AutoGPT’s official repository, an experimental open-source platform that creates and deploys autonomous agents capable of pursuing goals without continuous human guidance. AutoGPT provides tools for building self-directed agents that can break down complex tasks and execute them autonomously.
-
https://github.com/crewAIInc/crewAI
CrewAI’s GitHub repository, a lean Python framework built from scratch for orchestrating role-playing autonomous AI agents that foster collaborative intelligence. CrewAI allows developers to create multi-agent teams with specialized roles working together seamlessly.
-
https://www.crewai.com/open-source
The official CrewAI open-source website providing documentation, examples, and resources for building AI agent crews. This site offers comprehensive guides on creating multi-agent systems with memory management, tools integration, and agentic RAG implementations.
-
https://github.com/microsoft/autogen
Microsoft’s AutoGen repository, a programming framework for building agentic AI applications that enable multi-agent conversations and collaboration. AutoGen provides customizable agents that can work together to solve tasks autonomously or with human feedback.
-
https://microsoft.github.io/autogen/stable/index.html
Official documentation for Microsoft AutoGen covering the framework’s architecture, agent development, multi-agent systems, and plugin ecosystem. The documentation includes tutorials on building conversational agents and complex multi-agent workflows.
-
https://github.com/run-llama/llama_index
LlamaIndex’s official repository, a leading framework for building LLM-powered agents over structured and unstructured data. LlamaIndex specializes in retrieval-augmented generation (RAG) with extensive support for vector databases and document processing.
-
https://www.llamaindex.ai/
LlamaIndex’s official website showcasing their developer-first agent framework with industry-leading document parsing capabilities. The platform offers both open-source tools and enterprise-grade LlamaCloud services for production-ready AI applications.
-
https://github.com/phidatahq/phidata
Phidata’s GitHub repository (now rebranded as Agno), a framework for building multi-modal agents with memory, knowledge, tools, and reasoning capabilities. Phidata emphasizes simplicity and provides beautiful Agent UI for interaction and monitoring.
-
https://www.phidata.com/
The official Phidata/Agno website featuring their AgentOS platform for building, deploying, and managing multi-agent systems. The site includes comprehensive documentation on creating agents with advanced features like workflow orchestration and team collaboration.
-
https://github.com/yoheinakajima/babyagi
BabyAGI’s official repository, an experimental framework for self-building autonomous agents that introduced task planning as a core method for agent development. BabyAGI demonstrates minimalist agent architecture with automatic task generation and prioritization.
-
https://github.com/yoheinakajima/babyagi_archive
The archived version of the original BabyAGI (March 2023), preserved as a snapshot showing the evolution of autonomous task-driven agents. This repository contains the pared-down 140-line implementation that sparked widespread interest in autonomous AI systems.
-
https://github.com/microsoft/semantic-kernel
Microsoft Semantic Kernel’s repository, a model-agnostic SDK for building, orchestrating, and deploying AI agents and multi-agent systems. Semantic Kernel provides enterprise-grade tools with support for multiple programming languages and extensive LLM integrations.
-
https://learn.microsoft.com/en-us/semantic-kernel/get-started/detailed-samples
Microsoft Learn’s in-depth Semantic Kernel documentation with comprehensive samples demonstrating advanced SDK features. The documentation covers plugins, planners, memory systems, and integration patterns across C#, Python, and Java implementations.
-
https://github.com/deepset-ai/haystack
Haystack’s official repository by deepset, an AI orchestration framework for building customizable production-ready LLM applications. Haystack excels at retrieval-augmented generation, question answering, and semantic search with advanced component pipelines.
-
https://haystack.deepset.ai/
Haystack’s official documentation website providing comprehensive guides on building RAG applications, agent systems, and document search solutions. The site includes tutorials, cookbooks, and integration guides for various vector databases and LLM providers.
-
https://notebooklm.google.com/
Google NotebookLM’s official platform, an AI-powered research and note-taking tool that uses Google’s Gemini models to ground responses in user-uploaded sources. NotebookLM reduces hallucinations by constraining AI responses to cite only from provided documents, PDFs, websites, and videos.
-
https://www.perplexity.ai/
Perplexity AI’s main website, a free AI-powered answer engine providing accurate real-time answers with source citations. Perplexity uses advanced LLMs combined with live web search to deliver up-to-date information while explicitly citing sources.
-
https://research.perplexity.ai/
Perplexity Research’s dedicated site advancing frontier research in search, reasoning, agents, and systems. The platform handles 200+ million daily queries using hybrid retrieval and intelligent context curation for AI models
-
https://docs.crewai.com/
CrewAI’s comprehensive documentation covering agent creation, crews orchestration, flows management, and enterprise deployment. The documentation includes guides on tool integration, memory systems, knowledge bases, and multi-channel automation workflows.
-
https://github.com/crewAIInc/crewAI-examples
A collection of complete CrewAI application examples showcasing real-world implementations of multi-agent frameworks. Examples include content creation flows, email automation, lead scoring systems, and integration patterns with other frameworks.
-
https://microsoft.github.io/autogen/0.2/
AutoGen 0.2 documentation covering the framework’s multi-agent conversation capabilities and workflow orchestration features. This version provides comprehensive guides on building conversational agents with customizable autonomy levels.
-
https://github.com/run-llama/create-llama
Create-llama CLI tool repository for quickly scaffolding new LlamaIndex applications with pre-configured use cases. The tool generates full-stack applications with agentic RAG, data analysis, and report generation capabilities.
-
https://github.com/deepset-ai/haystack-cookbook
A collection of Haystack example notebooks demonstrating various model providers, vector databases, and retrieval techniques. The cookbook provides practical implementations for specific features and integration patterns.
-
https://github.com/microsoft/SemanticKernelCookBook
Semantic Kernel’s comprehensive cookbook for beginners with examples across .NET, Python, and Java. The guide covers plugins, planners, embeddings, RAG applications, and integration with Azure OpenAI Service.
-
https://devblogs.microsoft.com/dotnet/github-ai-models-dotnet-semantic-kernel/
Microsoft’s official blog post explaining how to integrate GitHub’s AI models with Semantic Kernel in .NET applications. The tutorial covers setup, configuration, and practical examples for building intelligent applications.
-
https://en.wikipedia.org/wiki/NotebookLM
Wikipedia article providing comprehensive background on Google NotebookLM’s development history, features, and evolution. The article covers Audio Overviews, interactive capabilities, NotebookLM Plus tier, and integration with Google’s Gemini models.
-
https://en.wikipedia.org/wiki/Perplexity_AI
Wikipedia entry detailing Perplexity AI’s company background, products, funding history, and legal controversies. The article explains Perplexity’s search API, Shopping Hub, finance features, and valuation milestones.
All images were AI-generated by NightCafe Studio.
MiniMax.ai was used for the research in this article.
I find it better than Google Gemini Pro 3.0!