Build your own AI agent (Medium)

A tool-calling agent that speaks JSON like real model APIs: search, memory, retries, a context window and a cost meter.

This is the shape of the OpenAI, Anthropic and Gemini tool APIs, and of LangChain-style agents: JSON calls, checked arguments, retrieval and budgets.

About 360 minutes across 10 stages. Skills: JSON tool calling, Schemas, Retrieval (RAG), Retries, Context window, Cost.

The guides are part of licode Club.

Stages

  1. Read the model's JSON reply.
  2. Run the tool calls and ask again.
  3. Check every argument before running a tool.
  4. Search the documents: the R in RAG.
  5. Handle many calls, missing ids and runaway models.
  6. Retry tools that fail for a moment.
  7. Give the agent long-term memory.
  8. Fold old messages to fit the context window.
  9. Add guardrails: switched-off tools and loop blocking.
  10. Count the words and the cost of every model call.