ImageFirm Sheet N°03 · Agent engineering
Infographic series · N°03 · Fact-checked rebuild

The agentic loop.

How an agent plans, picks its tools, acts, reads what came back, and knows when to stop — drafted station by station, with the guards that make it safe to run unattended.

Series N°03 Stations 09 + gate Iterated core 03–07 Revision 2026.08
Verified — holds up against how inference and tool use actually work Redline — corrected from the source IF — ImageFirm addition

The run, station by station

One instruction in, one outcome out. Everything between is this loop.

Request

One instruction arrives in natural language. Everything below exists to honour it — including knowing when honouring it means stopping.

Instruction Intent Success criteria
IF · AddedWrite the success criteria down now. Station 07 will judge "done" against them — not against how tired the loop is.

Plan & decompose

The model turns the goal into reasoning and an ordered subtask list. This is the run's blueprint; everything after it is execution.

Goal Reason Subtask list
VerifiedThe source has the systems detail right: reading the prompt (prefill) is compute-bound, while writing the plan (decode) is memory-bandwidth-bound. It is why long contexts and long outputs cost differently.

Select the tool

Each subtask is matched against tool schemas — name, description, inputs, outputs. Best match wins; the call is validated against the schema before it goes anywhere.

Subtask Tool schemas Validate Best match
RedlineA discrete "registry lookup" only exists at scale. With a few dozen tools, the schemas sit in the model's context and it chooses directly. Add a search layer when the catalogue outgrows the window — not before.

Execute

A typed call goes out — to an API, a system, or another agent — and a raw result comes back. Structured in, structured out.

Typed call API · System · Agent Raw result
VerifiedAgent-to-agent is real, not hype: in multi-agent systems the "tool" on the other end may be another agent speaking an A2A-style protocol. The same discipline applies either way.

Read the result

The raw response becomes a structured observation. Two questions, every time: did I get what I needed — and is it enough to proceed?

Raw response Normalise Observation
On failure Retry Fallback tool Ask the human
RedlineMost frameworks skip an explicit parse — the result is simply appended to the transcript. Treat this as a real checkpoint anyway: unread garbage in the context is how runs go wrong quietly.

Write memory

The observation lands in two places: the running context of this conversation, and the long-term stores that outlive the run.

Short-term In-context transcript
Long-term Vector store Key-value Episodic log
IF · AddedCompaction is part of memory. Summarise the transcript before the window forces you to — or station 07's judgement degrades exactly when it matters most.

Check & re-plan

Done means the success criteria from station 01 are met. If not: update the context, revise the plan, return to station 03.

Criteria met? Yes · continue to 08
VerifiedThe numbered list reads linear; the run is not. Stations 03–07 are the iterated core, and the loop-back below is the most important arrow on the sheet.
No → Update context Revise plan Return to station 03 Guards: max_iterations · max_spend IF

Synthesize

The observations become one answer — checked against each other first, then drafted. The final generation itself is a normal model inference pass.

Obs 1 + Obs 2 + Obs n Cross-check Draft
Redline"Verify consistency" is not default model behaviour. It is a critic pass you design in — or it does not happen.

Respond or act

Stream the text, return the structure, or take the action — whichever the instruction asked for. Gated actions get logged like everything else.

Streaming text Structured response Action taken · gated
VerifiedCost and latency accumulate across every model call and tool round trip in the run — the loop's economics are set by its architecture, not by the last answer.

Under the hood

Five properties that decide whether the loop survives contact with production.

B-01

Reliability

Retries, fallbacks, and the option to ask a person. An agent that cannot say "I'm stuck" is not reliable — it is quiet.

B-02

Latency

Every model call and every tool round trip adds up. Parallelise independent calls; the loop's speed is architecture, not model choice.

B-03

Cost

Grows with iterations × context size × tool calls. Ceilings are configuration, not hope.

B-04

Observability

Log plans, tool calls, results, errors and latency. A run you cannot replay is a run you cannot audit — or debug.

B-05Operating rule

Human authority

A person holds final authority over anything high-impact or irreversible. At ImageFirm this is not a setting — it is the rule the settings serve.

The perimeter

What the popular sheet leaves out — and what fails first without it.

C-01Missing at source

Injection defense

Every tool result is untrusted input. Instructions found inside data stay data — quarantine them; never promote them to commands.

C-02Missing at source

Least privilege

Scoped credentials, allowlisted actions, sandboxed execution. The agent gets the keys the task needs — none it might enjoy.

C-03Missing at source

Eval before unattended

A loop that has not passed offline evals runs with a person watching — or it does not run.

Work with ImageFirm

Bring us the loop that has your name on it.

This sheet is the method in the open. If you want it applied to your own agents — built, guarded and gated — start with an enquiry and tell us what you are trying to run.

Start an enquiry