Manuscript Offprint

arXiv:2611.06967

Call-Level Revision Contracts for LLM-Authored Workflows

Chenyang Jiang, Benyang Pan, Puqu Wu

Chenyang Jiang 1^{1}, Benyang Pan, and Puqu Wu

1^{1}South China Normal University, Guangzhou, China

Abstract—Durable execution engines replay a recorded history and do not compare activity payloads. When a model repairs a workflow that failed partway through, it must either pay again for calls that succeeded or accept a recorded result whose payload changed. We define a revision contract for workflows whose orchestration code is written by a model. Each capability call carries a structural identity built from its callsite, its fanout position, and its occurrence count, and the identity stays stable under rewrites that leave the call in place, so committed identities form a frozen prefix. The frozen unit is the call expression, and the surrounding code stays writable. A static gate rejects a rewrite that would change a committed call before a container starts. A runtime digest stops a changed payload at a committed identity, and an occurrence ledger names a repeated paid payload. Under three assumptions, a candidate the gate accepts replays every committed call it invokes, executes only new work, and reports the identities it skips. No local identity is both relocation-invariant and free of wrong reuse, so callsite identity turns a relocation into a pre-spend stop. On media workflows, 22 gate-passed repairs replay 258 committed identities with no duplicate, and a live six-way fanout makes seven paid calls instead of twelve. A 12-task customer-support study applies the same identity, replay, and boundary checks on two models.

Index Terms—Durable execution, workflow repair, LLM-authored workflows, revision contract, idempotency, replay, call identity.

I. INTRODUCTION

A repaired workflow may add work, but it must not pay twice for work that already ran, and it must not return a result that the repair has replaced. We make both properties an explicit contract for workflows whose orchestration code is written by a model.

Tasks that used to be a single model call are now small programs. A request for a thirty-second brand video with six shots becomes a plan for a storyboard and one image call per shot. Each image is reviewed, the failures are regenerated, and the result is composed. Our platform lets the model write the orchestration script itself, in a restricted Python subset with capability primitives such as ctx.run("image.generate", payload) and a broker that authorizes every call. The script may loop, fan out, retry, and branch on data that earlier calls produced, which a fixed DAG cannot express.

That flexibility has two failure modes, and both cost money. In the first, three shots are generated and paid for and the fourth call fails. The natural repair is to show the model the error and let it rewrite, and the rewritten script calls the provider for the first three shots again. The second mode is the reverse and is worse for the product. The model decides that a committed payload was wrong, for example a prompt, a size, or a seed, and edits it in place. A replay engine does not compare payloads, so it returns the recorded result and the run succeeds with the replaced artifact.

Neither gap is closed by a durable execution engine, which replays a recorded history, checkpoints after each workflow task, and requires the replayed code to issue the same commands in the same order. The guarantee is stated for the program that produced the history. A repair that moves a call into a helper still replays, because the command sequence is unchanged. A repair that edits a committed payload is served from the history, because the payload is not part of the key. Prior work formalizes resume for a fixed program [1], semantic step identity [2], runtime revision scope [3], and replay capsules under an unchanged source [4]. What a rewritten script may still touch is left open.

After a failure, the committed calls cannot change and the rest of the script can. The two sets are not separated by a line number, and under parallel calls arrive in an unstable order. In a loop, one source location executes many times, and formatting moves lines. Each capability call therefore carries a structural identity ι=(σ,π,ω)\iota = (\sigma, \pi, \omega), made of the callsite σ\sigma (enclosing function, block path, and call ordinal), the fanout path π\pi, and the occurrence counter ω\omega. None of the three depends on the payload or on arrival order, so a reordering cannot disguise a replay as a new call, or a new call as a replay.

The contract has three checks over a frozen prefix, and a bounded repair loop that uses them. Committed identities are durable, and a callsite with a committed occurrence is frozen. Before a container starts, a static gate rejects a candidate that removes a frozen callsite, changes its capability, or changes its call expression. At dispatch, a payload digest stops a call that reaches a committed identity with a different payload, so the run neither pays again nor returns a stale artifact. An occurrence ledger names a call at a new identity whose payload was already paid for at the same site and path. The repair loop returns structured counterexamples to the model, and a call-count check rejects a candidate that drops calls. Under the three assumptions of Section III, a candidate that the gate accepts never executes a committed identity.

The contract freezes the call expression and leaves the statements around it writable. A loop may grow, a bound may change, and prompt assembly may be rewritten. Moving a committed call into a helper is the harder case. The move preserves the capability, the payload, and the order, but the moved call has a new callsite, so under structural identity it is new work and would be paid for. The gate stops the candidate before any provider call. Section II walks through a real repair of this shape. Proposition 4 shows that no local identity can be both relocation-invariant and free of wrong reuse, so the choice is forced.

We evaluate the contract on media workflows and on a customer-support corpus, with a live image provider, two durable engines, and two model families. On eight real failures the model repairs every script within two rewrites, and the gate stops the one repair that would have paid for a committed call again. The spend advantage is strict when a failure falls inside a fanout, where a full rerun or an engine reset repeats the committed branches, and it disappears on a sequential tail repair, which Section VI reports.

Section II describes durable execution, the platform, and the repair that motivates the contract. Section III gives the model and the safety result, Section IV the mechanisms and their boundary, and Section V the implementation. Section VI reports the evaluation, Section VII what it covers, and Section VIII positions the work.

References (35)