Part 1

One call later, where’s my coffee?

Ada wants to know when her hand grinder will arrive. I sent her order number to the model twice. Both times it asked her to look up the parcel herself.

Phillipp Bertram5 min read
  • AI agents
  • TypeScript
  • Hands-on
Ada's question about order A-1042 as a paper speech bubble. Below it, in the dark, the model's reply that it can't look up the order from here.
Contents6 sections

In this chapter

  • Build One request to a language model with OpenAI’s Responses API, in two short files.
  • Learn What tokens, reasoning tokens and the context window are.
  • Find out Why the model can’t tell Ada where her parcel is.

Where’s Ada’s coffee?

Ada is waiting for her new hand grinder and a kilo of espresso. She opens the roastery’s chat with the number from her confirmation email. All she wants to know is where the parcel is and when she can expect it.

Ada · in the shop’s chat

My order A-1042 has not arrived yet. Where is it, and when should I expect it?

Sent to the model word for word, as input.

If Ada asked across the café counter, someone could pull up A-1042 and check the tracking number. The finished agent in the prologue can open an order too. For this first experiment I sent the model exactly what Ada typed. Read her message again. She doesn’t even mention coffee. What can the model tell her about the parcel from that alone?

One question, one call

Ada asks, our program passes her sentence to the model, and the reply travels back the same way. The shop’s database is not part of the trip.

Adatypes her question in the shop’s chat
Our programsends one request and adds nothing
The modelwrites a reply, token by token
Shop databasenot connectedA-1042 · shipped 17 Nov · last scan: regional sorting centre · expected 21 Nov

No arrow leads to the one place that knows where the parcel is. Chapter 2 passes its record to the model, chapter 3 lets the model ask for it.

What goes in
input

My order A-1042 has not arrived yet. Where is it, and when should I expect it?

One sentence. No instructions, no order data, no tools.

What comes out
output_text

I can’t look up order A-1042 from here, so I can’t confirm where it is or when it will arrive. Check your shipping confirmation email or the retailer’s order page for the latest tracking update and estimated delivery date.

If you share the carrier name and the latest tracking status, I can help interpret it. If there’s no tracking link or the estimated delivery date has already passed, contact the retailer with order number A-1042 and ask for an updated delivery estimate.

usagehow many tokens went in and came out, and how many of those were reasoning

The request is the one the companion code sends. Reply from gpt-6.2-sol. Your run will word it differently.

What goes into one call

A large language model (LLM) generates an answer one token at a time. A token is a piece of text, often a word or part of one. During training the model learns patterns that help it predict the next token. That’s enough to write a plausible reply about parcel tracking. How text generation works

Many current models also reason before they answer.

Reasoning

Text the model writes for itself before it writes for you.

You never see those reasoning tokens, but they are counted and billed as output. OpenAI’s reasoning guide

The input, any reasoning tokens and the visible reply all share the model’s context window. Follow A-1042 in the diagram. The model can repeat the number because Ada typed it. To find out what the roastery shipped under that number, our program would have to supply the order record or give the model a way to look it up.

Build it

Here’s the whole program. It’s the two files in typescript/01-first-call of the companion repository. The first picks the model and creates the API client. The highlighted lines in the second are everything we send to the Responses API. OpenAI’s text generation guide

01-first-call/setup.ts
ts
import OpenAI from 'openai';

// Reads OPENAI_API_KEY from the environment (see .env.example).
export const client = new OpenAI();
export const model = process.env.MODEL || 'gpt-6.2-sol';
01-first-call/index.ts
ts
import { client, model } from './setup.ts';

// One question goes to the model, with nothing else. Pass your own as an argument.
const question =
  process.argv[2] ??
  'My order A-1042 has not arrived yet. Where is it, and when should I expect it?';

const response = await client.responses.create({
  model,
  input: question,
});

console.log(response.output_text);

// What the call cost. A model reads and writes tokens, pieces of text of a few characters each,
// and both directions are counted and billed. The output count includes the tokens the model
// spent reasoning before it wrote the reply. They are billed too, but never shown.
const { input_tokens, output_tokens, output_tokens_details } = response.usage ?? {};
const reasoning = `${output_tokens_details?.reasoning_tokens ?? 0} of them reasoning`;
console.log(`\n(${input_tokens} input tokens, ${output_tokens} output tokens, ${reasoning})`);

The response gives us the generated text in output_text and the token counts in usage, including how many output tokens went into reasoning. I printed both because I wanted to know how much of the call went into answering Ada’s one sentence.

Run it

Set up once

Every chapter of this series runs from one companion repository. You need Node.js 24 or newer, which runs TypeScript files directly, and pnpm.

sh
git clone https://github.com/phillippbertram/from-llm-to-agent-harness.git
cd from-llm-to-agent-harness
pnpm install
cp .env.example .env

Open .env and add your OpenAI API key after OPENAI_API_KEY=. MODEL is optional. Without it, the code uses the default from setup.ts. That’s the setup for the whole series. From here on, every chapter is one command.

Ask Ada’s question

sh
pnpm ch01

Without an argument, the program sends Ada’s question. This is what came back from gpt-6.2-sol, with Node.js 24.19.0 and version 7.60.0 of the OpenAI JavaScript SDK.

pnpm ch01
txt
I can’t look up order A-1042 from here, so I can’t confirm where it is or when it will arrive. Check your shipping confirmation email or the retailer’s order page for the latest tracking update and estimated delivery date.

If you share the carrier name and the latest tracking status, I can help interpret it. If there’s no tracking link or the estimated delivery date has already passed, contact the retailer with order number A-1042 and ask for an updated delivery estimate.

(28 input tokens, 103 output tokens, 0 of them reasoning)

Ada asked when her grinder would arrive. Now she’s the one looking through her shipping email for the tracking update. The reply even tells her to contact the retailer, and she is typing in the retailer’s chat. Nothing in the request told the model whose assistant it is.

The last line counts the tokens. The model answered straight away, with none of the output spent on reasoning. At the model’s listed rates, this call cost a fraction of a cent, almost all of it for the reply. OpenAI’s API pricing

I ran the same command again with just Ada’s typed question. The reply came back in other words, with Markdown asterisks around the order number and the same request to Ada.

pnpm ch01, a second time
txt
I don’t have access to the order system, so I can’t confirm where order **A-1042** is or when it will arrive. The tracking link in your shipping confirmation should show the carrier’s latest scan and estimated delivery date.

If you share the tracking status here, I can help interpret it. If you never received a shipping confirmation or the estimated delivery date has passed, contact the retailer with order number **A-1042** and ask them to check the shipment.

(28 input tokens, 102 output tokens, 0 of them reasoning)

The status doesn’t have to be typed. Recent models accept images alongside text. If our program sent a screenshot of the tracking page with Ada’s question, the model could explain the last scan visible in it. To tell her whether the parcel had moved since, the shop would still have to check with the carrier. OpenAI’s guide to image input · Read the complete terminal outputs

Reasoning is not looking it up

With Ada’s parcel the model admitted it needed help. A public fact is a different matter. I asked for the latest long-term support release of Node.js.

sh
pnpm ch01 "Which Node.js version is the latest LTS release?"
pnpm ch01, with the Node.js question
txt
**Node.js 24.x (“Krypton”)** is the latest LTS series. For the exact latest patch version, check the **LTS** label on the [official Node.js download page](https://nodejs.org/en/download).

(17 input tokens, 131 output tokens, 76 of them reasoning)

This time more than half of the output tokens went into reasoning. The answer still names Node.js 24, although Node.js 26 had already entered long-term support. Thinking longer didn’t give the model newer facts. Node.js release history

Key idea

A model answers from two sources: what it learned in training and what the request contains. Ada’s order was in neither.

In chapter 3 we ask the Node.js question again, this time with web search.

In short

In short

  • The model could quote Ada’s order number because it was in her message.
  • The same question produced two different replies. Both asked Ada to supply the tracking information.
  • Reasoning tokens count as output. More reasoning didn’t make the Node.js answer current.
  • A screenshot could show the last scan Ada saw. A fresh lookup could tell her where the parcel went next.

Next

In chapter 2 I send the order record and the latest shipping update along with Ada’s original question. Can the shop now tell her when to expect her grinder?

Series

3 parts

An agent walks into a coffee shop

  1. 00Agent Smith doesn’t work here
  2. 01One call later, where’s my coffee?You are here
  3. 02Who told you that?

Written by

Phillipp Bertram

Software development and AI from Osnabrück

Ask my agent about this article

The article goes along as context. The answer opens in the chat.