Plan mode for agents
Plan errors
Every plan error carries retryable and next_action, so an agent knows what to do without guessing.
Every error is an RFC 7807 problem with a stable code. The PLAN_*
codes, API_KEY_PLAN_ONLY and TRANSACTION_RETRYABLE also carry retryable and
next_action. Act on next_action.
The same table is in the error_codes field of
GET /v1/plans/capabilities, so an agent can read it at
run time.
next_action
next_action | Do this |
|---|---|
fix_step | Change the step named by pointer, preview again. |
re_preview | Preview again, read the differences, then commit the new plan_id. |
retry_later | Wait a few seconds and send the same request again. |
split_plan | Break the plan into smaller plans; give them one session_id to undo them together. |
use_plan_mode | Send this write through POST /v1/plans/preview and POST /v1/plans. |
release_first | (on PLAN_UNDO_BLOCKED) If a blocker's blocking_run_id is set, undo that run or its session first. Otherwise remove the outside reference, or correct the records through the normal edit and void routes instead of undoing. |
contact_operator | Stop and tell the person you work for. |
Codes
| Code | HTTP | Retryable | next_action |
|---|---|---|---|
API_KEY_PLAN_ONLY | 403 | no | use_plan_mode |
PLAN_DRIFT | 409 | no | re_preview |
PLAN_DUPLICATE_REF | 422 | no | fix_step |
PLAN_NOT_FOUND | 404 | no | fix_step |
PLAN_NOT_HELD | 409 | no | contact_operator |
PLAN_ORG_BUSY | 409 | yes | retry_later |
PLAN_RAW_DB_ACCESS | 500 | no | contact_operator |
PLAN_REF_FORWARD | 422 | no | fix_step |
PLAN_REF_UNRESOLVED | 422 | no | fix_step |
PLAN_ROUTE_NOT_PLANNABLE | 422 | no | fix_step |
PLAN_TIMEOUT | 504 | yes | split_plan |
PLAN_TOO_LARGE | 413 | no | split_plan |
PLAN_UNDO_BLOCKED | 409 | no | release_first |
PLAN_UNDO_CONFLICT | 409 | no | contact_operator |
TRANSACTION_RETRYABLE | 409 | yes | retry_later |
Notes
PLAN_ORG_BUSY: one plan runs per org at a time, and a few per server. A second one is refused at once rather than queued.PLAN_TIMEOUT: the plan ran past its 20 s budget. Nothing is kept.context.reportshows the steps that ran; the rest areskippedwithreason: time_budget.API_KEY_PLAN_ONLY: the key may write only through plan mode. ItsGETcalls work as usual.- Idempotency codes carry no
next_action:IDEMPOTENCY_KEY_REQUIRED(400, add the header),INVALID_IDEMPOTENCY_KEY(400, fix the key's format),IDEMPOTENCY_CONFLICT(409, the key was used with a different body; use a new key). See Retrying a commit. - A bad plan shape (missing
steps, a header name not allowed,allow_driftwithsteps) is400 VALIDATION_FAILEDwithcontext.pointer.
Every code, plan or not, is in the error code catalog.