# Compiling Agent Traces into Typed Workflows for Cheaper and Faster Execution of Recurring Tasks

> Garcia-Carrasco et al. compile successful agent traces into workflows, reserving model calls for steps code cannot settle. On 30 held-out AppWorld tasks, the workflows solved all 30; median run cost was 98× lower than the tracing agent's.

- arXiv: https://arxiv.org/abs/2611.36322
- Authors: Jorge Garcia-Carrasco, Javier Sanchis, Sandra Garcia-Ponsoda, Alejandro Mate, Juan Trujillo
- Published: 2026-12-01
- Topic: Agents
- Visual carousel: https://instaxiv.com/p/2611.36322
- Explanation by InstaXiv, a secondary educational summary. Cite the original paper for exact results. InstaXiv is not affiliated with or endorsed by arXiv or Cornell University.

## Can successful traces make recurring agent tasks cheaper?

**98×** lower median run cost vs agent, held-out n=30

## Recurring tasks leave agents between cost and brittleness

**Agent from scratch:** Each request repeats the agent's loop: inspect operations, choose calls, check results and correct mistakes, even when the procedure is familiar.

**Fixed script:** 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

| Method | Solved /30 | Mean $/run | Median sec/run | Calls/run |
| --- | --- | --- | --- | --- |
| Tracing agent | 29/30 | $0.002644 | 46 | 10.1 |
| **Compiled workflow (139× lower cost)** | **30/30** | **$0.000019** | **0.6** | **1.0** |

_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

![Figure 6](https://cdn.instaxiv.com/figures/2611.36322/figure6.webp)

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. (Figure 6)

## Request values can become code; choices may remain

**Parsed from the request:** For Songs, code parses the cutoff year and comparison, then filters the library and playlists in 13 EXECUTE nodes with no model call.

**Left as bounded choices:** 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?

$$
\violet{N_{\mathrm{BE}}} = \frac{C}{a-r}
$$

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.

- $N_{\mathrm{BE}}$: 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

| Method | Solved /30 | Mean $/run | Input tokens/run |
| --- | --- | --- | --- |
| All-generate | 30/30 | $0.008056 | 115,076 |
| Native agent | 29/30 | $0.002644 | 90,021 |
| IR + chat decisions | 30/30 | $0.000132 | 255 |
| **IR compiled (7× lower cost)** | **30/30** | **$0.000019** | **452** |

_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.

Best used when: Best suited to recurring task families whose variations appear in successful traces; here, trace-plus-compile costs were repaid after 31 to 50 executions.

## Key takeaways

- 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?

## Links

- arXiv: https://arxiv.org/abs/2611.36322
- PDF: https://arxiv.org/pdf/2611.36322

## Citation

```bibtex
@article{garciacarrasco2026compiling,
  title   = {Compiling Agent Traces into Typed Workflows for Cheaper and Faster Execution of Recurring Tasks},
  author  = {Garcia-Carrasco, Jorge and Sanchis, Javier and Garcia-Ponsoda, Sandra and Mate, Alejandro and Trujillo, Juan},
  journal = {arXiv preprint arXiv:2611.36322},
  year    = {2026},
  url     = {https://arxiv.org/abs/2611.36322}
}
```
