Your placement (from diagnostic)
AWS cloud engineer → builder-architect track. You already own IAM, VPC, Lambda, CloudWatch and cost, so we're skipping Track A (the bridge). Target: Track B — Agentic Systems (the agentic loop, the five patterns, MCP, subagents, memory, eval design, cost modeling, OWASP LLM safety). This is Track B · Module 2.

The Agentic Loop & Tool Use CCAR-F Domain 1 · Agentic Architecture (highest-weighted) · ~25 min

Maps to: CCAR-F D1 · AWS GenAI Dev Pro (Bedrock agents) · real-work: the harness you own
01
Objectives
02
Lesson
03
Retrieval
04
Mastery
05
Coach
OBJECTIVE MASTERY
0%
Backward design · what you'll be able to do

Objectives

Every objective below maps to a question in the retrieval set and to the mastery gate. You don't advance on time spent — you advance when you can do these.

  • LO1Trace one full iteration of the agentic loop and name exactly what ends it.
  • LO2Explain why you branch on stop_reason instead of reading the model's prose for tool intent.
  • LO3Tell syntactic (malformed) from semantic (valid-but-wrong) tool errors, and say where each is caught.
  • LO4Bound a loop — budgets, done-conditions, escalation — to prevent runaway behavior and excessive agency.
  • LO5Reframe a senior's "make it deterministic" instinct into evals + guardrails.
recall > reread — there's a question for each of these
Lesson · framed as deltas from what you already know

Your code stops being the decision-maker

As a senior, your instinct is to own control flow: if this, call that. In an agent, you hand the branching decision to the model and your code becomes the loop harness around it. That single inversion is the whole mindset shift — everything else follows from it.

The loop, precisely

# the harness you write — not the intelligence, the plumbing
while True:
    resp = model.send(messages, tools)
    if resp.stop_reason == "tool_use":        # model decided to act
        result = run_tool(resp.tool_calls)     # YOU execute + validate
        messages.append(tool_result(result))  # feed it back
        continue                              # loop again
    if resp.stop_reason == "end_turn":        # model is done
        break

Read it as a sentence: send → check stop_reason → if it wants a tool, run it and feed the result back → repeat → stop when it's done. The model never touches your systems directly; it requests, your harness executes. That gap is where all your leverage (and all the risk) lives.

Map it to what you know
It's an event loop / a REPL / a retry-with-side-effects loop — except the branch decision each turn comes from the model, not your if statements. You've written this control structure a hundred times; only the decider changed.

The four footguns (where seniors actually get burned)

  • Reading the prose, not the structure. Don't scan the reply text for "I'll call search()". The response tells you structurally via stop_reason + tool_use blocks. Parsing prose is guessing.
  • Assuming schema-valid = correct. A typed tool schema stops malformed calls (syntactic), not wrong-but-well-formed ones (semantic). A valid account_id can still be the wrong account. You validate values in the tool.
  • No budget = runaway. Without a turn/tool cap and a done-condition, a loop can spin 40 times burning tokens — or take an irreversible action it shouldn't. This is OWASP LLM03 Excessive Agency (LLM06 in the 2025 edition): bound it, gate high-risk actions, keep a kill switch.
  • Fighting non-determinism. Same input can take a different tool path. Don't chase a deterministic path — judge outcomes with evals and constrain behavior with guardrails.
Why this is your job, builder-architect
At an AWS-partner GenAI consultancy, this loop is the Bedrock AgentCore agent. The harness, tool boundaries, stop conditions, cost controls, and safety gates all live here — and they're exactly the production instincts you already have from running systems. This module is you porting those instincts onto a probabilistic decider.
Retrieval practice · scenario items, CCAR-F style
Question 1 of 5
pick the option you'd defend in a code review
Mastery gate · advance on competence, not time

Mastery check

0/5

Your spaced-repetition schedule

Items you missed resurface sooner; items you nailed return on a longer interval. That's the forgetting curve being managed for you — recall right before you'd forget.

Objective / itemResultNext review
The coach · scalable 1:1 tutoring (the lever, §3)

A real corrective turn

Illustrative transcript: a learner picks "lower the temperature" to stop a runaway loop (a very common senior conflation). A good tutor doesn't say "wrong" — it finds the misconception, ties it to what you already know, and hands the loop back.

Learner
For the runaway-loop one I went with lowering temperature — fewer random detours should mean it stops looping, right?
Coach
Quick gut-check first: what does temperature actually control? It biases token sampling — how adventurous the next-token pick is. It has zero authority over how many times your loop runs. So the runaway isn't a sampling problem; it's a control-flow problem — your harness never told the loop when to stop.

The fix lives in your code, not the model's decoding params: a turn/tool-call budget, an explicit done-condition, and a human escalation when you hit the cap. You already do exactly this with rate-limiters and circuit-breakers — same instinct, new decider. Want to redo that item with the control-flow lens?
What just happened (by design): diagnosed the specific misconception (temperature ≠ loop control) · connected it to existing senior knowledge (rate-limiters / circuit-breakers — adult learning) · gave the correct model, not just the verdict · prompted a retry so the item re-enters the mastery + spaced-repetition cycle.

Keep going

Track 0 (The Mindset Shift) and the Track 0 coach allowance are free with an account, no card. The full curriculum, mock exams and the coach on every track come with membership.

How this 25 minutes maps to the gold-standard pedagogy (§1c)
Backward design
Measurable objectives (LO1–LO5) defined first; every item and the gate trace back to one.
Retrieval practice
You recalled under scenario pressure instead of re-reading — the testing effect is the core mechanic.
Spaced repetition
The schedule table: missed items return on short intervals, mastered ones stretch out.
Mastery gating
≥4/5 to advance — competence, not completion.
1:1 tutoring
The coach turn diagnoses a misconception and adapts — the 2-sigma lever, at scale.
Adult / expert
Deltas from known mental models, scaffolding faded fast, no beginner pacing (expertise-reversal aware).
Diagnostic path
Placement banner: an AWS engineer skips the bridge and starts on Track B (Agentic Systems).