How AI agents actually work: tokens, chat, LLMs, agent harnesses, and tools, explained from first principles.
An AI agent is an LLM plus a harness plus tools running in a loop, with the model deciding each next step.
A tool is a schema-described function the model can call by name, turning text output into real action.
An agent harness is the runtime around a model that assembles context, dispatches tools, and drives the working loop.
An LLM is a neural network trained to predict the next token, and that single mechanism is the engine every chat app and agent runs on.
A chat request is a stateless list of role-tagged messages, and your application owns the conversation history.
Tokens are the smallest units of text a language model reads or writes, and every context limit and price is measured in them.