Graph Engineering: Wiring Loops Together in AL Delivery
Note: This blog is a personal notebook. I write it to record what I work on, for my own reference, not to publish it on social media or to promote myself. If a post is still useful to you, I am glad, but that is not why it exists.
This post was published on July 06, 2026. Software versions, product features, links, and tool availability may have changed since then. Always check official documentation for the latest information. Some screenshots show small details. Zoom in on the page to see them clearly.
The harness post covered the tools an AL Copilot agent works with. The loop post covered a script that re-prompts the agent until a build passes. This post connects several loops into one AL delivery pipeline that can pause and resume.
Problem
A single loop suits one repeatable job, such as “fix compiler errors until the build passes.” A real AL per-tenant extension (PTE) change needs more checks. Does it compile? Does it pass tests? Does it match the request? One agent that tries all three in one long prompt mixes up the failures and produces a diff nobody can review well.
A long run can also stop halfway. A loop with no memory then restarts from zero.
Why this matters
- Small, separately checked steps are easier to review than one long agent run.
- A resumed run skips finished work, which saves time and API cost.
Architecture
Picture a print shop floor, not one workstation. A loop is one worker who repeats one job. A graph is the floor layout: fixed stations, a fixed order, and an inspection stamp at each station, so work can restart at the right place.
| Node | Job | Runs where |
|---|---|---|
| Code | Writes or edits the AL objects | Copilot agent mode or Claude Code, outside Business Central |
| Verify | Compiles and runs test codeunits | AL compiler and AL MCP Server, headless, outside Business Central |
| Review | Checks the diff against the requirement | Second agent pass or a human, outside Business Central |
Everything runs outside Business Central, and nothing touches a tenant automatically. A human still merges the pull request and publishes to a sandbox.
Demo steps: running the graph by hand
Prerequisites: an AL PTE project, GitHub Copilot agent mode or Claude Code, and the AL MCP Server available headlessly.
Scenario: add a Discount % field to a Sales Line table extension, with a page field and a 0 to 100 validation rule.
There is no script yet. You are the graph. You send one prompt at a time and record each finished step in a plain text file, state.json. Anyone can then pick the work up later without guessing.
- Code step. Send the prompt: “Add a
Discount %decimal field to table extensionSales Line Ext. Expose it on page extensionSales Line Page Ext. Add aValidateDiscountPctprocedure that errors outside 0–100.” When the agent finishes, write instate.json:{"node": "code", "commit": "<the git commit hash>"}This line is your bookmark: the Code step is done, for exactly this version of the code. - Verify step. Send: “Compile the app and run test codeunit
SalesLineExtTests. Report pass or fail.” On a failure, copy the error text into a new Code prompt and go back to step 1, up to three tries. On a pass, overwrite the bookmark:{"node": "verify", "result": "pass", "commit": "<same hash>"}The file always holds only your current position. - Review step. Send: “Compare the diff at commit
<hash>against the requirement: field, page exposure, 0–100 validation. Approve, or list what’s missing.” Approval means the commit is ready for a pull request. On a rejection, copy the gap into a new Code prompt.
To test resuming, stop after step 2 passes. Later, read state.json and go straight to the Review prompt, without re-running Code.
Graph engineering and the automated version
In the manual version, a person reads each result and decides the next move. A small script can do that, like a kitchen order ticket system:
- Memory is the same
state.jsonfile, read by the script. - A loop is the script asking again: did Verify pass or fail?
- The graph is the map of allowed moves. After Code comes Verify. A failed Verify goes back to Code, a limited number of times. A passed Verify goes to Review. An approval stops the run.
Only the question of who presses the next button changes. The script does not skip Verify, does not retry forever, and stops for a human when a pull request is ready.
What is intentionally simple
- No script yet: every prompt and state update is done by hand.
- One app, one small change, no parallel work.
Risks/limits
- The Review step sets the ceiling for the whole graph. A weak check lets bad diffs through.
- Handwritten state updates can drift from the real code if someone edits
state.jsonby mistake.
Next iteration
- Build the small script described above.
- Add a retry limit and a cost cap, so an automated run cannot loop forever.
Try it yourself
mb-copilot-al-graph-demo is a free VS Code add-on that runs this graph on a real AL project.
Install it, copy its hook folder into your AL project once (see the README), type /al-graph-start in Copilot Chat, and describe your change.
- Code runs first and offers a button to send the work to Verify.
- Verify builds the project, up to three times. A script counts each try and stops the build after three. The limit is code, not a request to a model, so it always holds.
- Review checks the diff against your request. It has no edit tool: it approves, or lists what is missing and sends the work back to Code.
The add-on writes state.json at the project root, so you can stop and later resume at the correct station. It never commits, publishes, or merges. “Approved” means ready for a human.
See the project page for install steps.
Closing note
Loop engineering repeats one task until one check passes. Graph engineering chains several checks, such as write, verify, and review, and a bookmark lets the chain pause and resume. A loop is one worker. A graph is several workers in a fixed order, and each one knows who goes next.