Lesson 01.01 · Phase 01 · LLM Foundations for Agents

What an LLM actually returns

You don't get "text" back. You get text, a reason it stopped, a token bill, and, if you ask, the probability of every token. An agent needs all of it.

Learning objectives

  • Read a raw chat-completion response from OpenAI-compatible, Anthropic and Ollama-native APIs, and name every field an agent cares about.
  • Normalise the three shapes into one Completion, including their different names for the same stop reasons.
  • Detect a truncated reply from its stop reason, instead of trusting text that merely looks finished.
  • Read token log-probabilities, and explain what they say (and don't say) about how sure the model was.

Most tutorials do response.choices[0].message.content and move on. That one line throws away the facts your agent needs:

Loading the full lesson…