LearnThatStack Ace your next interview
AI Agents · question
Question 2 of 54

Walk me through the reason-act-observe loop that makes a system agentic.

beginner
← All AI Agents questions
Re-explain

An agentic system runs a loop: the model reasons about what to do next, acts by calling a tool, then observes the real result. The observation is appended to the context, so the next reason step is better informed. The loop repeats until the model replies with an answer instead of a tool call.

while True:
    step = model(messages)              # reason: decide the next action
    if not step.tool_calls:
        return step.text                # model answers -> loop ends
    result = run_tool(step.tool_calls)  # act
    messages += [step, result]          # observe: real output back into context

Two things make this agentic. The observation is ground truth from a live system, not the model's guess. And the model, not your code, picks each next step. An error is just another observation, so the model can retry with different arguments.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for AI Agents One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. An agentic system is a loop where the model reasons about the next step, acts by calling a tool, then observes the real result before deciding again.
  2. In code, I send the messages to the model, and if it asks for a tool, my program runs it and appends both the call and the result to the messages.
  3. On the next call the model sees that real output, so its next decision is better informed than the last one.
  4. The loop ends when the model replies with an answer instead of a tool call.
  5. Two things make it agentic: the result comes from a live system, not the model's guess, and the model picks each next step, not my code.
  6. An error is just another observation, so the model can retry with different arguments, but that freedom is also why I'd put a hard cap on steps.

Weak answers to avoid

  • Describes one tool call, not a loop One call and one answer is plain function calling. Say the result goes back into context and the model decides again, until it answers in text.
  • Has the code pick the next step If your program fixes the order of tool calls, that's a workflow. The agentic part is the model choosing each next action from what it observed.
  • Never says how the loop ends The loop stops when the model replies without a tool call. Say that, and add that you'd also cap steps in production so it can't run unbounded.
  • Treats observe as the model thinking Observation is real output from a live system, not the model imagining a result. That ground truth is why the next reason step is better informed.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the AI Agents cheatsheet.

← Back to all AI Agents questions
Pro · $10/mo

47 of 54 AI Agents answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime