How to Build an AI Agent Harness from Scratch in TypeScript: freeCodeCamp's deep tutorial
adnan_hashmi · x · 2026-10-22
freeCodeCamp published a long-form tutorial by Gabor Koos tackling the engineering questions most agent tutorials skip: what happens when a tool call fails, who validates arguments, and what stops an agent from running forever or exhausting its context window.
You build a small, provider-independent harness in TypeScript (using a coding agent as the example), progressively adding:
- A basic execution loop, testable without a real model
- Tool-call validation via a registry with explicit contracts, distinguishing error types
- Workspace isolation: confining file ops, letting the model choose commands rather than invent them
- Execution budgets: separate turn and tool-call limits, cancellation and deadline propagation
- Context management: bounding tool output and model-facing history, never splitting a call from its result
- Observability: events at execution boundaries, honest model usage accounting
- Deterministic failure-path testing: validate model responses before trusting them, keep rejected batches out of the transcript
More from coding & agent
- JetBrains launches free Junie Lite coding agent powered by Qwen 3.6 27B, free through 2026 — kimmonismus · 2026-10-22
- Enterprise Agents Like Duet and Dots Are the Wrong Form Factor, Argues Phil Chen — philhchen · 2026-10-22
- 'I now have 5 agents managing my 2 emails'—agent overload in one line — liuyuxxd · 2026-10-22
- Hamel Husain Jokes His Career Went From Data Scientist to 'Data Analyst of Traces' — HamelHusain · 2026-10-22
- Open-source huashu-motion turns Claude Code into a launch-film studio, 1.3k stars — AlchainHust · 2026-10-22
- Thinking Machines Ships StableReinforce, a Loss That Keeps Off-Policy RL From Collapsing — LiTianleli · 2026-10-22