Bounded Agents and Memory
Autonomy is justified only when model judgment improves outcomes enough to pay for a larger failure surface. This stage compares a bounded agent with simpler workflows while making plans, budgets, termination and memory semantics inspectable.
Section 5 of 8 · 10 units · about 45 hours
By the end you can Compare deterministic, routed and bounded-agent paths on the same tasks and tools; prove hard termination and authority limits; evaluate memory utility and poisoning; then defend whether the added autonomy earns its quality, latency, cost and failure burden.
Units
- Workflow versus agent choice, and the routed, planned and evaluator-optimizer patterns4h
- A plan, act, observe and verify loop over an explicit state graph with stop reasons5h
- Hard budgets, progress measures, termination and loop detection4h
- Tool selection, observation grounding and stale results4h
- Layered agent evaluation and a failure taxonomy for agents5h
- Deterministic and routed baselines against the agent on identical tasks4h
- Working, checkpoint and durable memory, with a provenance-carrying write policy5h
- Memory conflict and supersession, authorization, retention and deletion5h
- Memory utility, privacy and poisoning evaluation4h
- Sandboxed runs, operator intervention and one bounded delegation5h
Build it
Mini project · about 18 to 24 hours
Bounded autonomy and scoped memory against simpler workflow controls
Extend agentlab in agent/ with explicit control, memory and intervention policies over the existing grounded durable workflow. Test mechanisms with CPU fakes and the section's pinned Python libraries before optional trials using a small open model behind your local OpenAI-compatible server, without paid APIs. Keep autonomy and memory only where evidence justifies them.
- 1Record the pattern choice and build fixed, routed and framework-free plan-act-observe-verify paths over the same task contract, tools and durable executor. Check transitions and premature completion against independent recipient-state verifiers; retain terminal-reason tests and observation-driven replay that invokes neither models nor effects.
- 2Extend shared admission to steps, tools, retries, rendered tokens, context, synthetic spend, effects and deadlines. Check reservations, no-progress detection and hangs against independent fake-clock ledgers, and argue why admissions stay finite. Bind observations to calls, scope and resource versions; retain tool-choice, stale, expired, wrong-scope and error fixtures with effect counts.
- 3Map working state, checkpoints, durable preferences and external knowledge by owner and lifetime. Stage provenance-carrying writes with source versions, scope, times, confidence basis and expiry; check independent admissibility fixtures. Retain forged-provenance, inferred-preference and instruction rejection, fresh-session reload and tests preventing promotion into executable policy.
- 4Implement scoped conflicts, corrections and supersession with valid-time and recorded-time history. Against an independent assertion/event table, test overlapping tenant/user keys, session overrides, historical reads and expiry cutoffs; retain deletion propagation through summaries, indexes, reuse and checkpoints, including old-checkpoint restoration and content-free audit evidence.
- 5Run isolated fake tools with host-enforced filesystem, network, process and resource limits, recording unavailable controls. Test pause, exact approval, rejection, cancellation and resume against durable admission records; retain LangGraph's repeated pre-interrupt effect regression and restricted delegation with inherited budgets, malformed artifacts, timeout and permission-expansion denial.
- 6Seed goal, capability, context, plan, tool, state, memory and evaluator failures. Score prerequisites, selection, execution, process guardrails and final state against independent fixtures, including a grader accepting completion text; retain first-divergence evidence and controlled oracle substitutions without forcing every valid trajectory into the same sequence.
- 7Repeat paired held-out comparisons with fixed items, graders, environments, tools and budgets: fixed/routed/agentic control, no-memory/raw-history/policy-memory, and delegated versus single-agent execution. Retain matched-consumption analyses, uncertainty, failed trials, full resource/intervention ledgers, poison admission/retrieval/effect denominators and benign utility; defend keeping or removing each addition, labeling fake-only capability unmeasured.
What you hand in
agent/control paths, budget ledger, memory policy and bounded delegation using the existing gateway, context compiler, tools and durable executor.- Independent state, observation, memory, cancellation and replay regressions in
tests/, with versioned scripted failures infakes/. - Item-level architecture and memory comparisons in
reports/, including privacy, poisoning, costs, interventions, negative evidence and keep-or-remove decisions.
How to check it
- Self-grade with the rubric below
- LangGraph interrupt restart fixture
Use the section's pinned LangGraph; demonstrate repeated pre-interrupt work and protect effects with exact consent and recipient idempotency.
How it's graded
Bounded grounded control
Pass: Your transition and recipient oracles reject false completion; reservation and fake-clock tests bound admissions, hangs and replanning. Observation tests reject stale, expired, failed and wrong-scope evidence before effects; replay reproduces terminal reasons.
Great: A finite-admission argument covers every recovery path, and unknown usage or effect outcomes never replenish allowances. Selection, argument correctness, execution and outcome remain independently measurable.
Scoped memory lifecycle
Pass: Your independent admission and assertion tables validate lineage, reload, conflict, supersession, historical reads, tenant/user denial and expiry. Deletion tests block derived summaries and old-checkpoint resurrection under a declared purge contract.
Great: Corrections preserve what was known at earlier decisions without retaining deleted content in audit exports. Held-out poison-stage counts and benign false rejections bound claims about privacy and useful recall.
Operator and delegation authority
Pass: Your positive-control isolation probes and admission traces validate exact approval, rejection, cancel/resume and repeated interrupt work. Delegation reserves parent resources and rejects malformed, late or scope-expanding artifacts; unavailable isolation remains untested.
Great: Cancellation awaits active-process termination and prevents later dispatch without pretending to undo committed effects. A restricted delegated result cannot expand policy, reset budgets or bypass independent artifact verification.
Comparable decision evidence
Pass: Your oracle-substitution replays support layered attribution. Repeated paired control, memory and delegation comparisons preserve failures, actual consumption, uncertainty and intervention costs; independent item records regenerate decisions without requiring any addition to win.
Great: Matched-consumption controls expose extra sampling or preprocessing confounds. Poisoned context, factual corruption and executed harm remain distinct; negative results justify simpler designs, and scripted behavior never becomes measured model capability.
Resources
- AI Agents in DepthBojie Li
Read 1.2.4 Orchestration Patterns for the workflow-versus-agent choice (the book argues for less structure; this track keeps deterministic authority), 3.1 user memory with 3.3.3, 5.1.5 for repeated-call fingerprints, circuit breakers and turn and budget ceilings, and Chapter 10 (10.1 to 10.5) for when multi-agent coordination helps or fails. Implement one bounded loop before any delegation.
- Building Effective AgentsAnthropic
Study augmented models, prompt chaining, routing, parallelization, orchestrator-worker and evaluator-optimizer, then "Agents". Select the simplest pattern that meets the task and document why more autonomy is or is not justified. The post now opens with a note that its December 2024 tooling list is out of date; use it for the patterns, not for framework advice.
- AI Engineering Handbook - Agent EngineeringHandbook Academy
Read Part 7 chapters 7.0 Workflow vs agent (the compounding-error arithmetic), 7.1 The five workflow patterns, 7.2 The agent loop (stop conditions; reflection needs an external check), 7.6 Agent memory and task state, 7.8 Long-running agents (four budgets, kill switch versus circuit breaker, checkpointing is not recovery) and 7.12 Choosing a framework. Treat 7.9 multi-agent systems as optional until a single-agent baseline is measured.
- AI Agents That MatterKapoor, Stroebl, Siegel, Nadgir and Narayanan
Read Section 2 (cost-controlled evaluation: on HumanEval, simple retry, warming and escalation baselines matched the best agent architectures in accuracy at lower cost; plot accuracy against cost as a Pareto frontier) and Table 1 in Section 5 (which benchmarks have proper holdouts). The result is limited to that benchmark and April 2024 prices; the method is the point. Report every agent result next to a non-agentic baseline and its cost. Preprint, no venue.
- Agentless: Demystifying LLM-based Software Engineering AgentsXia, Deng, Dunn and Zhang
Read the Section 1 limits of agent approaches, the Section 3 overview and Table 1: a fixed localize, repair and validate pipeline rivaled agents on score and cost. Use it as the worked non-agentic baseline; its numbers are not a target.
- ReAct: Synergizing Reasoning and Acting in Language ModelsYao et al. (ICLR 2023)
Read Sections 1 to 3.3 and Section 4 up to Table 4: the interleaved thought, action and observation loop and the hand-labeled failure modes of Table 2. On HotpotQA, ReAct alone scored below chain of thought; the gain came from combining them. It is the primary citation for the loop, not a design to copy.
- The Hitchhiker's Guide to Agentic AI - Memory and Agent PatternsHaggai Roitman
Use v3 Chapter 17 (17.4 memory writes, conflicts and bi-temporal facts), Chapter 19 loop engineering (19.7 termination, 19.8 stagnation and escalation, 19.9 failure taxonomy) and Chapter 21 agent design patterns. Chapters 24 to 26 (skills, A2A, multi-agent) are only for a bounded depth comparison.
- AlgoMaster AI Engineering - AgentsAlgoMaster
Read the free lesson
what-are-ai-agents("The Autonomy Spectrum", "When to Use Agents, Pipelines, or Chatbots", "Building a Minimal Agent Loop"), then the owned premium lessonsagent-memory-systems,agent-reliability-and-debugging,human-in-the-loop-patternsandlong-running-agents. Rebuild one loop without a framework under the same tasks, budgets and failure cases. - LangGraph Persistence, Interrupts and Graph APILangChain
At langgraph 1.2.16, read the Graph API "Reducers" and "Recursion limit" sections,
checkpointers(core concepts, durability modes),interrupts("Rules of interrupts": a resumed node reruns from its start) andstoresfor long-term memory. The page says the default recursion limit is 1000 but the 1.2.16 code default is 10007, so setrecursion_limityourself. Build one graph only after the framework-free loop passes its tests; skip the prebuilt agent templates. - OpenAI Agents SDK: Running Agents and HandoffsOpenAI
At openai-agents 0.24.0, read
running_agents("The agent loop": final output, handoff or tool call,max_turns) and the first screen ofhandoffs. ItsScriptedModelruns the loop with no key and no server, a reference for deterministic fake models. Disable tracing export for local runs. - Pydantic AI: Usage LimitsPydantic
At pydantic-ai 2.57.0, read the "Usage Limits" section of the agent page: request, tool-call, token and cost limits (the tool-call limit is checked before tools run; cost limits are best effort). Compare it with your own budget object and test it with
FunctionModel. - A Practical Guide to Building AgentsOpenAI
Read pages 5 and 6 (when to build an agent) and 14 and 15 (the run loop and its exit conditions). The rest repeats Building Effective Agents; its guardrail pages are weaker than this track's security sources.
- Cognitive Architectures for Language Agents (CoALA)Sumers, Yao, Narasimhan and Griffiths (TMLR 2024)
Read Section 4.1 (working memory and the long-term episodic, semantic and procedural stores; writing to procedural memory is riskier than writing to episodic or semantic memory) and Section 4.5 (learning actions, the writes). Its working memory is broader than the context window. Use it to name each store in your design and its write rule.
- Generative Agents: Interactive Simulacra of Human BehaviorPark et al. (UIST 2023)
Read Section 4.1 (memory stream; retrieval scored by recency, importance and relevance), 4.2 (reflections as derived memories that point to their sources) and 6.5.2 (embellished recall). Recency decays from the last retrieval, not from creation, and nothing supersedes a wrong memory: test both in your store.
- MINJA: Memory Injection Attacks on LLM Agents via Query-Only InteractionDong et al. (NeurIPS 2025)
Read Section 3 and Section 5.4: an attacker acting as an ordinary user plants records in a shared memory bank through queries alone, because the agent stores its own reasoning after user feedback, and later users retrieve them. Use it to decide which memories are per user, which are shared and who may write each.
- MemGPT: Towards LLMs as Operating SystemsPacker et al.
Read Sections 2.1 to 2.4 for the tiered memory vocabulary (main context, recall and archival storage, eviction under memory pressure). Its writes are entirely self-directed by the model, with no provenance or review; your write policy and deletion rule come from your own specification.
- Reflexion: Language Agents with Verbal Reinforcement LearningShinn et al. (NeurIPS 2023)
Read Section 3 and Section 4.3: verbal self-reflection stored in an episodic buffer between trials. Compare it at equal cost against plain retries, as AI Agents That Matter does, before crediting the memory.
- Context Personalization: Memory Lifecycle and GuardrailsOpenAI Cookbook
Read "4. Memory Lifecycle" (distill, consolidate, inject) and "Memory Guardrails": the precedence order is the current user message, then session context, then memory. It is SDK specific and lists principles without attack fixtures; take the lifecycle, not the code.
- Agent2Agent (A2A) Protocol Specification 1.0.0A2A Project
Read 1.2 (opaque execution), 3.4 (task and context ids), 4.1.3 TaskState (nine values, including
TASK_STATE_INPUT_REQUIREDandTASK_STATE_AUTH_REQUIRED), 4.4.1 AgentCard, 7.5 and 7.6 and Appendix B (relationship to MCP). Authorization is implementation specific (7.5): the protocol says where to ask, not what a grant means. Field names changed from 0.3.0, so older posts are stale. - How We Built Our Multi-Agent Research SystemAnthropic
Read after the single-agent comparison. Extract the parallelization assumptions, delegation contracts (objective, output format, tools and boundaries for each subagent) and evaluator strategy. The benefits section gives the cost: agents use about 4x the tokens of chat and multi-agent systems about 15x. Test one small coordinator-worker variant only if your workload has independent search branches.
- No Magic - ReAct LoopNo Magic
Read the agent README and trace
microreact.pyfor the shape of the reason, act and observe loop. It has no language model or tool schema, so it illustrates control flow only. - HTTP Semantics: validators and conditional actionsIETF / RFC Editor
RFC 9110 Sections 8.8.1 and 13.1.1 only: carry an observed resource version into a conditional action so stale observations cannot silently authorize an overwrite. Apply the mechanism to fake tools, not a second HTTP course.