Compiling Agent Traces into Typed Workflows for Cheaper and Faster Execution of Recurring Tasks
Garcia-Carrasco et al. in Agents
Can successful traces make recurring agent tasks cheaper?
Compiling Agent Traces into Typed Workflows for Cheaper and Faster Execution of Recurring Tasks
Recurring tasks leave agents between cost and brittleness
Each request repeats the agent's loop: inspect operations, choose calls, check results and correct mistakes, even when the procedure is familiar.
A script captures that procedure cheaply, but may break when a paraphrase refers to a different alarm or value.
The challenge is to reuse the procedure while resolving each new instance.
Output space determines who can run each step
- 1
EXECUTE
Code calls a named operation or computes on available values; it reads or changes the system without a model.
- 2
DECIDE
A decision model answers a bounded question over declared criteria, sometimes read from live state; the engine checks answers and controls routes.
- 3
GENERATE
A generative model returns an open-ended value matching a schema; generated text cannot choose the next branch.
On held-out tasks, success is close; cost is not
30 held-out AppWorld instances (10 per family), one run each. Cost and calls are means; latency is median.
A compiler turns traces into a package it can test
- 1
Learn from traces
Successful traces are its only task description; it also receives generic IR rules and a deployment contract, not task-specific instructions.
- 2
Write and run
It writes a graph, operations and example input, then runs the package against the traced world and repairs mismatches in resulting state.
- 3
Keep worlds separate
Held-out worlds and grading materials stay out of its workspace, though each held-out request instruction appears in at least one trace.
More traces can move a value into code

With three traces, the Songs graph has 14 nodes: 12 EXECUTE, one DECIDE and one GENERATE reading the cutoff year. The all-traces package parses that year in code.
Request values can become code; choices may remain
For Songs, code parses the cutoff year and comparison, then filters the library and playlists in 13 EXECUTE nodes with no model call.
Artists uses one DECIDE call to choose a genre from live candidates; Alarms uses two for alarm type and shift direction. Their graphs have 20 and 16 nodes.
Model calls follow unresolved semantics, not workflow length.
When does compilation pay back?
Compilation took 3 to 5 minutes; including trace and compile costs, break-even came at 50 runs for Artists, 41 for Alarms and 31 for Songs.
- NBE
- Executions needed to recover upfront cost
- C
- Trace plus compilation cost
- a−r
- Agent run cost minus workflow run cost
More traces help, but only within the tested request space
- 1
One trace
Artists solved 10/10 held-out tasks; Alarms 4/10 and Songs 2/10. The latter still passed 59/80 and 54/80 task tests.
- 2
Three traces
At three traces, all families reached 10/10 and stayed there with five, ten or all traces in the deterministic sample.
- 3
What was held out
Every held-out instruction appeared in the full trace set, so this tests new worlds for familiar requests, not new request types.
The major saving comes from compiling away the loop
Same 30 held-out runs; cost uses cache rates. All-generate uses traces in one prompt; IR + chat changes the DECIDE model.
What this evaluation does not establish
Known request templates
Every held-out instruction appeared in the traces; only its AppWorld world was unseen. New request types were not tested.
Small evaluation
Three task families, 10 held-out instances each, one tracing agent and one benchmark cannot establish a general success rate.
GENERATE tested narrowly
None of the three main packages used GENERATE; coverage compiles used it only to parse values from instructions.
Measurement context
Prices use rates read on 21 October 2026; latency was measured on one machine. User interaction was specified, not measured.
Why it matters
- The artifact makes operations, routes and required model calls visible before execution, so its procedure can be inspected and tested.
- For a recurring request family, weigh expected reuse against trace-and-compile cost; these workflows broke even after 31 to 50 executions.
- How can a system recognize that a new request matches a known family, then choose between the compiled workflow and an agent?
12 slides, 3 min
1 day ago