Skip to content

Build1 publisher3 min readPublished

AgentJIT compiles a traced agent run into deterministic Python after one warmup call

The library traces the first invocation and replays the tool chain as generated Python on every later call. Its own 90 percent premise puts a tenth of traffic back on the model, and that tenth sets the average latency.

The Engineer · Build desk

Photograph accompanying AgentJIT compiles a traced agent run into deterministic Python after one warmup call
Photo: stanford.edu

What happened

  • A dev.to post open-sources AgentJIT, a just-in-time trajectory compiler that traces an agent's first run and compiles the observed tool chain into a deterministic Python AST for later calls.
  • Its premise is that over 90 percent of recurring agent invocations execute the identical sequence of tool calls and differ only in parameters such as user_id, order_id or date.
  • Compiled pipelines carry runtime input guards, and an input that violates the expected structure triggers a de-optimization back to the original LLM agent.
  • Adoption is a pip install and two decorators, @jit on the agent function and @trace_tool on each tool, with warmup and tracing happening on the first run.

Compiled by The EngineerSomething wrong?How this is made

Why it matters

  • constraint The compiled path is only trustworthy where the plan is a function of input shape. Guards described in the post check inputs, so workflows that branch on what a tool returned stay on the model.
  • cost The first call of every distinct trajectory still runs the full 15-to-45-second chain at full token price, so the saving tracks how few distinct shapes the traffic actually has.
  • decision Adopting this is a measurement decision first. The repeat rate of tool sequences has to come out of a team's own traces, because the post asserts the 90 percent without a dataset.
  • contradiction The speedup ratio compares compiled Python against a simulated chain, so it bounds what the simulator was configured to wait and not what a model costs a buyer.

Call the decorated function a second time and the model is not in the loop. The trace from the first run has already become a Python abstract syntax tree, with dynamic tool dispatch replaced by hard-wired, type-checked calls and nested outputs resolved out of the data-flow graph the tracer recorded [6][7]. The second call consumes no tokens because there is nothing left to sample [10]. The design follows the pattern the post cites in V8 and in torch.compile: run once, profile, compile the hot path [15].

A trace records one path. The guards AgentJIT inserts check the structure of the inputs, and a violation bails out to the original LLM agent [8]. That covers product_id arriving as an integer, but not fetch_product returning an empty record on run 40, where an agent would have taken a different branch. The worked example in the post is a straight line: fetch_product, then calculate_vat, then generate_invoice [19]. Compiling that is defensible. A triage agent that picks its next tool from what the last tool returned is a different case, and the post describes guards on inputs only [8].

Take the 90 percent premise at face value [2] and the uncompiled tenth determines mean latency. Using the midpoint of the post's own 15-to-45-second range, one call in ten at 30 seconds and nine at 0.1ms average about 3 seconds, so mean latency falls around 10x, not the 300,000x the two per-call figures imply [17][21]. At 50,000 invocations a day, that tenth is 5,000 model runs [18].

Reliability compounds the same way. A 98 percent per-step success rate across four steps leaves 92.24 percent, so about 7.8 percent of chains fail [16][5].

What I like here is concrete: one library, no mandatory external dependencies, a pip install, @jit on the agent and @trace_tool on the tools [11][12]. The generated code is readable off the function object at runtime [13]. Printing the compiled plan is the first thing I would want, because that is what reviewing it requires. The author wrote that the guarded fallback gives "Zero crashes, zero regressions, pure speedup" [9]. Deopt has a price: a guard failure pays the guard check and then the full 15-to-45-second chain [8][3].

The post reports a 100-iteration benchmark in Google Colab against a simulated uncompiled multi-step LLM chain [14], so the baseline is whatever delay the simulator was configured to wait. The post gives no dataset for the 90 percent figure and calls it "the unspoken truth of agent workflows" [22]. For the ratio to transfer, your real chain's p50 has to sit near that simulated delay, and the repeat rate of tool sequences in your own traces has to be as high as 90 percent [2].

What to watch

  • Whether the full benchmark compares compiled Python against real model calls instead of a simulated chain delay.
  • Whether the guards extend from input structure to tool outputs, which is what branching trajectories would need to compile safely.
  • Whether anyone publishes a measured trajectory-repeat rate from production traces to test the 90 percent premise.
Loading claim ledger
Loading source directory links
Loading share composer
Loading topic controls
Loading related stories