{"slug": "agents-as-reconciliation-loops", "title": "Agents as reconciliation loops", "summary": "Redowan's Reflections published a post describing a reconciliation-loop pattern the author now uses for nearly every agent built across AWS Strands, Google ADK, LangGraph, OpenAI Agents SDK, Pydantic AI and the Claude Agent SDK. The pattern splits each agent run into four stages — observe, decide, apply and report — so that decide returns a plan as plain data and changes nothing, while apply carries out the plan, letting the author log the plan before execution, skip apply for a dry run, and replay recorded state through decide in tests. The author argues this separation, modeled on Kubernetes controllers and Andrew Godwin's reconciliation-loop talk, gives visibility that a typical tool-calling loop lacks, where the model reads and mutates state in the same turn.", "body_md": "[Redowan's Reflections](https://rednafi.com/)\n\n# Agents as reconciliation loops\n\n## Table of contents\n\nOver the past year, I’ve written a handful of agents. Some of them handle production traffic\nat work, and a couple run on a Raspberry Pi on my desk. I’ve written agent loops by hand and\nused most of the popular frameworks: [AWS Strands](https://strandsagents.com/), [Google ADK](https://google.github.io/adk-docs/), [LangGraph](https://www.langchain.com/langgraph), [OpenAI\nAgents SDK](https://openai.github.io/openai-agents-python/), [Pydantic AI](https://ai.pydantic.dev/), and the [Claude Agent SDK](https://docs.claude.com/en/api/agent-sdk/overview). Along the way, I settled on a\npattern that I now use for nearly every agent, regardless of the framework.\n\nNote\n\nBy agent, I mean a model plus a harness. The harness is the glue code around the model that does things on its behalf, like calling tools, reading files, and talking to other services.\n\nAgents can be triggered by an API call, an event, or a cron job. Once awake, the agent typically follows the same steps, and each run is one pass of a reconciliation loop.\n\n## Reconciliation loops \n\nIn [Reconciling Everything](https://www.youtube.com/watch?v=MuK6lmsfX1E), Andrew Godwin describes a reconciliation loop as stateless\nprograms that talk to one source of truth. Each program reads the current state and finds\nsomething that doesn’t match the desired state. It takes a small step to close the gap,\nwrites the result back, and starts again.\n\nKubernetes is the best-known example. You declare what you want in an object’s `spec`, and a\n[controller](https://kubernetes.io/docs/concepts/architecture/controller/) runs a loop that:\n\n- watches the API server for changes to the objects it manages\n- compares the desired state in the `spec` with the current state of the cluster\n- asks the API server for the changes that close the gap\n- records what it saw in the object’s `status`\n\n## Observe, decide, apply, report \n\nAn agent run works the same way, with your prompt or rules defining the desired state.\n\nIn code, a run looks like this:\n\n``` php\ndef reconcile(trigger: Trigger) -> None:\n    state = observe(trigger)\n    plan = decide(state)  # returns data, changes nothing\n    result = apply(plan)\n    report(result)\n```\n\nSay you’re building an agent that labels and assigns open GitHub issues:\n\n- `observe` fetches the current`state` , like the open issues that still need triage.\nUsually this is plain code calling an API. If fetching the data directly is cumbersome or\nfinding the right context takes judgment, it can ask a model to use read-only tools\ninstead.\n- `decide` compares`state` against your prompt or rules and returns a`plan` as plain data,\nlike which labels and owners each issue should get. You can write it in ordinary code, or\ncall an LLM or a decision model.\n- `apply` carries out`plan` and makes the changes on GitHub. Depending on the job, it runs\nthe steps directly or hands them to subagents or a swarm.\n- `report` turns`result` into a summary and handles notifications, like posting what\nchanged to Slack.\n\nIn a typical tool-calling loop, the model reads state and mutates it in the same turn. You\ncan’t see what it’s about to do before it acts. Splitting `decide` from `apply` gets you\ncloser to [functional core, imperative shell](https://www.destroyallsoftware.com/screencasts/catalog/functional-core-imperative-shell). Calling a model over the network means\n`decide` isn’t strictly pure, since you still have I/O and non-determinism. Still, it never\nmodifies the system you’re managing, and every change happens in `apply`. Because the plan\nis plain data, I can log it before anything runs or skip `apply` for a dry run. I can also\nreplay recorded state through `decide` in tests.\n\nOne call to `reconcile` is a single pass, which is enough for an agent behind an API\nendpoint. Put the same function on a schedule and it becomes a loop. As long as `observe`\nsees the effect of `apply` on the next run, the agent doesn’t need its own state or\ncheckpointing. Say that GitHub triage agent crashes halfway through a run. GitHub holds the\nstate, so the next run just finds whichever issues are still unlabeled and finishes the job.\n\nIf you want to see how this looks in real code, I have put together a single-pass example in\n[this gist](https://gist.github.com/rednafi/2a6ba6ae79f935f6e011df9377fb57e9). It’s an agent written with the AWS Strands SDK that finds the most\ncontroversial stories on Hacker News and summarizes them.\n\nOutside of software, I’m also building an agent that moves the arms of a servo robot, and this loop fits each individual movement perfectly. Maybe I’ll write about it at some point.", "url": "https://wpnews.pro/news/agents-as-reconciliation-loops", "canonical_source": "https://rednafi.com/ai/agent-reconciliation-loop/", "published_at": "2026-12-01 23:00:00+00:00", "updated_at": "2026-12-02 22:47:40.316205+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools"], "entities": ["Redowan's Reflections", "Andrew Godwin", "AWS Strands", "Google ADK", "LangGraph", "OpenAI Agents SDK", "Pydantic AI", "Claude Agent SDK"], "also_reported_by": [], "takeaway": "Split each agent run into observe, decide, apply and report so decide returns a plain-data plan without mutating state, enabling pre-execution logging, dry runs and replaying recorded state through decide in tests.", "recommendation": {"advice": "Separate decide from apply in your agent loop so the plan is plain data you can log, dry-run and replay in tests before any state changes.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/agents-as-reconciliation-loops", "markdown": "https://wpnews.pro/news/agents-as-reconciliation-loops.md", "text": "https://wpnews.pro/news/agents-as-reconciliation-loops.txt", "jsonld": "https://wpnews.pro/news/agents-as-reconciliation-loops.jsonld"}}