Agent Loop
“One loop & Bash is all you need”
one tool + one loop = one agent
Build a Claude Code–style agent harness from scratch - a free 20-lesson course across 6 stages, with runnable code and English chapters.
while True:
response = model(messages, tools)
if response.stop_reason != "tool_use":
return response.text
results = execute(response.tool_calls)
messages.append(results)Every coding agent is this loop. The model calls tools until it is done — everything else in these 20 lessons is refinement around it.
Forward Deployed Engineers ship AI agents inside real customer systems. Open roles at Anthropic, OpenAI, Cognizant and more.
Core capabilities
“One loop & Bash is all you need”
one tool + one loop = one agent
“Adding a tool means adding one handler”
the loop stays untouched; new tools register into the dispatch map
“Set boundaries first, then grant freedom”
check what can run, what must stop, and what needs approval
“Hook around the loop, never rewrite the loop”
add extension points without changing the main loop
Plan, delegate, make room
“An agent without a plan drifts”
list the steps before starting; completion rate doubles
“Context always fills up -- have a way to make room”
four compaction steps reduce tool results first, then summarize history when it remains over the limit
Memory and resilience
“Remember what matters, forget what doesn't”
three subsystems: selection, extraction, consolidation
“Big goals break into small tasks, ordered, persisted to disk”
a file-backed task graph that lays the groundwork for multi-agent coordination
“Slow ops go background, agent keeps thinking”
background threads run commands; notifications inject on completion
Persist, background, schedule
“Fire on schedule, no human kick needed”
trigger tasks automatically by time
“Too big for one agent -- let teammates divide the work”
persistent teammates coordinate, claim ready tasks, and use task-bound working directories
“Not enough capability? Plug in more via MCP”
connect external tools into the same tool pool
Teams and protocols
“Many mechanisms, one loop”
the mechanisms used by the integrated example share one harness
“When the orchestration shape is fixed, put it in code”
saved workflows with resumable journals
“A goal decides when the loop may stop”
an independent evaluator reviews each proposed stop; impossible, failed, or over-limit goals return control to the user
Skills, MCP, the full loop