Foundations · Free preview

An LLM Is a Function

Text in, text out

A language model is a pure function: text in, text out. It can't take actions or remember on its own — an agent is what you build around it.

Text in, text out

People meet a chatbot and assume there's an entity behind the screen — something that remembers them, checks their calendar, sends the email it just promised to send. There isn't. Ask a raw model "weather tomorrow?" and it can't look outside; ask it "book it" and nothing gets booked. The same input always yields the same shaped output, and the moment the text comes back, the model forgets you exist.

At its core a language model is a pure function: text in, text out. No clock, no memory between calls, no hands. Think of it like reply = llm(prompt) — you hand it a string, it hands one back, and that's the entire contract. It's genuinely good at the text part: ask it the capital of France and it returns "Paris"; ask for live weather and the honest version says "I can reason about it, but I don't have live data." That last reply is the tell — the model knows the shape of an answer but has no channel to the world.

This matters because every capability you'll build rests on naming this boundary exactly. Memory, tool calls, multi-step plans — none of them live in the model. They're machinery you wrap around the function. Confuse the two and you'll spend hours asking a calculator why it can't remember your last sum.

Below is a stand-in llm() — a lookup table, but it behaves like the real thing: deterministic text-to-text. Loop over the three prompts and, for each, print a > <prompt> header line and then the model's reply. "Done" is three prompts, each echoed and answered.

The model only ever returns text. To make it act — remember, fetch, decide — you wrap it in a loop and give it tools. That loop is the very next station.

In the full academy, you write and run this — live, graded:

// A language model is a function: text in, text out. Here's a tiny stand-in.
function llm(prompt) {
  const replies = {
    "capital of France?": "The capital of France is Paris.",
    "2 + 2?": "2 + 2 = 4.",
    "weather tomorrow?": "I don't have live data, but I can reason about it.",
  };
  return replies[prompt] ?? "(no idea)";
}

const prompts = ["capital of France?", "2 + 2?", "weather tomorrow?"];

// TODO: for each prompt, print a line "> <prompt>" then the model's reply.

🔒 Live code execution, real agent runs, mastery tracking and verifiable credentials unlock with the full academy.

This is 1 of 50 lessons.

The full academy: write real code, watch real agents run, and earn verifiable credentials — across 8 tracks, in a 3D campus.

Unlock the full academy — $100 →

More free lessons: The Agent Loop  ·  Define a Tool  ·  Give an Agent a Tool  ·  Durable State

← The Agent Marketplace