LazyAgent: Demand-Driven Materialization and Physical Optimization of Agentic Programs
Organizations: Tote AI
Abstract
Current agent runtimes that plan before acting generally execute a step once it becomes ready. We present LazyAgent, a unified execution framework for agent-authored programs organized around a live, goal-derived demanded set. LazyAgent refreshes a backward closure from requested outputs as execution state changes and materializes a ready node only when the active goal requires it. This replaces repeated local judgments with one linear-time graph analysis followed by constant-time membership tests, allowing programs to remain broad while execution stays request-specific. On programs that describe more than the current request needs, LazyAgent consistently outperforms the strongest goal-stopping eager baseline by refusing unrelated work before it starts. Adding one unrelated product raises the eager bill by 22.5% and LazyAgent's by 0.0%. LazyAgent saves 42.0% of measured CPU on production scientific workflows and 51.7% of container time on a live release gate spanning four repositories. We also prove and verify exact equivalence when the request reaches the whole graph, leaving no unrelated work to avoid. Beyond permission, goal-relative output projection saves up to approximately 90% of a shared step on two third-party test suites while the identical eager control saves 0.0%; the advantage disappears when the omitted output has no other consumer or the request needs it. Ordering, reuse, and pruning can also save cost, but do not replace permission. Finally, we show that current public benchmarks are eager-shaped and contain almost no unrequested work. A pre-registered planning intervention did not broaden them. These findings motivate benchmarks built from standing programs and sequences.
Figures & tables
| System or line of work | Goal- relativity | Demand re-evaluated on observation | Ready-queue ordering | Field projection | Commit barrier |
|---|---|---|---|---|---|
| Declarative and incremental execution | |||||
| Make, Bazel [ 14 , 8 ] | S | ||||
| Build systems à la carte [ 30 ] | S | ✓ | ✓ | ||
| Adapton [ 18 ] | S | ✓ | |||
| TensorFlow graph mode [ 1 ] | S | ||||
| Volcano, Eddies [ 17 , 7 ] | S | ✓ | ✓ | ✓ | |
| Arena | Mode | Cost unit | Shape | What it is |
|---|---|---|---|---|
| WfCommons / WfInstances [ 13 , 15 ] | replay | measured CPU s | multi-product | 154 readable production scientific-workflow traces, 86 with several output products; 303 seeded product requests. |
| DataSciBench [ 48 ] | live | real tokens | multi-product | The benchmark supplies executable dependency-structured plans; our adaptation retains 95 goals over 28 tasks, including 28 multi-goal follow-up tasks. |
| SWE-bench Verified [ 20 , 40 ] | replay; live gate | recorded; container seconds | pool | 500 human-validated tasks; also the substrate for a live release gate with real agent patches run in Docker. |
| Defects4J v1.1 [ 21 , 39 ] | replay | wall seconds | pool | 395 bugs; 185 settle under our replay criterion; also composed into portfolios. |
| SimulCost [ 10 ] | replay; live | analytic cost | pool | 2,304 multi-round problems from the pinned arXiv v3 release; also composed into portfolios. |
| Bazel [ 8 ] | replay | action CPU s | build graph | 419 native targets on two production packages; exploratory second structural domain. |
| Study | Mode | Headline vs stop_eager | Control | |
|---|---|---|---|---|
| WfCommons permission | replay | 303 requests | 42.0% [37.5, 46.7]; 211 / 0 / 92 | 68 single-product instances give exactly 0.0% |
| WfCommons shape law | replay | 235 observations | 50.3% (one product), 21.4% (half), 0.0% (all) | 86 / 86 exact ties when the goal names everything |
| Pool arenas (SWE-bench, SimulCost, Defects4J) | replay | 3,199 asks | 0.0% , bit-identical bills | Predicted by Prop. 2 ; a saving here would be a bug |
| DataSciBench, agent-authored | live | 95 goals, 28 tasks | 12.8% clustered [7.7, 18.2]; 15 / 0 / 13 | Quality matched on every task |
| Portfolio position sweep | replay | 3,572 rows | 0.0% asking first 85.5% asking last | 893 / 893 all-products ties; 0 losses |
| Program width, | replay | 10,680 rows | capture 100% ( lazy ) vs 0% open / 50% settleable | 2,538 / 2,538 controls tie; deltas 100% off-path |
| Operation | Arena | Costs | Result | Read it as |
|---|---|---|---|---|
| Project | Live DataSciBench, 95 goals | live | ; narrow asks bill ; no significant blind-judge preference ( ) | Fewer tokens; no detected preference |
| Project | Authored isolation pair | authored | (named consumer) vs (no consumer) | Pays iff the dropped field has another consumer |
| Project | CI verify job, 2 third-party repos | measured cpu | , (named, off-path); with no consumer and when both demanded | Same shape, prices from a clock; controls zero independently |
| Project | Authored sessions, coverage sweep | authored | , ; | Grows as session coverage falls |
| Fidelity | Authored ladder, named consumer / no consumer / needed | authored | / / | Projection one granularity down; sign pattern, not magnitude |
| Reorder | No rule may stop the run; 5 arenas, every task | ex-ante, replay, live | 0.0% bill change, incl. 8 random orders | Exact identity under C1–C3 |
| Cell | Cost unit | Preconditions | Result |
| All three hold — separation predicted | |||
| Live release gate, SWE-bench | container seconds | all three | , |
| Live projection, Jinja and Flask | measured CPU s | all three | , |
| Composed portfolios, Defects4J and SimulCost | native arena costs | all three | separation region |
| DataSciBench projection | real tokens | all three | pooled; on the 126 narrowable nodes ( gpt-5.6-terra ; sign is planner-bound, § 8.4 ) |
| Fidelity ladder | authored | all three | ; magnitude authored |
Appendix figures & tables6 assets
Supplementary material from the paper’s appendix.
Appendix
| Limitation | Where | How we handle it, or why it stands |
|---|---|---|
| Largest separation result is replayed workflows, not LLM programs; product requests are seeded, not observed | § 7.1 | The agentic arena carries the live version of the same claim at smaller magnitude; we never pool the two |
| Near-complete coverage has a structural benchmark-design account; its historical cause is not identified | § 5 , § 7.5 | The census (98.6% demanded, 27 of 28 plans with no off-path work) is measured. Across 168 valid plans from three paired repeats, demand billing produced 0.0% off-path work against 0.8% under readiness billing (paired per-plan difference points [ , ], ); the prompt-level null rules out the tested billing intervention as evidence, not the benchmark-design account |
| Agentic corpus sits at session coverage , so the effect there is small | § 7.4 | Reported as a property of the corpus, with a node-level census; the conditional and the average are both given |
| Portfolio topology is authored | § 7.6 | Native costs, exhaustive position sweeps, retained zeros, exact-tie controls, setup-share sensitivity, normalization by opportunity |
| The four widths regroup one task pool rather than forming four datasets | § 7.7 | Stated; capture rates rather than raw savings are the quantity compared across widths |
| Each live gate run is 12 rows from 4 clusters | § 7.8 | Case study, never a population claim; smallest exact Wilcoxon at 4 clusters is 0.125 and no is quoted off it |
| Limitation | Where | How we handle it, or why it stands |
|---|---|---|
| Fidelity’s magnitude is authored, not measured | § 8.2 | Projection has measured support: on live DataSciBench tokens and / on measured Jinja/Flask CPU. Fidelity remains authored ladder arithmetic, so only its sign and two zero controls transfer |
| Every remainder is computed in one resource | § 8 | Prune already shows the resource can decide the verdict while the factorial stays internally consistent; the other rows are not audited for it, and reordering — a latency lever scored on spend — is the obvious suspect |
| Speculation counts rounds rather than seconds, on uniform priors, leaning on one deep program | App. B.6 | A clock in a replay would time the harness; the priors are optimistically ordered relative to an indifferent speculator, and both are stated |
| Live leg of the ordering identity is one authored program at one width, one vendor | § 8.3 | Reported as the identity on the executed set, with the bill allowed to move by the materializer’s own run-to-run noise |
| Ties are classified order-contingent from one recorded visit order | § 7.1 | A shuffled-selector run is done for the operation rows but not for every permission tie |
| Measured population varies from run to run | § 8.4 | Repeating one planner flips 6 of 31 tasks in or out (Jaccard 81%), so the disjoint sets across planners are substantially run churn and not a capability ranking; shared-goal comparisons use the 77-goal intersection, while own-population figures, including projection, are labeled as such |
| Scenario term | Meaning |
|---|---|
| Named-consumer case | An output omitted from today’s request is still required by another consumer recorded in the standing program, so a static eager control cannot discard it. |
| No-consumer control | No node reads the omitted output, so ordinary dead-output elimination is available to both eager and lazy arms. |
| All-demanded control | Today’s request needs every output, so neither arm may project any of them away. |
| Standing session | Several requests arrive over time against one persistent graph; prior artifacts may be reused when still valid. |
| Session coverage | Fraction of the standing program’s products requested at least once during the session. |
| Invalidation | Fraction of requests whose changed input makes an earlier artifact and its downstream artifacts stale. |
| Scenario | Worth to stop_eager | Worth to lazy | Remainder |
|---|---|---|---|
| Gate output only; trace has another consumer (bills 256 / 256 / 56) | |||
| Gate and trace both requested (bills 261 / 261 / 261) | |||
| Named-consumer case | 0.0% | ||
| No-consumer control | |||
| Release-package standing session | 0.0% | ||
| Model-refresh standing session | 0.0% |
| Arena | Cost unit | Stop rule | Demand | Perm. gap | Overlap | |
|---|---|---|---|---|---|---|
| Release-package session | authored CPU | 5 | 42.0% | 0.0% | 59.5% | 70.7% |
| Model-refresh session | authored CPU | 5 | 25.8% | 0.0% | 41.7% | 61.8% |
| WfCommons (60 req., 200-task cap) | recorded CPU | 60 | 1.8% | 0.0% | 5.0% | 36.0% |
| DataSciBench | real tokens | 95 | 4.2% | 0.0% | 19.8% | 21.4% |
| Scenario | Stopping | Stopping + cheapest-first | Worth |
|---|---|---|---|
| Named-consumer projection case | 332 | 932 | |
| No-consumer projection control | 332 | 1,102 |
LLM Agent Workflow Optimization
LLM agent workflow optimization studies how to design and run multi-step agents for better task success, reliability, latency, and cost.
See all 262 papers