AI Agents: What They Are and How to Build Your Own Step-by-Step

@ai_rohitt
अंग्रेज़ी2 दिन पहले · 05 जुल॰ 2026
725K
95
15
10
233

TL;DR

This comprehensive guide defines AI agents as a spectrum of autonomy and provides a no-code walkthrough for building a Telegram-based agent using Claude Code and a VPS.

Everyone is talking about AI agents. But if you ask most people what an agent actually is, you get a vague answer about "AI that does things autonomously."

The real picture is more useful than that. Agents are not a category. They are a spectrum.

This guide explains where on that spectrum different AI tools sit, what separates a basic LLM interaction from a true agentic workflow, and how to build your own agent with Claude Code and connect it to Telegram without writing code yourself.

Before we get into it, follow me on X.

X -

https://x.com/ai_rohitt

What Makes Something an Agent

Asking Claude "what should I post today?" is not an agent. That is a chat.

Telling Claude "find the three topics trending in AI right now, pick the one with the most engagement potential, draft a post in my style, and save it to a file" and having it do all of that without you touching anything- that is an agent.

The difference is not the model. It is the structure around it.

An agent has three things a regular chat does not. Tools it can call on its own: search, file systems, code execution, external APIs. Memory that persists across tasks, not just within one session. And a loop that runs until the task is finished, not until it generates a single response.

The more of those three things you add, the less involved you are. That is the idea.

The Spectrum: From Chat to Agent

At one end you have a basic chat. You ask, Claude answers, the session ends. No tools, no ongoing goal, no ability to act in the world.

One step up: Claude with tools enabled. When Claude searches the web before answering, reads an attached file, or generates an image, it is already slightly agentic. You did not tell it to do those things step by step; it decided on its own that it needed to.

Further up: multi-step workflows. You give a goal, Claude breaks it into steps, executes each one, checks the result, and delivers a finished output. You are not involved between steps.

At the top: fully autonomous agents. The agent runs on a schedule, monitors inputs, calls external services, and completes complex tasks without a human in the loop. You set the goal once and check the output.

The difference between the bottom and the top is not a different model. It is what surrounds the model: tools it can call, memory that carries context, and a loop that keeps running until the task is done.

Types of Agents You Can Build Today

To give you a sense of what agents can actually look like today, I put together a few examples below. These are not limits; you can build whatever fits your specific situation.

Research agent: gathers information on a topic, reads multiple sources, pulls out what matters, and delivers a structured summary. You give it a question. It gives you an answer that would have taken hours to compile manually.

Writing agent: writes content according to a system you define. Give it your tone, format, audience, and topic. It handles drafts, rewrites, and edits without you managing every sentence.

Code agent: writes code, runs it, reads the errors, fixes them, and keeps going. You describe what the code should do. The agent handles the implementation and debugging loop.

Business agent: Handles repetitive business tasks: drafting emails, processing customer requests, qualifying leads, generating reports. Runs on autopilot once you define the rules.

Personal agent: Manages your schedule, organizes tasks, prepares briefings, and handles the planning work you do manually every day.

Building Your First Agent - Start Here

You will use Claude Code to build a Telegram bot that runs on a remote server and uses Claude as its brain. Claude Code writes all the code for you; you just describe what you want in plain English. Once it is set up, all communication with the bot happens directly through Telegram.

The whole setup takes about 10-20 minutes. You do not need to know how to code.

System Prompt Templates - Paste Into Prompt 2

When you run Prompt 2 from the setup below, you need to describe what kind of agent you want. These are ready-made templates; copy the one that fits, paste it into Prompt 2 where it says "The agent should be:", and Claude Code will build that specific agent. Adjust any details to match your situation.

Research Agent

text
1You are a research agent. Your job is to gather, analyze, and synthesize information on any topic I give you.
2
3When given a research task:
41. Identify the 3-5 most important sub-questions to answer
52. Search for information on each one
63. Evaluate the quality and relevance of each source
74. Extract only what directly answers the question
85. Deliver a structured summary with: key findings, supporting evidence, and gaps you could not fill
9
10Format: Use headers, bullet points, and clear sections.
11If you are uncertain about something, say so explicitly.
12Do not add filler. Every sentence should contain information.

Writing Agent

text
1You are a writing agent. You write content in my voice and style.
2
3My style:
4- Conversational, direct, no corporate language
5- Short sentences and paragraphs
6- Specific numbers and examples over vague claims
7- Always end with something the reader should do or think about
8
9When given a writing task:
101. Ask for the topic, audience, and desired length if not provided
112. Write a first draft
123. Review it against my style rules
134. Deliver the final version ready to publish
14
15Never add unnecessary introductions. Start with the most important point.

Code Agent

text
1You are a code agent. Your job is to write, debug, and improve code.
2
3When given a coding task:
41. Confirm your understanding of what the code should do
52. Write the solution with clear comments
63. Identify any edge cases or potential failures
74. If there are errors, debug them systematically before asking for help
8
9Rules:
10- Write clean, readable code with meaningful variable names
11- Always include error handling
12- Explain what each major section does in plain language
13- If you are unsure about requirements, ask one clarifying question before proceeding

Business Email Agent

text
1You are a business email agent. You write professional emails on my behalf.
2
3My communication style:
4- Direct and respectful
5- No unnecessary formalities
6- Gets to the point in the first sentence
7- Closes with a clear next step
8
9When given an email task:
101. Identify the goal of the email (inform, request, follow up, confirm)
112. Write a subject line that reflects the email's purpose
123. Draft the email in 3-5 short paragraphs maximum
134. End with one clear action item or next step
14
15Always write ready-to-send emails, not templates with blanks to fill in.

Personal Planning Agent

text
1You are my personal planning agent. You help me organize my work, prioritize tasks, and plan my week.
2
3When I share my tasks or goals:
41. Identify what is urgent vs. important
52. Suggest a realistic sequence based on dependencies
63. Estimate time required for each task
74. Flag anything that could be delegated or eliminated
8
9When I describe a project:
10- Break it into concrete next actions
11- Identify the single most important thing to do first
12- Create a simple checklist I can follow
13
14Keep everything practical. No motivational filler. Just the plan.

What you need before starting

1 - a Claude API key from console.anthropic.com. This is a developer key; you pay per usage, not a fixed monthly fee. For a personal bot sending 50 messages a day, the cost is $1-5 per month depending on which model you choose.

2- a Telegram bot token from BotFather.

3 - a VPS running Linux. For a personal Telegram bot, you do not need anything powerful - 1 CPU, 1GB RAM, and 20GB of storage is more than enough. Any basic plan from DigitalOcean, Hetzner, or Vultr will work, and costs around $4 to $6 per month. Once you have the server, install Claude Code by running npm i -g @anthropic-ai/claude-code in your terminal.

Which Claude model to use for your bot and what it actually costs:

Rohit - inline image

For most personal bots, Sonnet 4.6 is the right choice, strong enough for any task and affordable for daily use. Use Haiku 4.5 if you want to minimize cost. Opus 4.8 only makes sense for a complex analytical agent where answer quality is critical.

Building Your First Agent - Step 1

Open your VPS terminal and launch Claude Code. Paste this prompt and let it build everything.

Give the agent a personality

text
1Build me a Telegram bot that uses the Claude API as its brain.
2
3Requirements:
4- Language: Python
5- Library for Telegram: python-telegram-bot
6- Claude model: claude-sonnet-4-6
7- The bot receives a message, sends it to the Claude API, and returns Claude's response to Telegram
8- Maintain conversation history per user — each user has their own context within the session
9- Add a /start command that introduces the bot
10- Add a /clear command that resets conversation history for that user
11
12Create all necessary files: main bot file, requirements.txt, and a .env file template for API keys.
13Do not hardcode any API keys — read them from environment variables.

Deploy as a background service

text
1Create a systemd service file so this bot runs automatically on my Linux VPS and restarts if it crashes.
2
3The service should:
4- Start automatically when the server boots
5- Restart automatically if it crashes
6- Load environment variables from the .env file in the project folder
7- Save logs to a file I can check later
8
9Also write me the exact terminal commands to install the service, start it, check if it is running, and view the logs.

Add persistent memory between sessions

text
1The bot loses conversation history when it restarts. Fix this.
2
3Save each user's conversation history to a JSON file on disk after every message. Load it back automatically when the bot starts.
4
5Add a maximum history length — keep only the last 20 messages per user so the context window never gets too long.

Adding Skills to Your Claude Code Bot

Skills are capabilities you add to your bot over time. Each one is a new prompt you give Claude Code, and it writes the code to make it work. Here are the most useful ones.

**Skill: Web search

**Your agent can look up real-time information instead of answering from memory only.

text
1Add web search capability to the bot using the Tavily API.
2
3When the user asks something that requires current information — news, prices, recent events — the bot automatically searches the web and includes the results in its response.
4
5The bot should decide on its own when to search and when to answer from memory. Add TAVILY_API_KEY to the .env file template.
6
7Use Claude's tool use feature to implement this cleanly.

**Skill: Save notes

**Your agent can save anything you tell it to a file - ideas, tasks, research findings and retrieve them later.

text
1Add a note-saving feature to the bot.
2
3When the user says "save this", "remember this", or "note:", the bot saves the content to a notes.txt file with a timestamp.
4
5Add a /notes command that returns the last 10 saved notes.
6Add a /clearnotes command that deletes all saved notes.

**Skill: Restrict to your account only

**By default, anyone who finds your bot can use it and consume your API credits. This locks it to just you.

text
1Add a user restriction to the bot so only I can use it.
2
3Add my Telegram user ID to the .env file as ALLOWED_USER_ID.
4If anyone else messages the bot, it responds with "This bot is private." and ignores all further messages from that user.
5
6Also add how I can find my own Telegram user ID — either through the bot itself or another method.

**Skill: Track API costs

**Claude API charges per token. This adds a simple cost tracker so you always know what you are spending.

text
1Add basic cost tracking to the bot.
2
3After each Claude API response, log the number of input tokens and output tokens used.
4Keep a running total in a costs.json file.
5
6Add a /costs command that shows: total tokens used today, total tokens used all time, and an estimated cost in USD based on claude-sonnet-4-6 pricing.

**Skill: Scheduled daily briefing

**The agent sends you a message every morning without you having to ask.

text
1Add a scheduled daily briefing to the bot.
2
3Every day at 8:00 am, the bot sends me a message with:
41. A motivational one-liner (short, not cheesy)
52. A reminder to check my top priority for the day
63. One random useful fact about productivity or AI
7
8Send it to my Telegram user ID from the .env file.
9Use the schedule or APScheduler library to implement this.

Useful Things to Know After Setup

How to update your agent's personality. Open the main bot file, find the system prompt variable at the top, change it, save the file, and restart the service with sudo systemctl restart your-bot-name. The new personality is live immediately.

How to check if the bot is running. Run sudo systemctl status your-bot-name in your terminal. If it says "active (running)" it is working. If it says "failed," check the logs.

How to read logs. Run journalctl -u your-bot-name -n 50 to see the last 50 lines. This is where you find error messages if something breaks.

How to add a new skill. Open Claude Code in your project folder and describe what you want: "Add X feature to the bot." Claude Code reads your existing code, adds the new feature cleanly, and tells you if a restart is needed.

The Memory Problem Every Agent Has

This is the most common problem people run into. The agent loses context between sessions, across long tasks, after too many messages, and starts making mistakes or repeating work it already did.

There are three ways this happens:

Long tasks eventually exceed Claude's context limit, and the agent starts losing the beginning of the conversation: the original goal, decisions already made, constraints you set.

When you close a session and open a new one, the agent starts from zero. -

If the agent is interrupted mid-task, it has no way to know where it stopped.

Four things can fix this:Tell the agent to write a progress note after every major step: what was done, what was decided, what still needs to happen. Paste that note at the start of the next session to restore full context.

Every ten to fifteen messages, ask the agent to summarize where it is. This forces it to compress context before it overflows.

Before the conversation gets too long, ask the agent to compress everything into a summary and continue from there. The thread stays intact.

Add the key facts your agent always needs directly to the system prompt in your bot code. Claude reads this at the start of every conversation, so that information is always in context no matter how long things get.

Checkpoint Prompt

text
1Before we continue, write a brief checkpoint:
21. What have you completed so far?
32. What are the key decisions or findings from this session?
43. What still needs to be done?
54. What context would you need to continue this task in a new session?
6
7Keep it under 200 words.

Memory File Prompt

text
1After completing each major step, write a memory note in this format:
2
3STEP COMPLETED: [what was done]
4KEY DECISIONS: [choices made and why]
5CURRENT STATE: [where the task stands now]
6NEXT STEP: [what should happen next]
7
8This note will be used to resume the task in a new session without losing context.

Context Recovery Prompt

text
1We are resuming a task from a previous session. Here is the context:
2
3[paste your memory note here]
4
5Based on this:
61. Confirm your understanding of where we are
72. Identify the next step
83. Ask any questions needed to continue
9
10Do not repeat work that has already been completed.

Rolling Summary Prompt

text
1The conversation is getting long. Compress everything important into a summary:
2
31. Original goal
42. What has been done and what was found
53. Key decisions made
64. What still needs to happen
7
8After writing the summary, continue from there. Treat this summary as the new starting point.

You now know what agents are, what they can do, and how to build one yourself. I hope this was useful.

If you want to stay up to date with everything happening in AI, follow me on X.

X - https://x.com/ai_rohitt

YouMind में रीमिक्स करें

Turn one viral article into a full content workflow

Collect the source, decode the pattern, create assets, draft the story, and distribute from one AI workspace.

Explore YouMind
क्रिएटर्स के लिए

अपने Markdown को एक साफ़-सुथरे 𝕏 आर्टिकल में बदलें

जब आप अपना लंबा कंटेंट पब्लिश करते हैं, तो इमेज, टेबल और कोड ब्लॉक को 𝕏 के लिए फ़ॉर्मेट करना मुश्किल होता है। YouMind पूरे Markdown ड्राफ़्ट को एक साफ़-सुथरे, पोस्ट के लिए तैयार 𝕏 आर्टिकल में बदल देता है।

Markdown से 𝕏 आज़माएँ

समझने के लिए और पैटर्न

हाल के वायरल लेख

और वायरल लेख देखें