How to build AI agents: first agent, code, architecture, workflows, skills and projects

What AI agents are and how to build one, example code, architecture, workflows, projects, skills, context graphs, ChatGPT agent and VS Code tools.

Walking a room through the products he has shipped
Walking a room through the products he has shipped

Key takeaways

  • An AI agent is a model, a few well-described tools and a loop with limits and logging.
  • Write your first agent loop by hand before moving to LangGraph or an agent SDK.
  • Production architectures add memory, retrieval, guardrails, approvals and tracing.
  • Agent Skills package repeatable instructions and scripts that load only when relevant.
  • Context graphs help agents answer multi-hop questions that vector search alone misses.

An AI agent is a program in which a language model decides which tools to call, in what order, to reach a goal. Building one takes a model API, a few well-designed tools and a loop, plus guardrails and evaluation. I build AI products such as RAG.NextUpgrad and DocuLens AI, so this page covers what agents are and how to build one, a developer's first agent, example code, architecture, workflows, projects, skills, context graphs, ChatGPT agent and VS Code extensions.

What are AI agents, and how do you build one?

AI agents are systems where a language model plans and takes actions with tools, such as search, databases or APIs, to complete a goal. To build one, choose a model, define tools with clear schemas, write instructions, and run a loop that executes tool calls.

Also asked as: what are ai agents and how to build one

Start with a narrow, valuable task where success is easy to check, such as answering questions from your documentation with citations. Give the agent only the tools it needs, with descriptive names and parameter docs. Add step limits, error handling and logging from the start. Then build a small evaluation set of realistic tasks and measure completion rates before expanding scope. Frameworks help later, but understanding the basic loop first makes debugging far easier.

How do you build your first AI agent as a developer?

Pick one provider SDK, write two tool functions with JSON schemas, and implement the loop: send the goal and tools, execute any requested tool, append the result and repeat until the model returns a final answer or hits a step limit.

Also asked as: how to build your first ai agent: a practical guide for developers

A good first project is a research helper with a web search tool and a page-reading tool, which must return an answer with source links. Print every model message and tool call so you can see the reasoning path. Then add a test set of ten questions and track how many it answers correctly. Once that works, port it to a framework such as LangGraph or an agent SDK to compare what the framework handles for you.

What does example AI agent code look like?

Typical agent code has four parts: tool functions, such as get_weather or search_docs; tool schemas describing names, purposes and parameters; a messages list holding the conversation; and a while loop that calls the model and executes tool requests.

Inside the loop, the code checks whether the model's response contains a tool call. If so, it looks up the function by name, validates the arguments, runs it with error handling, and appends the result as a tool message. If not, the response is the final answer and the loop ends. A counter enforces a maximum number of steps. Official examples in the Anthropic and OpenAI SDK documentation show this pattern in Python and TypeScript.

What does an example AI agent architecture include?

A production agent architecture includes the model, a tool layer with permissions, an orchestrator running the loop, short-term memory for the current task, long-term memory or retrieval for knowledge, guardrails, human approval steps and observability through traces and metrics.

Common patterns include a single ReAct agent for focused tasks; a router that sends requests to specialised agents; and an orchestrator that splits work among worker agents and merges results. Tools often connect through the Model Context Protocol. Retrieval follows the same principles as RAG.NextUpgrad: hybrid search, reranking and citations. Store state in a database so runs can resume after failures, and keep secrets out of prompts by handling credentials in the tool layer.

What is an example AI agent workflow?

A support agent workflow: classify the incoming ticket, retrieve relevant help articles, look up the customer's order with a tool, draft a reply grounded in those sources, check it against policy, request human approval for refunds, then send and log the outcome.

Each step has clear inputs, outputs and failure handling. Classification routes simple questions to automatic replies and complex ones to humans. Retrieval with citations prevents invented policies. Policy checks catch replies that promise things the business cannot deliver. Logging every step lets the team review mistakes and improve prompts or tools. Many successful agents look like this: mostly structured workflow, with the model making focused decisions at specific points rather than controlling everything.

What is a good example AI agent project?

Good portfolio projects include a research agent that writes cited reports, a GitHub issue triage agent that labels and summarises issues, a meeting assistant that turns transcripts into tasks, and a document agent that answers questions over uploaded PDFs.

Choose a project with real users, even classmates or a club, and measurable success, such as correct labels or accepted answers. A document agent can build on OCR, as in my OCR & Speech Workspace, which uses Mistral OCR and document-scoped RAG with page citations. Include an evaluation report, a demo video and a README explaining design choices, failure cases and guardrails. Projects that show judgement about limits impress more than flashy demos without testing.

What is an example AI agent skill?

Agent Skills, introduced by Anthropic in 2025 and later published as an open format, are folders containing a SKILL.md file with a name, description and instructions, plus optional scripts and reference files that an agent loads only when relevant.

For example, a report-formatting skill might describe the company's document structure, include a template file and a script that checks headings, with a description saying when to use it. The agent sees only skill names and descriptions until a task matches, then reads the full instructions, which keeps context small. Skills package repeatable expertise, such as brand guidelines, data analysis procedures or code review checklists, so agents apply them consistently across tasks and teams.

Why do AI agents need context graphs?

Context graphs, or knowledge graphs, give agents structured knowledge about entities and their relationships, such as customers, orders, products and policies, so agents can reason across connected facts instead of searching disconnected text chunks.

Also asked as: why ai agents need context graphs (and how to build one with aws

Plain vector search finds similar passages but struggles with questions requiring multiple hops, such as which customers bought products affected by a recall. A graph stores these relationships explicitly, and agents can query it through tools. On AWS, teams often use Amazon Neptune for graph storage alongside vector search, combining both in GraphRAG patterns. Building one involves extracting entities and relations from data, defining a schema, keeping it updated and exposing safe query tools to the agent.

What is an example of ChatGPT agent?

ChatGPT agent mode lets ChatGPT complete multi-step tasks using a virtual browser, terminal and connectors, such as researching competitors and building a slide deck, comparing products across websites, or compiling information into a spreadsheet.

Also asked as: example chatgpt agent

For example, you might ask it to find three venues matching your requirements, compare reviews and availability, and summarise options in a table. It works step by step, showing progress, asks for confirmation before consequential actions, such as purchases or submitting forms, and hands control to you for logins or CAPTCHAs. Results still need checking, since it can misread pages. Availability and limits depend on your plan, so check OpenAI's help centre.

What are the best VS Code AI agent extensions?

Popular VS Code agent extensions include GitHub Copilot with agent mode, the Claude Code extension, OpenAI's Codex extension, Gemini Code Assist, and open-source agents such as Cline, Roo Code, Continue and Kilo Code.

They differ in model choice, pricing approach, autonomy and how they show changes. Copilot integrates tightly with GitHub and VS Code features. Open-source agents such as Cline let you bring your own API keys or local models through Ollama. Look for clear diffs, approval prompts before running terminal commands, checkpoint or undo support, and Model Context Protocol support for connecting tools. Try two on a real task in your repository before settling on one.

Sources

  1. Anthropic, Building effective agentsanthropic.com
  2. Anthropic, Agent Skills overviewdocs.anthropic.com
  3. OpenAI, Introducing ChatGPT agentopenai.com
  4. Model Context Protocolmodelcontextprotocol.io
  5. AWS, Amazon Neptuneaws.amazon.com
  6. Cline, repositorygithub.com
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way. Email pranjulrathour41@gmail.com.

Keep reading

More on Shipping AI apps

All Shipping AI apps guides →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way.

Pranjul Rathour, GenAI engineer in India