Repository navigation
Expand file tree
/
Copy pathloop-engineering.html
More file actions
918 lines (791 loc) · 42.1 KB
/
Copy pathloop-engineering.html
File metadata and controls
918 lines (791 loc) · 42.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
<!doctype html>
<html lang="en">
<head>
<!-- Klaro Consent Management -->
<script type="text/javascript">
var klaroConfig = {
storageMethod: 'cookie',
cookieName: 'klaro',
cookieExpiresAfterDays: 365,
privacyPolicy: '/privacy.html',
default: false,
mustConsent: false,
acceptAll: true,
hideDeclineAll: false,
hideLearnMore: false,
noticeAsModal: false,
translations: {
en: {
consentModal: {
title: 'Design a Loop — We value your privacy',
description: 'Here you can see and customize the information that we collect about you.',
},
decline: 'Reject all',
ok: 'Accept all',
analytics: {
description: 'Collection of information about how visitors use our website.',
},
purposes: {
analytics: 'Analytics',
},
},
},
services: [
{
name: 'analytics',
title: 'Analytics & Tracking',
purposes: ['analytics'],
required: false,
},
],
};
</script>
<script defer src="https://cdn.kiprotect.com/klaro/v0.7.18/klaro.js"></script>
<!-- Google tag (gtag.js) — loaded only after analytics consent via Klaro above -->
<script async type="text/plain" data-type="text/javascript" data-name="analytics" src="https://www.googletagmanager.com/gtag/js?id=G-QGLX7EXQVC"></script>
<script type="text/plain" data-type="text/javascript" data-name="analytics">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-QGLX7EXQVC');
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Loop Engineering — The AI Agent Loop, Defined</title>
<meta name="description" content="Loop engineering is designing the perceive, reason, decide, act, verify, recover cycle an AI agent runs on every turn — and the open-source tool that builds it.">
<link rel="canonical" href="https://designaloop.com/loop-engineering">
<meta property="og:type" content="website">
<meta property="og:url" content="https://designaloop.com/loop-engineering">
<meta property="og:site_name" content="Design a Loop">
<meta property="og:title" content="Loop Engineering — The AI Agent Loop, Defined">
<meta property="og:description" content="Loop engineering is designing the perceive-reason-decide-act-verify-recover cycle an AI agent runs on every turn — what it is, vs. prompt engineering, and the tool that builds it.">
<meta property="og:image" content="https://designaloop.com/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Design a Loop — the discipline of engineering the iterative cycle behind AI agents.">
<meta property="og:locale" content="en_US">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Loop Engineering — The AI Agent Loop, Defined">
<meta name="twitter:description" content="Loop engineering is the discipline of designing the iterative perceive-reason-decide-act-verify-recover cycle an AI agent runs on every turn.">
<meta name="twitter:image" content="https://designaloop.com/og-image.png">
<meta name="twitter:image:alt" content="Design a Loop — the discipline of engineering the iterative cycle behind AI agents.">
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1">
<meta name="author" content="3IVIS">
<meta name="keywords" content="loop engineering, agent loop, AI agent loop, agentic loop, reasoning loop, perceive reason decide act, AI agent reliability, harness engineering, open source">
<link rel="alternate" type="text/plain" href="/llms.txt" title="llms.txt — structured summary for LLMs">
<link rel="sitemap" type="application/xml" href="/sitemap.xml">
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<meta name="theme-color" content="#3D2F8C">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&family=Instrument+Serif:ital@0;1&display=swap" rel="stylesheet">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "DefinedTerm",
"@id": "https://designaloop.com/loop-engineering#term",
"name": "Loop engineering",
"description": "The discipline of designing the iterative perceive, reason, decide, act, verify, recover cycle that an AI agent runs on every turn, rather than letting one emerge by accident.",
"inDefinedTermSet": "https://designaloop.com/#glossary"
},
{
"@type": "WebPage",
"@id": "https://designaloop.com/loop-engineering#webpage",
"url": "https://designaloop.com/loop-engineering",
"name": "Loop Engineering — Designing the Iterative Cycle Behind Reliable AI Agents",
"description": "Loop engineering is the discipline of designing the iterative perceive-reason-decide-act-verify-recover cycle an AI agent runs on every turn.",
"datePublished": "2026-07-04",
"dateModified": "2026-07-04",
"publisher": { "@id": "https://designaloop.com/#org" },
"breadcrumb": { "@id": "https://designaloop.com/loop-engineering#breadcrumb" }
},
{
"@type": "BreadcrumbList",
"@id": "https://designaloop.com/loop-engineering#breadcrumb",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Design a Loop", "item": "https://designaloop.com/" },
{ "@type": "ListItem", "position": 2, "name": "Loop Engineering", "item": "https://designaloop.com/loop-engineering" }
]
},
{
"@type": "Organization",
"@id": "https://designaloop.com/#org",
"name": "3IVIS",
"url": "https://github.com/3IVIS",
"sameAs": ["https://github.com/3IVIS/buildaharness", "https://buildaharness.com"]
},
{
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is loop engineering?",
"acceptedAnswer": { "@type": "Answer", "text": "Loop engineering is the discipline of designing the iterative cycle an AI agent runs on every turn: what it perceives, what it believes, what it is allowed to do, how it verifies its own output, and how it recovers when a step fails — before looping back and doing it again. Instead of letting a loop emerge by accident from glue code, loop engineering treats the cycle itself as the primary thing you design." }
},
{
"@type": "Question",
"name": "What is the difference between loop engineering and prompt engineering?",
"acceptedAnswer": { "@type": "Answer", "text": "Prompt engineering asks 'how should I phrase this one call?' and optimizes a single model invocation. Loop engineering asks 'what should happen between calls, and how many times should this cycle run?' It designs the state carried across iterations, the stopping condition, the verification that runs each pass, and the recovery path when an iteration fails. In production, loop-level design decisions account for the large majority of agent reliability; prompt refinement beyond a reasonable baseline accounts for a small fraction." }
},
{
"@type": "Question",
"name": "What is the difference between a loop and a workflow?",
"acceptedAnswer": { "@type": "Answer", "text": "A workflow is a straight line: input, LLM call, tool call, output, done once. A loop is designed to run an unknown number of times, carrying state forward, deciding after each pass whether to continue, escalate, retry, or stop. Workflows suit deterministic linear tasks. Loops suit agents operating in environments where the right number of steps isn't known in advance." }
},
{
"@type": "Question",
"name": "Is loop engineering the same as harness engineering?",
"acceptedAnswer": { "@type": "Answer", "text": "Yes, they describe the same discipline from two angles. Harness engineering emphasizes the constraint structure — the infrastructure that wraps the model and keeps it in bounds. Loop engineering emphasizes the iterative cycle that structure runs on — perceive, reason, decide, act, verify, recover, repeat. Build A Harness is the open-source tool that implements both views: it builds the harness, and the harness is what runs the loop." }
},
{
"@type": "Question",
"name": "What is the 'agent loop' people talk about?",
"acceptedAnswer": { "@type": "Answer", "text": "The agent loop is the repeating cycle an autonomous AI agent runs through: observe the current state, reason about it, decide on an action, execute it, check the result, and repeat until a stopping condition is met. Most agent failures — infinite retries, drift, compounding hallucination, silent context loss — trace back to a loop that was never explicitly designed, not to the underlying model." }
},
{
"@type": "Question",
"name": "How do I get started with loop engineering?",
"acceptedAnswer": { "@type": "Answer", "text": "The fastest path is Build A Harness, the open-source tool that implements a fully engineered loop as drawable canvas nodes. Clone github.com/3IVIS/buildaharness, run ./scripts/setup-env.sh && docker compose up, and draw your loop on the canvas at localhost:3000. It compiles to LangGraph, CrewAI, Mastra, or Microsoft Agent Framework. No cloud account required." }
},
{
"@type": "Question",
"name": "What is FlowSpec?",
"acceptedAnswer": { "@type": "Answer", "text": "FlowSpec is the runtime-neutral JSON format at the center of Build A Harness. You design a loop once on the visual canvas and it compiles to a FlowSpec file, which then runs on LangGraph, CrewAI, Mastra, or Microsoft Agent Framework without rewriting." }
}
]
}
]
}
</script>
<style>
:root{
--bg:oklch(.972 .008 270);
--bg-2:oklch(.948 .012 270);
--paper:oklch(.985 .008 270);
--ink:oklch(.19 .024 270);
--ink-2:oklch(.37 .02 270);
--ink-3:oklch(.55 .018 270);
--line:oklch(.84 .014 270);
--accent:oklch(.46 .16 268);
--accent-ink:oklch(.36 .16 270);
--green:oklch(.38 .12 148);
--green-tint:oklch(.93 .04 148);
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--bg);color:var(--ink);}
body{
font-family:"IBM Plex Sans",sans-serif;
line-height:1.6;
-webkit-font-smoothing:antialiased;
}
.wrap{max-width:1180px;margin:0 auto;padding:0 40px;}
.prose{max-width:740px;}
/* header */
header{border-bottom:1px solid var(--line);background:var(--paper);}
.site-inner{display:flex;align-items:center;justify-content:space-between;padding:18px 0;}
.brand{display:flex;align-items:center;gap:12px;text-decoration:none;color:var(--ink);}
.brand .name{font-family:"IBM Plex Mono",monospace;font-size:15px;white-space:nowrap;}
.nav{display:flex;gap:22px;font-family:"IBM Plex Mono",monospace;font-size:12px;}
.nav a{text-decoration:none;color:var(--ink-2);}
.nav a:hover{color:var(--ink);}
.btn{
display:inline-flex;align-items:center;gap:8px;
padding:10px 16px;border-radius:6px;text-decoration:none;
background:var(--ink);color:white;
font-family:"IBM Plex Mono",monospace;font-size:12px;
border:1px solid var(--ink);
}
.btn-ghost{background:transparent;color:var(--ink);border-color:var(--line);}
.btn-ghost:hover{border-color:var(--ink);}
/* breadcrumb */
.breadcrumb{
font-family:"IBM Plex Mono",monospace;font-size:12px;
color:var(--ink-3);margin-bottom:32px;
}
.breadcrumb a{color:var(--ink-3);text-decoration:none;}
.breadcrumb a:hover{color:var(--ink-2);}
.breadcrumb span{margin:0 6px;}
/* eyebrow */
.eyebrow{
font-family:"IBM Plex Mono",monospace;text-transform:uppercase;
font-size:11px;letter-spacing:.16em;color:var(--accent-ink);
margin-bottom:22px;
}
/* hero */
.page-hero{padding:64px 0 72px;background:var(--paper);border-bottom:1px solid var(--line);}
h1{
font-size:56px;line-height:1.04;letter-spacing:-.04em;
font-weight:300;margin:0 0 24px;max-width:820px;
}
h1 em{
font-family:"Instrument Serif",serif;font-style:italic;
color:var(--accent-ink);font-weight:400;
}
.hero-lede{
font-size:19px;font-weight:300;color:var(--ink-2);
max-width:660px;margin:0 0 40px;line-height:1.5;
}
/* stats */
.stat-row{
display:flex;gap:0;border:1px solid var(--line);border-radius:6px;
overflow:hidden;margin-bottom:36px;max-width:820px;
}
.stat{
flex:1;padding:22px 24px;background:var(--bg);
border-right:1px solid var(--line);
}
.stat:last-child{border-right:none;}
.stat-n{
display:block;font-size:32px;font-weight:300;letter-spacing:-.03em;
color:var(--accent-ink);font-family:"IBM Plex Mono",monospace;
margin-bottom:6px;
}
.stat-l{display:block;font-size:13px;color:var(--ink-3);line-height:1.4;}
.cta-row{display:flex;gap:12px;flex-wrap:wrap;}
/* content sections */
.section{padding:64px 0;background:var(--paper);}
.section.alt{background:var(--bg);}
h2{
font-size:36px;font-weight:300;letter-spacing:-.03em;
margin:0 0 20px;line-height:1.15;
}
h2 em{
font-family:"Instrument Serif",serif;font-style:italic;
color:var(--accent-ink);font-weight:400;
}
.section-label{
font-family:"IBM Plex Mono",monospace;text-transform:uppercase;
font-size:10.5px;letter-spacing:.18em;color:var(--ink-3);
margin-bottom:16px;
}
p{font-size:16px;color:var(--ink-2);line-height:1.7;margin:0 0 18px;}
p:last-child{margin-bottom:0;}
strong{color:var(--ink);font-weight:600;}
/* comparison block */
.compare-grid{
display:grid;grid-template-columns:1fr 1fr;gap:16px;
margin-top:28px;max-width:820px;
}
.compare-card{
border:1px solid var(--line);border-radius:6px;
background:var(--bg);padding:24px 26px;
}
.compare-card.highlight{
border-color:oklch(.78 .06 268);
background:oklch(.95 .018 268);
}
.compare-card h3{
font-size:14px;font-weight:600;font-family:"IBM Plex Mono",monospace;
text-transform:uppercase;letter-spacing:.1em;margin:0 0 14px;
color:var(--ink-3);
}
.compare-card.highlight h3{color:var(--accent-ink);}
.compare-card ul{
margin:0;padding:0 0 0 16px;
display:flex;flex-direction:column;gap:8px;
}
.compare-card li{font-size:14.5px;color:var(--ink-2);line-height:1.5;}
.compare-card.highlight li{color:var(--ink);}
/* layers */
.layers-grid{
display:grid;grid-template-columns:1fr 1fr;gap:12px;
margin-top:28px;
}
.layer-card{
border:1px solid var(--line);border-radius:6px;
background:var(--paper);padding:20px 22px;
border-left:3px solid var(--accent);
display:flex;flex-direction:column;gap:6px;
}
.layer-num{
font-family:"IBM Plex Mono",monospace;font-size:10px;
color:var(--ink-3);text-transform:uppercase;letter-spacing:.14em;
}
.layer-name{font-size:16px;font-weight:600;color:var(--ink);letter-spacing:-.01em;}
.layer-desc{font-size:14px;color:var(--ink-2);line-height:1.5;}
.layer-without{
font-size:12.5px;color:var(--ink-3);
font-family:"IBM Plex Mono",monospace;
margin-top:4px;
}
/* process steps */
.process-steps{
display:grid;grid-template-columns:repeat(4,1fr);
gap:0;border:1px solid var(--line);border-radius:6px;
overflow:hidden;margin-top:28px;
}
.process-step{
padding:24px 22px;background:var(--paper);
border-right:1px solid var(--line);
display:flex;flex-direction:column;gap:10px;
}
.process-step:last-child{border-right:none;}
.process-step-n{
font-family:"IBM Plex Mono",monospace;font-size:10px;
color:var(--accent-ink);text-transform:uppercase;letter-spacing:.16em;
}
.process-step-title{font-size:17px;font-weight:600;color:var(--ink);letter-spacing:-.01em;}
.process-step-sub{font-size:13.5px;color:var(--ink-2);line-height:1.5;}
.process-step-detail{
font-family:"IBM Plex Mono",monospace;font-size:11px;
color:var(--ink-3);line-height:1.6;
}
/* quickstart */
.quickstart-box{
border:1px solid var(--line);border-radius:6px;
overflow:hidden;max-width:640px;
margin-top:28px;
}
.quickstart-bar{
padding:11px 18px;background:var(--bg-2);border-bottom:1px solid var(--line);
font-family:"IBM Plex Mono",monospace;font-size:10.5px;
text-transform:uppercase;letter-spacing:.14em;color:var(--ink-3);
}
pre{
margin:0;padding:20px 18px;
font-family:"IBM Plex Mono",monospace;font-size:13px;
line-height:1.7;color:var(--ink);background:var(--paper);
}
/* services list */
.services{
display:flex;flex-direction:column;gap:6px;margin-top:20px;
}
.service-row{
display:flex;align-items:center;gap:14px;
padding:10px 14px;border:1px solid var(--line);
border-radius:4px;background:var(--paper);
}
.service-dot{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0;}
.service-name{font-family:"IBM Plex Mono",monospace;font-size:12.5px;font-weight:500;color:var(--ink);}
.service-url{font-family:"IBM Plex Mono",monospace;font-size:12px;color:var(--ink-3);}
/* tool callout */
.tool-callout{
margin-top:20px;padding:14px 18px;
border:1px solid var(--line);border-radius:6px;
background:var(--paper);
display:flex;align-items:flex-start;gap:16px;
}
.tool-callout-label{
font-family:"IBM Plex Mono",monospace;font-size:10px;
text-transform:uppercase;letter-spacing:.14em;
color:var(--accent-ink);white-space:nowrap;flex-shrink:0;padding-top:2px;
}
.tool-callout p{
margin:0;font-size:13.5px;color:var(--ink-2);line-height:1.5;
}
/* faq */
.faq-list{
border:1px solid var(--line);border-radius:6px;overflow:hidden;
margin-top:24px;
}
.faq-item{
padding:22px 26px;border-bottom:1px solid var(--line);
background:var(--paper);
}
.faq-item:last-child{border-bottom:none;}
.faq-item h3{
font-size:17px;font-weight:500;letter-spacing:-.01em;
color:var(--ink);margin:0 0 8px;
}
.faq-item p{font-size:14.5px;}
/* cta section */
.cta-section{
padding:64px 0;border-top:1px solid var(--line);
background:var(--paper);
}
.cta-inner{
display:flex;align-items:flex-start;justify-content:space-between;
gap:40px;flex-wrap:wrap;
}
.cta-text h2{margin-bottom:12px;}
.cta-text p{max-width:540px;}
.cta-actions{display:flex;flex-direction:column;gap:12px;flex-shrink:0;padding-top:8px;}
/* footer */
footer{padding:32px 0;border-top:1px solid var(--line);}
.footer-inner{
display:flex;justify-content:space-between;align-items:center;
flex-wrap:wrap;gap:20px;
}
.footer-links{display:flex;gap:18px;flex-wrap:wrap;}
.footer-links a{
text-decoration:none;color:var(--ink-2);
font-family:"IBM Plex Mono",monospace;font-size:12px;
}
.footer-tag{
font-family:"Instrument Serif",serif;color:var(--ink-3);font-style:italic;
}
@media(max-width:760px){
.wrap{padding:0 22px;}
h1{font-size:38px;}
h2{font-size:28px;}
.stat-row{flex-direction:column;}
.stat{border-right:none;border-bottom:1px solid var(--line);}
.stat:last-child{border-bottom:none;}
.compare-grid{grid-template-columns:1fr;}
.layers-grid{grid-template-columns:1fr;}
.process-steps{grid-template-columns:1fr 1fr;}
.cta-inner{flex-direction:column;}
.nav{display:none;}
.tool-callout{flex-direction:column;gap:8px;}
}
</style>
</head>
<body>
<header>
<div class="wrap site-inner">
<a class="brand" href="/" aria-label="Design a Loop home">
<span class="name">Design a Loop</span>
</a>
<nav class="nav">
<a href="/#definition">The loop</a>
<a href="/#anatomy">Anatomy</a>
<a href="/#vs-prompt-engineering">vs prompt engineering</a>
<a href="/#tool">The tool</a>
<a href="/loop-engineering" style="color:var(--accent-ink);">Loop engineering</a>
<a href="/#faq">FAQ</a>
</nav>
<a class="btn" href="https://github.com/3IVIS/buildaharness">Get the tool</a>
</div>
</header>
<section class="page-hero">
<div class="wrap">
<nav class="breadcrumb" aria-label="Breadcrumb">
<a href="/">Design a Loop</a><span aria-hidden="true">/</span><span>Loop Engineering</span>
</nav>
<div class="eyebrow">DESIGN A LOOP · THE DISCIPLINE OF LOOP ENGINEERING</div>
<h1>
The discipline of<br>
<em>loop engineering.</em>
</h1>
<p class="hero-lede">
Every AI agent runs on a loop — perceive, reason, decide, act, verify, recover, repeat. Loop engineering is the discipline of designing that cycle on purpose instead of letting it emerge from whatever glue code happened to ship first. This page covers the discipline. <a href="https://buildaharness.com" style="color:var(--accent-ink);">Build A Harness</a> is the open-source tool that builds it.
</p>
<div class="stat-row" role="list">
<div class="stat" role="listitem">
<span class="stat-n">88%</span>
<span class="stat-l">of AI agent projects never reach production — the bottleneck is the loop, not the model</span>
</div>
<div class="stat" role="listitem">
<span class="stat-n">7</span>
<span class="stat-l">stages in a fully engineered agent loop — perceive through learn, then repeat</span>
</div>
<div class="stat" role="listitem">
<span class="stat-n">~1.6%</span>
<span class="stat-l">of a production agent is the model's decision logic — the rest is the loop around it</span>
</div>
</div>
<div class="cta-row">
<a class="btn" href="https://github.com/3IVIS/buildaharness">Get the tool — GitHub</a>
<a class="btn btn-ghost" href="/">See Design a Loop →</a>
<a class="btn btn-ghost" href="#definition">What is loop engineering? ↓</a>
</div>
</div>
</section>
<section class="section" id="definition">
<div class="wrap prose">
<div class="section-label">DEFINITION</div>
<h2>What is loop engineering?</h2>
<p>
Loop engineering is the discipline of designing the iterative cycle an AI agent runs on every turn: what it perceives, what it believes, what it is allowed to do, how it verifies its own output, and how it recovers when a step fails — before looping back and doing it again.
</p>
<p>
Every agent that does more than answer a single question runs on a loop, whether anyone designed one or not. Call a model, look at what it produced, decide what to do next, call it again. Left undesigned, that loop degrades in predictable ways: it retries forever when a tool fails, it drifts when early mistakes compound across iterations, it loses track of what it already tried, and it has no way to tell the difference between "done" and "stuck."
</p>
<p>
Loop engineering is the practice of designing that cycle deliberately — the same way you'd design a state machine, not glue code you patch after something breaks in production. It's the same underlying discipline as <a href="https://buildaharness.com/harness-engineering" style="color:var(--accent-ink);">harness engineering</a>, viewed through the lens of the cycle rather than the constraint structure around it.
</p>
<div style="margin-top:28px;border:1px solid oklch(.82 .04 268);border-left:3px solid var(--accent);border-radius:6px;padding:20px 24px;background:oklch(.96 .008 268);">
<div style="font-family:'IBM Plex Mono',monospace;font-size:10px;text-transform:uppercase;letter-spacing:.14em;color:var(--accent-ink);margin-bottom:8px;">Build A Harness — the tool built for this discipline</div>
<p style="font-size:15px;color:var(--ink);line-height:1.6;margin:0;">Build A Harness is the open-source visual canvas that implements a fully engineered loop as drawable, composable nodes — world model, control state, verification, recovery, all wired into the cycle your agent actually runs on. Apache 2.0. <a href="https://buildaharness.com" style="color:var(--accent-ink);">See the tool →</a></p>
</div>
</div>
</section>
<section class="section alt" id="vs-prompt-engineering">
<div class="wrap">
<div class="section-label">COMPARISON</div>
<h2>Loop engineering vs <em>prompt engineering</em></h2>
<p class="prose" style="margin-bottom:0;">
Both matter. But they operate at different points in the cycle and solve different problems. In production, the returns on each are not equal.
</p>
<div class="compare-grid">
<div class="compare-card">
<h3>Prompt engineering</h3>
<ul>
<li>Optimises the input to a single model call</li>
<li>Asks: <em>"How should I phrase this?"</em></li>
<li>Scope: one call, one response</li>
<li>Reliability gain beyond a baseline: <3%</li>
<li>Breaks down once the agent needs to loop more than once</li>
</ul>
</div>
<div class="compare-card highlight">
<h3>Loop engineering</h3>
<ul>
<li>Designs what happens between calls, and how many times the cycle runs</li>
<li>Asks: <em>"What should this loop do after each pass, and when should it stop?"</em></li>
<li>Scope: every iteration, every tool call, every failure, every run</li>
<li>Reliability gain from loop-level changes: 28–47%</li>
<li>The layer that determines whether an agent survives past the demo</li>
</ul>
</div>
</div>
<div class="tool-callout" style="max-width:820px;">
<div class="tool-callout-label">In Build A Harness</div>
<p>Every node type on the canvas implements a piece of the loop — not prompt optimisation. It's the tool that makes the 28–47% reliability gain buildable without writing the cycle from scratch. <a href="https://buildaharness.com" style="color:var(--accent-ink);">See the node library →</a></p>
</div>
</div>
</section>
<section class="section" id="vs-workflow">
<div class="wrap prose">
<div class="section-label">COMPARISON</div>
<h2>A loop vs a <em>workflow</em></h2>
<p>
A <strong>workflow</strong> is a straight line: input, LLM call, tool call, output, done once. It gets data where it needs to go, and it's the right tool when the number of steps is known ahead of time and the failure modes are predictable.
</p>
<p>
A <strong>loop</strong> is designed to run an unknown number of times, carrying state forward from one pass to the next. Where a workflow routes, a loop governs:
</p>
<ul style="margin:0 0 18px;padding-left:20px;display:flex;flex-direction:column;gap:10px;">
<li style="font-size:16px;color:var(--ink-2);line-height:1.6;"><strong>What carries over between iterations</strong> — a world model that tracks typed beliefs, detects contradictions, and tags each belief with a generation ID</li>
<li style="font-size:16px;color:var(--ink-2);line-height:1.6;"><strong>Whether this pass is allowed to act</strong> — a multi-tier control state resolver (NORMAL → CAUTIOUS → BLOCKED) evaluated every iteration</li>
<li style="font-size:16px;color:var(--ink-2);line-height:1.6;"><strong>Whether the output of this pass is good enough</strong> — verification layers that run before the loop either continues or exits</li>
<li style="font-size:16px;color:var(--ink-2);line-height:1.6;"><strong>What happens when a pass fails</strong> — named recovery strategies instead of a crash or a silent retry-forever</li>
<li style="font-size:16px;color:var(--ink-2);line-height:1.6;"><strong>When to actually stop</strong> — a stopping condition that isn't just "ran out of tokens"</li>
</ul>
<p>
Loops are the right tool for any agent operating in an environment where the correct number of steps isn't known in advance — most agentic use cases qualify, even ones that look like simple workflows at first.
</p>
<div class="tool-callout" style="background:var(--bg);">
<div class="tool-callout-label">In Build A Harness</div>
<p><code style="font-size:12px">world_model</code> · <code style="font-size:12px">control_state</code> · <code style="font-size:12px">verify_gate</code> · <code style="font-size:12px">recovery</code> · <code style="font-size:12px">exp_store</code> — these are the node types that implement what a plain workflow doesn't. Draw them on the canvas; Build A Harness generates the loop. <a href="https://buildaharness.com" style="color:var(--accent-ink);">See the tool →</a></p>
</div>
</div>
</section>
<section class="section alt" id="anatomy">
<div class="wrap">
<div class="section-label">ANATOMY</div>
<h2>The seven stages of an engineered loop</h2>
<p class="prose" style="margin-bottom:0;">
You don't need every stage for every use case. But each one addresses a specific failure mode that will surface in production if left unhandled. Start with the stages your agent needs today; add the rest as the failure modes appear.
</p>
<div class="layers-grid">
<div class="layer-card" style="border-left-color:oklch(.46 .18 290)">
<span class="layer-num">Stage 1 — Perceive</span>
<span class="layer-name">World Model</span>
<span class="layer-desc">Typed beliefs about the environment, contradiction detection, and generation_id tracking so the agent knows what it knows — and when that knowledge was formed.</span>
<span class="layer-without">Without it: the next iteration acts on stale or contradictory beliefs without knowing it.</span>
</div>
<div class="layer-card" style="border-left-color:oklch(.46 .14 148)">
<span class="layer-num">Stage 2 — Reason</span>
<span class="layer-name">Evidence & Hypothesis</span>
<span class="layer-desc">An evidence store, hypotheses from four generation sources, and a value-of-information gate that fires before every action.</span>
<span class="layer-without">Without it: the loop commits to the first plausible hypothesis instead of the best-supported one.</span>
</div>
<div class="layer-card" style="border-left-color:oklch(.46 .18 310)">
<span class="layer-num">Stage 3 — Decide</span>
<span class="layer-name">Control State</span>
<span class="layer-desc">A five-tier state resolver (NORMAL → CAUTIOUS → RESTRICTED → BLOCKED → HALT) evaluated fresh every iteration, plus deadlock detection that stops escalation loops.</span>
<span class="layer-without">Without it: no brakes — each pass escalates further when conditions degrade.</span>
</div>
<div class="layer-card" style="border-left-color:oklch(.52 .14 60)">
<span class="layer-num">Stage 4 — Act</span>
<span class="layer-name">Execution</span>
<span class="layer-desc">VOI-gated actions, a pre-execution review gate across safety, relevance, reversibility, resource, and alignment, and reversibility classification before any action fires.</span>
<span class="layer-without">Without it: an iteration takes an irreversible action without assessing the cost first.</span>
</div>
<div class="layer-card" style="border-left-color:oklch(.46 .18 20)">
<span class="layer-num">Stage 5 — Verify</span>
<span class="layer-name">Verification & Review</span>
<span class="layer-desc">Nine verification layers and an adversarial reviewer pass that check this iteration's output before the loop either continues or exits.</span>
<span class="layer-without">Without it: a bad pass feeds straight into the next iteration, or straight out to the user.</span>
</div>
<div class="layer-card" style="border-left-color:oklch(.52 .14 40)">
<span class="layer-num">Stage 6 — Recover</span>
<span class="layer-name">Recovery & Replanning</span>
<span class="layer-desc">Six named recovery strategies, a typed failure library, and local vs. global replanning scope, so a failed step is handled systematically rather than ending the run.</span>
<span class="layer-without">Without it: one failed tool call ends the session instead of triggering a recovery path.</span>
</div>
<div class="layer-card" style="border-left-color:oklch(.46 .12 148)">
<span class="layer-num">Stage 7 — Learn & Repeat</span>
<span class="layer-name">Memory & Experience</span>
<span class="layer-desc">Context compression so the loop doesn't truncate its own history, and an experience store so future runs warm-start instead of beginning cold — then the cycle repeats from Stage 1.</span>
<span class="layer-without">Without it: every run starts cold and long-running loops silently lose the thread of what they've done.</span>
</div>
</div>
<div class="tool-callout" style="margin-top:28px;background:var(--paper);">
<div class="tool-callout-label">In Build A Harness</div>
<p>All seven stages are implemented as drawable, composable node types — tested across 759 harness-layer tests. You do not write the loop's infrastructure: Build A Harness ships it. <a href="https://buildaharness.com" style="color:var(--accent-ink);">See the full node library →</a></p>
</div>
</div>
</section>
<section class="section" id="tool">
<div class="wrap">
<div class="section-label">THE TOOL</div>
<h2>Design once. <em>Run any framework.</em></h2>
<p class="prose" style="margin-bottom:0;">
Build A Harness is the open-source tool built for this discipline. It covers the full loop — from drawing the cycle on a visual canvas to compiling and running it in production — without locking you into a single framework.
</p>
<div class="process-steps">
<div class="process-step">
<span class="process-step-n">Step 1 — Design</span>
<span class="process-step-title">Visual canvas</span>
<span class="process-step-sub">Draw your loop using 27 node types — 14 execution nodes and 13 loop-control nodes that implement the full seven-stage cycle.</span>
<span class="process-step-detail">
input · output · llm_call · tool_invoke<br>
agent_role · agent_debate · condition<br>
parallel_fork · parallel_join · hitl_breakpoint<br>
world_model · control_state · verify_gate<br>
recovery · exp_store · reviewer_pass · +8 more
</span>
</div>
<div class="process-step">
<span class="process-step-n">Step 2 — Compile</span>
<span class="process-step-title">FlowSpec</span>
<span class="process-step-sub">The canvas exports to FlowSpec — a runtime-neutral, portable JSON format. One FlowSpec file runs on any supported framework without rewriting.</span>
<span class="process-step-detail">
Open format · version-controlled<br>
Framework-agnostic<br>
Third-party node packs supported<br>
(@buildaharness/nodes/…)
</span>
</div>
<div class="process-step">
<span class="process-step-n">Step 3 — Run</span>
<span class="process-step-title">Any framework</span>
<span class="process-step-sub">The same FlowSpec compiles to LangGraph, CrewAI, Mastra, or Microsoft Agent Framework. Switch runtimes without touching the loop design.</span>
<span class="process-step-detail">
LangGraph (Python / JS)<br>
CrewAI (Python)<br>
Mastra (TypeScript)<br>
MS Agent Framework (C# / Python / Java)<br>
A2A protocol (any A2A runtime)
</span>
</div>
<div class="process-step">
<span class="process-step-n">Step 4 — Observe</span>
<span class="process-step-title">Langfuse</span>
<span class="process-step-sub">Every iteration is traced automatically. Spans extend to world model generation_id, control state transitions, recovery strategy changes, and reviewer-pass findings.</span>
<span class="process-step-detail">
Per-iteration tracing<br>
Compare runs across frameworks<br>
HITL pause and resume<br>
REST · MCP · A2A deployment
</span>
</div>
</div>
</div>
</section>
<section class="section alt" id="quickstart">
<div class="wrap prose">
<div class="section-label">QUICK START</div>
<h2>Up and running <em>in two commands.</em></h2>
<p>
Everything runs locally via Docker. No cloud account, no API key required to start — use Ollama to run a free local model if you prefer.
</p>
<div class="quickstart-box">
<div class="quickstart-bar">shell</div>
<pre><span style="color:var(--ink-3)"># 1. Generate secrets and configure environment</span>
git clone https://github.com/3IVIS/buildaharness.git && cd buildaharness
./scripts/setup-env.sh
<span style="color:var(--ink-3)"># 2. Start all nine services</span>
docker compose up</pre>
</div>
<div class="services">
<div class="service-row">
<div class="service-dot"></div>
<span class="service-name">Canvas</span>
<span class="service-url">localhost:3000</span>
<span style="font-size:13px;color:var(--ink-3);">Visual loop editor</span>
</div>
<div class="service-row">
<div class="service-dot"></div>
<span class="service-name">API</span>
<span class="service-url">localhost:8000</span>
<span style="font-size:13px;color:var(--ink-3);">Compiles and runs FlowSpec</span>
</div>
<div class="service-row">
<div class="service-dot"></div>
<span class="service-name">Langfuse</span>
<span class="service-url">localhost:3001</span>
<span style="font-size:13px;color:var(--ink-3);">Observability dashboard</span>
</div>
</div>
<p style="margin-top:20px;">
Apache 2.0. <a href="https://github.com/3IVIS/buildaharness" style="color:var(--accent-ink);">Source on GitHub →</a>
</p>
</div>
</section>
<section class="section" id="faq">
<div class="wrap prose">
<div class="section-label">FAQ</div>
<h2>Questions, <em>answered.</em></h2>
<div class="faq-list">
<div class="faq-item">
<h3>What is loop engineering?</h3>
<p>The discipline of designing the iterative cycle an AI agent runs on every turn — what it perceives, what it believes, what it is allowed to do, how it verifies its own output, and how it recovers when a step fails — before looping back and doing it again.</p>
</div>
<div class="faq-item">
<h3>What is the difference between loop engineering and prompt engineering?</h3>
<p>Prompt engineering optimises a single model call. Loop engineering designs what happens between calls — the state carried forward, the stopping condition, the verification each pass, and the recovery path when a pass fails. In production, loop-level design accounts for the large majority of agent reliability gains; prompt refinement beyond a reasonable baseline accounts for a small fraction.</p>
</div>
<div class="faq-item">
<h3>What is the difference between a loop and a workflow?</h3>
<p>A workflow is a straight line: input, LLM call, tool call, output, done once. A loop is designed to run an unknown number of times, carrying state forward and deciding after each pass whether to continue, escalate, retry, or stop. Workflows suit deterministic linear tasks; loops suit agents operating where the right number of steps isn't known in advance.</p>
</div>
<div class="faq-item">
<h3>Is loop engineering the same as harness engineering?</h3>
<p>Yes — two names for the same discipline. <a href="https://buildaharness.com/harness-engineering" style="color:var(--accent-ink);">Harness engineering</a> emphasizes the constraint structure around the model; loop engineering emphasizes the iterative cycle that structure runs on. Build A Harness is the tool that implements both views at once.</p>
</div>
<div class="faq-item">
<h3>What is the "agent loop" people talk about?</h3>
<p>The repeating cycle an autonomous agent runs through: observe the current state, reason about it, decide on an action, execute it, check the result, and repeat until a stopping condition is met. Most agent failures — infinite retries, drift, compounding hallucination, silent context loss — trace back to a loop that was never explicitly designed, not to the underlying model.</p>
</div>
<div class="faq-item">
<h3>What is FlowSpec?</h3>
<p>FlowSpec is the runtime-neutral JSON format at the centre of Build A Harness. You design a loop once on the visual canvas and it compiles to a FlowSpec file. That single file then runs on LangGraph, CrewAI, Mastra, or Microsoft Agent Framework without rewriting.</p>
</div>
<div class="faq-item">
<h3>How do I get started with loop engineering?</h3>
<p>Clone <a href="https://github.com/3IVIS/buildaharness" style="color:var(--accent-ink);">github.com/3IVIS/buildaharness</a>, run <code style="font-size:13px">./scripts/setup-env.sh && docker compose up</code>, and open the canvas on <code style="font-size:13px">localhost:3000</code>. Five ready-made harnesses are included to fork and build on. No cloud account required.</p>
</div>
</div>
</div>
</section>
<section class="cta-section">
<div class="wrap">
<div class="cta-inner">
<div class="cta-text">
<div class="section-label">DESIGN A LOOP · POWERED BY BUILD A HARNESS</div>
<h2>Stop letting the loop<br>happen <em>by accident.</em></h2>
<p>Build A Harness implements the full seven-stage loop — world model, control state, verification, recovery, and cross-run learning — as drawable, composable nodes. Apache 2.0. Runs locally via Docker.</p>
</div>
<div class="cta-actions">
<a class="btn" href="https://github.com/3IVIS/buildaharness">Star on GitHub</a>
<a class="btn btn-ghost" href="https://buildaharness.com">Explore Build A Harness →</a>
<a class="btn btn-ghost" href="/">Back to Design a Loop →</a>
</div>
</div>
</div>
</section>
<footer>
<div class="wrap footer-inner">
<div class="footer-links">
<a href="https://github.com/3IVIS/buildaharness">GitHub</a>
<a href="https://buildaharness.com">Build A Harness</a>
<a href="https://buildaharness.com/harness-engineering">Harness engineering</a>
<a href="https://github.com/3IVIS/buildaharness/blob/main/LICENSE">Apache 2.0</a>
<a href="/">Design a Loop</a>
<a href="/privacy.html">Privacy</a>
<a href="/impressum.html">Impressum</a>
<a href="#" onclick="if(window.klaro)klaro.show();return false;">Cookie Settings</a>
</div>
<div class="footer-tag">
Design the loop. Ship it anywhere.
</div>
</div>
</footer>
</body>
</html>