Apply to my task
arXiv:2610.33876 ★ 80 Oct 24, 2026

FlashScript: turning a successful agent run into a program of code plus targeted LLM calls

Key result

An agent with a “skill” (a text instruction from a past run) drops to 23% accuracy on a bundle of ten subtasks. A script built from one successful run gets 100% and identical tool calls on every run. The FlashScript method lets you turn a recurring task (a weekly report, an export review) into a program that takes the same path every time. The trick: the model doesn’t drive the task; it answers narrow questions at fixed points in the code. A coding agent rewrites the run as a neuro-symbolic program: actions and calculations are written as code, and the run’s values become parameters. The `llm` call returns a strictly defined type: yes/no, a choice from a list, or a string. The outcome: roughly 70x fewer input tokens and three times faster.

01

TL;DR

FlashScript is a set of instructions a coding agent follows to turn one successful run of a recurring task into a neuro-symbolic program (NSP). That’s a script where actions and calculations are written as code, the values specific to a given run are pulled out into parameters, and the model is called only where judgment is needed. Each such call is typed: llm<T> returns a string, a yes/no, or a choice from a list. It sits at a fixed point in the code.

A regular agent reinvents the path every time. It solves the same task once with an extra chart, once with a different column name. Even a “skill” (a text instruction distilled from a past run) reduces the variance but doesn’t eliminate it: the model still interprets the instruction and does the math “in its head.” When up to ten subtasks were glued into one request, the agent with a skill mixed them up. Accuracy dropped to 23%, and it added charts nobody asked for.

The method works in three steps. First, the code is written from a plan: identify the template variables and decide what can be written as a rule. Then every spot that needs the model is assigned to one of three layers: input, computation, or output. Finally, model calls are cut back with three techniques: cache, turn judgments into rules, and combine questions into one call. The test result: 100% accuracy, identical tool calls on every run, roughly 70x fewer input tokens, and three times faster.

Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.

02

Method Blueprint

STEP 0: Work through the task with an agent once, until you’re happy with the result (regular chat/agent)
STEP 1: PLAN → which values change from run to run (parameters),
               which decisions can be written as rules, where AI is needed
STEP 2: TAG THE CALLS BY LAYER:
        • INPUT (text → typed value: “LA” → the “Los Angeles” sheet)
        • COMPUTATION (a semantic decision: “is this a scammer?”)
        • OUTPUT (nice wording for something the code already computed)
STEP 3: CUT BACK model calls:
        • cache with a check (guard) → call only if the check fails
        • codification → a judgment becomes a rule (regex, thresholds)
        • clubbing → independent questions in a single call
STEP 4: The code is written by a coding agent in one request: request template + trajectory + tool descriptions
STEP 5: Verify separately: code with regular tests, LLM calls with repeated runs and contracts
03

Example in Practice

Task: Every Monday, a marketplace manager asks an agent to go through the export of customer reviews for their Amazon store. It needs to compute the average rating for each SKU, flag reviews about defects and returns, and then write a summary for the owner. Once, they worked through this with the agent until the result was right: fixed the table format, explained what counts as a “defect.” Now they want it to come out exactly the same every week, without paying thousands of tokens for a rerun of the same reasoning.

Prompt (given to Claude Code along with the trajectory file):

You are an engineer who turns a successful agent run into a repeatable program.
I need a Python program where actions and calculations are code, and the model is called
only for judgments, via llm<T>(question, data) -> T.

<Inputs>
<RequestTemplate>
Go through the review export {csv_file} for the week {start_date}–{end_date}.
Compute the average rating for each SKU, flag reviews about defects or returns,
and write a summary for the owner of the store {store_name}.
</RequestTemplate>
<ReferenceRun>
The file reviews_run.md is the full log of a successful run: reasoning, actions, my corrections.
</ReferenceRun>
<Tools>
Read CSV with pandas; write Excel with openpyxl; call the model through the llm function.
</Tools>
</Inputs>

<Plan>
Write a plan first, code after it:
1. List what changes from run to run → parameters.
2. List the decisions from the run. For each one, decide: rule, cache, or model call.
3. Find shortcuts and accidental assumptions in the run. Don’t carry them into the program
   unless they follow from the request template.
</Plan>

<Layers>
Assign the llm<T> calls to layers:
- Input: turning free text into a typed value
  (which column is the “rating,” even if it’s named “Score”).
- Computation: semantic decisions that can’t be written as a rule (is this review about a defect?).
- Output: a written summary of numbers the code has already computed.
</Layers>

<Reduction>
- Cache: store values from the run in a dictionary; call llm only if the check fails.
- Codification: turn anything repetitive into a rule (keywords, thresholds).
  The model must not do counting or summing.
- Clubbing: independent questions about one review go into a single call.
</Reduction>

<Output>
The finished program with the parameters from step 1, a list of all llm calls
(layer, type T, input), and 3 tests on new data.
</Output>

Result: The agent will first produce a plan: the parameters, the run’s decisions, and what happens to each (rule, cache, call). Then it writes a script where computing ratings and formatting the table are done in code. The model is called at a few points: matching column names, deciding borderline reviews that the rules didn’t catch, and writing the summary from numbers already computed. You also get a table of all LLM calls by layer and a set of tests. Rerunning it the next week gives the same format and the same steps; only the wording of the text summary changes.

04

Why It Works

The LLM’s weakness. When an agent solves a task from scratch every time, it picks a new path each time, and at a temperature above zero, the path drifts. The model is bad at doing math “in its head”: in the paper, it added up daily values in its reasoning and got them wrong. A “skill” from a past run doesn’t fully help. The model still decides on its own how to execute it. It can also inherit an accidental shortcut from the reference run. For example, sums were compared instead of percentages, both approaches gave the right answer, and the skill locked in the wrong one.

The LLM’s strength. A model is good at narrow semantic tasks: understanding that “LA” means Los Angeles, deciding whether a listing looks suspicious, presenting facts nicely. A coding agent is also pretty good at rewriting a run as code. So the method gives the model exactly those tasks and leaves everything else to code.

How the method exploits this. All actions are fixed in code, and variance remains only inside the typed calls. The answer type (yes/no, a choice) limits the model’s freedom. The three techniques (cache, rule, clubbing) cut the number of calls to it, and with them the randomness.

Control levers: - What you give the agent as input. The request template alone already generalizes well. Template plus trajectory gives fewer calls and lets you check the run’s decisions. A trajectory alone without the template is too specific. - What to push into code. The more decisions are written as rules, the more stable and cheaper it is, but the fewer input variations the program can handle. The more decisions stay with the model, the more flexible but scattered it is. - User-facing parameters. A criterion (“what counts as a defect”) can be pulled out into a text field and plugged into the LLM call. - Planning. Without the “plan first, then code” requirement, accuracy in the tests was 0.88–0.96, and the programs broke on rephrased requests. With it: 1.00.

05

Prompt Template

The paper’s text doesn’t include the instructions themselves; they’re in the authors’ appendix. Below is a template assembled from the paper’s description: plan, rules, layers, reduction techniques, the llm<T> type.

<Role>
You are an engineer who turns a successful agent run into a repeatable
neuro-symbolic program: actions and calculations are code, and the model is called
only for judgments via llm<T>(question, data) -> T, where T is the answer type
(string, Boolean, choice from a list).
</Role>

<Inputs>
<RequestTemplate>{request_template_with_variables}</RequestTemplate>
<ReferenceRun>{successful_run_trajectory}</ReferenceRun>
<Tools>{tools_and_API_description}</Tools>
</Inputs>

<Plan>
Write the plan first, code after:
1. Which values change from run to run → program parameters.
2. Which decisions were made in the run. For each: rule / cache / llm call.
3. Which steps of the run are accidental assumptions or shortcuts.
   Don’t carry them over unless they follow from the request template.
4. What input variations are possible (other phrasings, edge cases).
</Plan>

<Layers>
Assign each llm<T> call to one layer:
- INPUT: free text → typed value.
- COMPUTATION: a semantic decision that’s hard to write as a rule.
- OUTPUT: a written presentation of a result computed by code.
Insert the call at a fixed point in the code. Check that the answer matches type T.
</Layers>

<Reduction>
- CACHING: store a value observed in the run in a dictionary. Before using it,
  check the condition. Call the model only if the check fails.
- CODIFYING: write a recurring judgment as a rule (regex, threshold, dictionary).
  The model must not make a decision by doing calculations in its reasoning.
- CLUBBING: combine independent questions into a single call.
</Reduction>

<Output>
1. The plan.
2. The program with parameters.
3. A table of all llm calls: layer, type T, input.
4. Tests: the deterministic part and 3 rephrased requests.
</Output>

Fill in: {request_template_with_variables}: your typical request with blanks in place of the changing values (“for {week},” “for the city of {city}”). {successful_run_trajectory}: an export or chat log of the successful run. {tools_and_API_description}: what the agent uses to read data and write results.

🚀 Quick start: paste this into a chat (ideally Claude Code or another coding agent):

Here is the FlashScript template. Adapt it to my task: [describe the recurring task].
Ask me questions to fill in the fields.

[paste the template above]

The LLM will ask which values in the request change from time to time, which decisions you made by hand in the successful run, and which tools are available. It needs this to separate the parameters from the fixed steps and figure out what can be written as a rule. It will take the structure from the template and build a plan for your task.

06

Limitations

⚠️ Preliminary results: This is a short paper with “first results.” One small model, one benchmark, 12 request templates. Don’t carry the 70x savings and 100% accuracy figures over to just any task.

⚠️ Requires code and somewhere to run it: The output is a Python script with model calls. It has to be run, stored, and maintained somewhere. The method won’t work in a regular chat; you need a coding agent and API access to the model.

⚠️ The authors’ full instructions aren’t in the text: They’ve been moved to the appendix. The template above is a reconstruction from the described principles, not a copy of the original.

⚠️ A narrow type of task: It was tested on analytics with clear correct answers: read data, compute, compare to a threshold, build a chart. On creative, fuzzy, or exploratory tasks where the path differs every time, the method is untested.

⚠️ It doesn’t remove randomness: The method only locks it inside typed calls. The wording of answers and borderline judgments can still drift.

⚠️ Mistakes from the reference run move into the program: If the successful run contained a shortcut that happened to produce the right answer, it ends up in the code. The plan requirement helps, but you still need to review the code.

⚠️ A trajectory alone hurts: If you give the agent a single run without the request template, the program is too tied to that specific case. On new instances of the task, accuracy dropped, and some runs crashed with an error.

07

How They Tested It

The team used the WorkBench benchmark: 12 templates of analytics tasks, ten variants of each, 120 tasks in total. An example: “if the number of active users is more than 10% lower than on November 24, build a chart.” They worked with a small model, Claude Haiku 4.5, at temperature 1. Everything was tried three times to see the variance, not just correctness. For each template, the best run of a regular agent was turned into a “skill” and into an NSP. A coding agent wrote both.

The results were compared with a regular agent and an agent with a skill. The regular agent reached the same state as on its first try in 82% of repeats. The skill raised that figure to 99%, but not to 100%. Then the authors glued up to ten independent requests into one. And that’s where the big surprise showed up: the agent with skills, given all the skills it needed, fell to 23% accuracy, added extra charts, and forgot the needed ones. Under the same conditions, the NSP stayed correct and completely identical. On 108 new task variants, the programs also solved everything, while the skill managed 96%.

The most practical result is the experiment with generation instructions. A plain “write a program from the template” gave 0.96 from the template and 0.88 from the trajectory. But the programs broke on rephrasings. Adding the requirement “plan first, write decisions as rules, assign calls to layers” raised accuracy to 1.00. The template / run / both comparison shows that correctness comes from the template and the plan, while the run adds savings (fewer calls, 1.5 versus 1.8 per run) and a way to check the run’s decisions.

08

Adaptations and Extrapolations

🔧 Technique: pull the judgment criterion out into a parameter → the user controls the decision without touching code

The authors suggest making judgments configurable: a menu choice or a text field. In the reviews scenario, it looks like this:

In the program, add a parameter {defect_criterion} (a text field, default value:
“a complaint about a defect, breakage, or mismatch with the description”).
Plug it into the llm<bool> call on the COMPUTATION layer.

Now the manager changes the definition of “defect” with a single line and immediately sees how the result changes.

Extrapolation: a “when to compile” rule in the agent’s instructions file (my idea, not tested in the paper):

If the user asks for the third time to run a task with the same request template,
offer to turn the successful run into a program: write a plan, find the parameters,
decide what becomes a rule and where an llm<T> call is needed. Don’t run it without confirmation.

A rule like this in CLAUDE.md or AGENTS.md turns a “one-time lucky run” into an asset that keeps compounding.

09

Resources

  • FlashScript: Compiling Recurring Agent Workflows into Reusable Neuro-Symbolic Programs: Sadra Sabouri, Shreya Sinha, Souti Chattopadhyay (University of Southern California); Hosein Hasanbeig, Adam Sage, Cale Darling, Ashish Tiwari, Katie Garms, Sumit Gulwani (Microsoft).
  • The authors’ instructions for generating NSPs: https://figshare.com/s/c812d719d2d43bae034c
  • The WorkBench benchmark (Styles et al., 2024), arXiv:2405.00823.
  • Related work on compiling trajectories: SKILL-DISCO, TraceCompiler, Agent Workflow Memory.

Research digest

Key result

An agent with a “skill” (a text instruction from a past run) drops to 23% accuracy on a bundle of ten subtasks. A script built from one successful run gets 100% and identical tool calls on every run. The FlashScript method lets you turn a recurring task (a weekly report, an export review) into a program that takes the same path every time. The trick: the model doesn’t drive the task; it answers narrow questions at fixed points in the code. A coding agent rewrites the run as a neuro-symbolic program: actions and calculations are written as code, and the run’s values become parameters. The `llm` call returns a strictly defined type: yes/no, a choice from a list, or a string. The outcome: roughly 70x fewer input tokens and three times faster.

Principle

The method has three steps, and code is written only after the plan. 1. Plan. The agent writes out what changes from run to run (parameters). Then it lists the run’s decisions and picks one for each: rule, cache, or model call. 2. Layers. Each model call is assigned to one of three layers. Input: text turns into a value (“LA” becomes the “Los Angeles” sheet). Computation: a semantic decision (“is this a scammer?”). Output: a polished summary of numbers the code has already computed. 3. Reduction. Cache with a check: the model is called only if the check fails. Codification: a recurring judgment becomes a rule (keywords, thresholds). Clubbing: independent questions go into one call. Plan first, then code: that’s how the agent separates what follows from the request template from the run’s accidental assumptions. It’s like a factory assembly line. Each station does its own job instead of everything at once, and the model sits only at the stations where a human eye is needed.

Why it works

Without a plan, the agent invents the path anew every time. One time it draws an extra chart, another time it names a column differently. The model is also bad at doing math “in its head”: in the paper, it added up daily values in its reasoning and got them wrong. Even a skill doesn’t fully fix this, because the model decides on its own how to execute it. The kicker: a skill from a successful run locked in an accidental shortcut. In the run, sums were compared instead of percentages, the answer came out right, and the mistake became the rule. In the script, all actions are fixed in code, and variance remains only inside typed calls, where the answer is constrained by its type. The three reduction techniques cut the number of those calls, and with them the randomness. The “plan first” requirement raised accuracy from 0.88–0.96 to 1.00. Without the plan, programs broke on rephrased requests. What to give the agent as input: the request template plus the run log means fewer model calls and lets you check the run’s decisions. A log alone without the template is too tied to the specific case. The more decisions are written as rules, the cheaper and more stable it gets. But the fewer input variations the program can handle.

When to apply

Analytics with clear correct answers → weekly reports, export reviews, checking data against thresholds, especially when the same request runs dozens of times and you keep paying for the same reasoning over and over. Not a fit for creative or exploratory tasks where the path is new every time: the method wasn’t tested there. You need a coding agent and a place where the script can be run and maintained. The method won’t work in a regular chat. The results are preliminary: one small model, one benchmark, 12 request templates. Don’t carry the “70x” and “100%” figures over to just any task.

Mini recipe

1. Work through the task once, until the result is what you want. A regular agent, a regular chat. Don’t scrub out your corrections along the way: they’ll be useful in the log. 2. Save the full log. Reasoning, actions, your corrections. This will be the reference run. 3. Write a request template with blanks. Each changing value is replaced with a blank: . 4. Describe the tools. What the agent uses to read data, write results, and call the model. 5. Give it all to a coding agent in one request (Claude Code or similar). Ask for the plan first and the code after: parameters, what happens to each decision (rule, cache, call), and the run’s accidental assumptions that shouldn’t be carried over. 6. Require a table of model calls. Layer (input, computation, output), answer type, what goes in. If there are many calls, ask for caching, rules, and clubbing of questions. 7. Verify separately. Run the code through regular tests. Check the model calls with repeated runs on 3 rephrased requests. 8. Pull contested criteria out into parameters. For example, put “what counts as a defect” into a text field and plug it into the model call.

Examples

[BAD]: `Go through this week’s review export, same as last time` [GOOD]: `You are an engineer who turns a successful agent run into a repeatable program. I need a Python script: actions and calculations in code, the model only for judgments via llm(question, data) -> T. Request template: “Go through the review export {csv_file} for {dates}, compute the average rating per SKU, flag reviews about defects, write a summary for the store {store_name}”. Log of the successful run: reviews_run.md. Tools: pandas, openpyxl, the llm function. Plan first: parameters, the run’s decisions and what happens to each (rule, cache, call), accidental assumptions not to carry over. Then the code, a table of all llm calls by layer, and 3 tests on new data.` [BAD]: `Here’s the log of my successful run, make a script out of it` [GOOD]: `Here’s the run log and the request template with parameters. Don’t carry over steps that don’t follow from the template. Compute the rating and the table formatting in code. Call the model only to match column names, for borderline reviews without keywords, and for the final summary of the computed numbers.`

In plain words

Making an AI agent do the same weekly routine from scratch every time is pure insanity. Models can’t do mental math, they mix up formulas, and at a nonzero temperature they give you different results on identical data. The FlashScript method shuts down this circus for good: it takes one successful agent run and compiles it into a neuro-symbolic program. Logic and math move into hard code, and the model is left with only targeted judgment calls.

It’s like hiring a creative poet as your accountant and explaining the rules of addition to them all over again every Monday. Instead of calmly using a calculator, they pour their soul into it every time and botch basic change. FlashScript takes Excel away from the “poet,” bakes the formulas into the concrete rails of a script, and calls in the model only where real human understanding of text is needed, not dumb number crunching.

Here’s how the mechanics work: a compiler agent extracts a deterministic pipeline from the successful session. All loops, filters, and the average order value calculation are written as regular code. Calls to the model are isolated through a typed function, llm, which returns a strict format: yes/no, a category from a list, or a clean string. No extra chatter, no wonky reasoning: 100% repeatability where there used to be chaos.

The study ran through marketplace review analysis, but the principle is universal. Any weekly routine, from bug-report triage to stitching together complex reports, moves from “pray the agent doesn’t lie” mode to a reliable program. You pay for tokens once, build a working skeleton, and run it forever without feeding it gigabytes of context every time you sneeze.

Bottom line: stop using LLMs to execute strict algorithms; it’s expensive and unreliable. Turn one-off successful prompts into hybrid code, where the logic rests on syntax and the model works as a narrow sensor. Anyone who keeps running “smart agents” in circles on raw prompts is just flushing their budget down the drain on hallucinations they paid for themselves.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on FlashScript: turning a successful agent run into a program of code plus targeted LLM calls arXiv:2610.33876

Sign in to apply this study New accounts get 50 free credits.