Plan mode for agents
Let an AI agent describe a multi-step build, see exactly what it would do without keeping anything, fix it, then commit it all-or-nothing and undo it if it was wrong.
An agent that sets up a portfolio makes dozens of calls: a legal entity, its properties, a lender, a loan, the loan's activation. Called one by one, a mistake on call 14 leaves 13 records behind, and nobody sees the journal entries, the scheduled jobs or the events until they have already happened.
Plan mode turns that build into one reviewable unit. The agent sends the whole list of
/v1 calls as a plan. Acreum runs it for real inside one database transaction, reports
every row, journal entry and follow-on effect it produced, and then rolls it all back. When
the report shows what the agent meant, it commits the same plan. If the result is still
wrong, one call undoes it.
Start here: GET /v1/plans/capabilities
Before its first plan, an agent calls
GET /v1/plans/capabilities once. It answers, in one
response, which routes a plan may call, the limits, how one step refers to another, which
headers a step may send, and every plan error with what to do about it. The values come
from the same code that enforces them, so they are always current.
The loop
Learn the rules. GET /v1/plans/capabilities, once per session.
Read. Look up what already exists, or put the lookups in the plan as GET steps.
Preview. POST /v1/plans/preview with the whole plan. Nothing is kept.
Fix. Read summary.first_error and each step's error, change the plan, and preview
again until there are no errors and the report shows what you meant.
Commit. POST /v1/plans with { "plan_id": "<the preview's plan_id>" } and an
Idempotency-Key.
Read back, and undo if wrong. GET the records you created. If something is off,
POST /v1/plans/{id}/undo and go back to Preview.
What a preview tells you
A preview is not a guess. Every step is a real call to its real route, with your own credentials, scopes and validation. The report shows:
- Every step's response or error, with a JSON Pointer into the plan you sent.
- Every row written, grouped by step and table, including rows no step returned (accounting periods, search entries, schedules).
- Every journal entry posted, with its lines and totals.
scheduled_effects: which scheduled jobs will act on the new rows after a commit, and when they next run. For a new loan that is accrual generation, rate resets and the rolling schedule window.would_fire: the events and background jobs the commit would start, such asLoanActivatedEvent.
So an agent, or the person supervising it, sees the whole consequence of a build before any of it is real.
Safety by construction
- A plan never grants anything. Each step runs with the caller's own credentials, so a plan can do exactly what the caller could do directly, nothing more.
- All or nothing. A commit keeps every step or none of them.
- What you previewed is what commits. A commit by
plan_idmust write the same rows and answer the same responses as the preview. If the data changed in between, it is refused withPLAN_DRIFTand nothing is kept. - Undo is real. A committed run can be undone until something outside it depends on its rows. A run that posted to the ledger is undone by voiding through the normal void path, so the reversal is visible in the books.
- Every step is audited like any other API call.
Scopes
| Scope | Allows |
|---|---|
plans:preview | GET /v1/plans/capabilities, POST /v1/plans/preview, and reading runs and reports |
plans:commit | POST /v1/plans (commit), POST /v1/plans/{id}/undo, session undo |
plans:release | Committing or undoing a run another principal previewed or committed |
The steps inside a plan also need the scopes of the routes they call: a plan that creates a
loan needs loans:write as well.
Capabilities
The one call that teaches an agent plan mode.
Write a plan
Steps, references between steps, GET lookups and step headers.
Read the report
Rows, journal entries, scheduled effects and what a commit would fire.
Commit and undo
Drift checks, safe retries, undo and sessions.
Errors
Every plan error code with next_action.
Worked example
A 6-step portfolio onboarding and its real report.