TypeScript Agents: from Zero to Hero in 6 repo’s

typescript ai agents from zero to hero

Want to go superspeed from TypeScript Agent Zero to Agent Hero ?

This won’t make you a veteran developer, but it will show you what agents are basically about. I spent the last year coding agents and this is roughly the path I myself took. I missed that, last year. A short walkthrough, so you have an idea what agents are all about. This takes you in six repo’s from the simplest single agent, the chatbot, to an agent that learns and optimizes itself according to what the user wants (price/quality/speed).

What do you need ? Of course: Node.js (18+).

For the first four examples:

  • OpenAI API key
  • Jina (free tier)
  • DataForSEO (free $1 trial budget)
  • A WordPress blog (use Local if you don’t have a WordPress site)

For the last two, the learning systems:

  • Postgresql

The arc

The first three repos are basic TypeScript — no LangChain, no LangGraph, no Zod, no framework at all. Just fetch, async/await, and plain objects. If you can write a function, you can write these. They exist to show the ideas without the scaffolding. We start with a single agent, then multiple agents with a handoff, and a first orchestra.

By then we have a working SEO Article Blogger TypeScript Agent. We can give it a title, it will search Google and scrape pages, it will write an article based on these pages and publish it to WordPress.

Repo four wraps the same Agent in a LangGraph state graph. Same agents, same flow, but now it will also run on a platform like LangSmith that handles persistence, concurrency, and monitoring for you. This is your production on-ramp. LangGraph is a standard in Agent development, with a number of relative easy deployment options through LangSmith and Crewship for instance, or Cloudflare workers (as edge functions). Now we are writing ‘industry standard code’.

Repos five and six add the layer that makes an agent system seriously smart: : a database version that records every run, every cost, every mistake and uses stats for decisions. Repo five uses heuristics. Repo six is the contextual bandit, a more advanced version of a learning algorithm, that matches demand and supply better.

Once you have digested these six you can already start building a lot of business agents for your boss.

The bandit is a bit advanced, don’t worry if you don’t immediately see how it works. It was conceived in 2005 and applied by Yahoo in 2007 for the first time and increased their CTR x10. I used a similar algo in 1998 myself and sped up database matching x30. It is highly efficient. It may be a step too far, at once, that’s why I added step 5 in between, it’s easier to comprehend.

typescript ai agent

1. Single Agent

One file, one class, one prompt. The MiniAgent is 30 lines of TypeScript that calls an OpenAI-compatible API and returns JSON. That’s it. No dependencies beyond Node.js 18.

Just the basics of the TypeScript Agent.

Repo: https://github.com/juustesout/typescript-ai-agent-example

seo blogger ai agent in typescript

2. Multiple Agents with Handoff

Two agents that pass the baton. The researcher fetches SERP data and scrapes sources, then hands the raw material to the writer.

No orchestrator, no graph, no event bus. Just one agent awaiting another, like a relay race.

Multi-agent doesn’t have to mean it’s more complicated :)

Repo: https://github.com/juustesout/typescript-agent-with-handoff-seo-blogger

orchestrator ai agent pattern

3. Orchestrator

Now we’re cooking.

“Team!!! Team!!! Team!!!”

An orchestrator agent plans the work, delegates to workers, and knits their outputs together. The orchestrator decides which agents to call and in what order. This is the moment your system stops being a script and starts being an worker.

Repo: https://github.com/juustesout/typescript-agent-orchestrate-workflow

4. LangGraph Orchestrator

Same agents, same flow, but now modelled as a state graph with explicit nodes and conditional edges. The graph makes the workflow portable: you can run it locally, or deploy it to LangSmith or Cloudlfare.

Repo: https://github.com/juustesout/typescript-agent-example-langgraph

rule of thumb ai

5. Learning Agent with Database

Hre’s where it gets real. Memory. Every LLM call, every DataForSEO request, every cent spent is logged to PostgreSQL. After each run, an adaptive heuristic adjusts the next run’s parameters: deeper research if quality was high, fewer scrapes if costs ran away, more review passes if the draft got rejected. The system doesn’t just run — it watches itself run and gets better.

Repo: https://github.com/juustesout/typescript-learning-ai-agent

contextual bandit agent

6. Contextual Bandit

This is the endgame.

The rule-based heuristic from step 5 is replaced by a learned routing algorithm. The bandit models the workflow as a graph and chooses the optimal next node at every decision point, using historical edge statistics stored in PostgreSQL. Epsilon-greedy, UCB1, cold-start exploration, objective-relative utility weights — it’s a real learning system that adapts to your business goals.

Budget, speed, quality, balanced: pick one profile, and the bandit learns the optimal path that delivers it, just the way you want it.

Repo: https://github.com/juustesout/contextual-bandit-ai-agent-typescript

Why this matters

Almost every developer that ends up building an AI TypeScript Agent follows this arc. You start with a single prompt and it feels like magic. Then you realise one prompt can’t do everything, so you split responsibilities. Then you need an orchestrator because the handoff logic gets tangled. Then you need a graph framework because you want persistence and monitoring. Then you need a database because you’re flying blind without data. Then you need a learning algorithm because you’re tired of tuning parameters by hand.

Each step is a real problem that real developers hit. And each repo in this progression is a working solution you can clone, run, and adapt. They’re not toy examples — they’re the code I use to produce articles on my news blogs.

Where to start

If you’re new to Agents: start at repo 1, the basic TypeScript Agent, and work up. Each repo adds one new major concept. Clone it, run it, break it, delete it, clone it again, fix it. By the time you reach repo 6 you’ll understand more about production AI agents than most people talking about them on Youtube.

If you already have agents in production: jump to repo 5. The metrics layer will show you what your system is actually costing and how it’s performing — data you may not have today. Repo 6 is the ideal next step once you have enough history to learn from.

All code is MIT-licensed. Go clone it.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top