Task Decomposition · Part 1 of 3
Task Decomposition: Splitting LLM Workflows into Single-Purpose Steps Using agent-actions (Part 1)
Splitting LLM workflows into single-purpose steps: why task decomposition lets lower-cost and local models do the work, how to decompose a job, where to set step boundaries, and how to try it.
- Part 1Splitting LLM workflows into single-purpose steps
- Part 2How one record moves through a step (coming soon)
- Part 3Six patterns for setting step boundaries (coming soon)

Task decomposition is a technique that engineering has relied on for a long time. In its general form, it means breaking an assigned job down into a planned sequence of subtasks, so that each subtask is small enough for one part of a system to carry out and manage on its own (ScienceDirect). The technique appears in fields as different as robotics, human reliability analysis and parallel computing, and the way it is applied in those fields carries over closely to LLM workflows. In each case, the subtasks that result are either independent of one another, in which case they can be carried out at the same time, or sequentially dependent, in which case the output of one becomes the input of the next. Each subtask is then assigned to whichever resource is best suited to perform it, and the decomposition is considered complete when every subtask has been reduced to a single unit of work, such as one piece of information to gather, one decision to make or one action to take.
This series applies the same technique to LLM workflows. A job that would otherwise be handled by one large prompt is broken into a graph of steps, each of which makes a single decision, and agac runs those steps in the way a data pipeline runs its transformations, giving each step its own contract, its own checks and its own stored output. Because each step is narrow, most of them can be handled by a small or local model rather than a large hosted one.
- Part 1: Splitting LLM Workflows into Single-Purpose Steps
- Part 2: How One Record Moves Through a Step
- Part 3: Six Patterns for Setting Step Boundaries
agac (Agent-Actions) is an open-source framework that runs LLM workflows using the same approaches that have been tried and tested in data pipelines for large scale data transformations. I built agent-actions to apply the same steps over many records, with an LLM as the transformation tool instead of something like SQL, and with every result validated against predefined contracts and stored. It borrows from how we process data in OLTP and OLAP systems, so a workflow can run in online mode, where each record goes to the model as it is processed, much like a transaction in an OLTP system, or in batch mode, where records go through the provider's batch API at a lower cost, much like a job in an OLAP system. In agent-actions, a record is one item of input that needs one or more specific outcomes, such as one support or incident ticket that needs triage and resolution, one contract whose clauses and references need extracting, or one documentation page that needs converting into a list of FAQs.
agac enables us to describe the task to be done once in a YAML file, much like the way we define GitHub Actions, so that the workflow is reusable and easy to understand. Each step in the workflow file is an action, which can be a model call, with its own prompt, model and answer shape (schema), or a Python function that makes no model call. A Python tool is defined the same way as a model step. It names the fields it reads and declares its own expected schema, just as we do when we define tools for agents. The design approach in agac ensures that every step shares one interface, so steps are interchangeable and pluggable, and you can swap a model step for a tool, or one model for another, without touching the steps around it, and reuse a step in another workflow. The approach is also deliberately opinionated (convention over configuration). There is one way to define a step, so the framework, the engineers and the coding assistants that build on it have a single way of doing things. An action defines everything it needs to get a response, including the predecessor it inherits its input data from. Defining steps this way naturally turns the workflow into a DAG, which gives agac an easy way to plan the order of execution before the run, so that independent actions can run in parallel while dependent actions follow the DAG.
Below are two sample actions from the incident support example we will be using in this article.
- name: classify_issue
intent: "Classify the issue"
prompt: $support_resolution.Classify_Issue # the instructions
schema: { issue_type: string } # the answer's shape
context_scope:
observe: [source.title, source.body, source.labels] # all it may see
- name: assess_severity
intent: "Rate the severity"
dependencies: [classify_issue] # runs after it
prompt: $support_resolution.Assess_Severity
schema: { severity: string }
context_scope:
observe: [source.title, source.body, classify_issue.issue_type]
drop: [source.labels] # never sent
- The first action is classify_issue. From its intent we can see that it takes some input and classifies it into one of a listed set of categories, its accepted values, much like a dbt or Great Expectations accepted_values test on a column, which closes the boundary so that the model can only answer with a value we have defined. Rather than being written inline, the prompt is defined once in a central prompt file and called by name ($support_resolution.Classify_Issue). The action then declares its schema, the shape of its answer, and its context_scope, the inputs we want the model to see. Showing only those fields avoids context pollution and gives the model just the context it needs, on a need to know basis.
- The second action is assess_severity. It names classify_issue under dependencies, so it runs only after the issue has been classified, and it reads that answer as classify_issue.issue_type alongside the ticket's title and body. It also drops source.labels, so the reporter's own labels never reach the model and cannot anchor its rating. Looking at just these two actions, we can already see the graph forming. classify_issue depends on nothing, so it is a starting node, and assess_severity hangs off it, joined by the dependency it declares. Every action added this way names what it reads from, and agac builds the whole DAG from those links, with no extra wiring.
The model call is the small part of the system; in effort and cost it is cheap, but the harder question is how far we can trust the response it returns. agac addresses this by wrapping every output in a harness of validation that accepts no answer until it passes its checks, so that an answer which does not meet its predefined requirements fails, and the failed record has a clear path to be retried or set aside in quarantine, much like a dead letter queue. These checks test the form of an answer, such as whether a category is on the list, and not whether its judgement is right; Part 3 of this series will show how to check a judgement. Because agac applies the same rules to every record, this holds whether a run covers a hundred records or millions of transactional records, which is what makes applying an LLM at that scale manageable. For every action and every record, agac does the following.
- Before the run, it checks every key, every prompt reference and every dependency, so a typo stops the run before a single paid call. This avoids the situation where, mid-run, we find that a prompt or config is missing and the workflow fails at step 5 with thousands of API calls already made.
- Before each call, it compiles and renders the prompt from only the fields the action observes, and skips the records that a guard rules out (similar to a WHERE clause in SQL).
- After each call, it checks the answer against its schema and the action's rules (called agac expectations), and sends an answer that breaks a rule back to the model with the reason if repair is enabled. When the tries run out, a setting on the action decides what happens: by default agac keeps the last answer with its failed checks attached, and if you choose, it sets the record aside in quarantine so that later steps skip it.
- After each record, it stores the answer on the record with a status, and keeps every prompt the model saw, along with the other artifacts used to generate the outcome, for easy observability through the agac docs site. A rerun skips the work already done, and
agac retrysends only the failed records again.

Each action can use its own model, so a single workflow can mix models and give each step the one best suited to it, whether that is OpenAI, Anthropic, Gemini, Groq, Cohere, a model on your own machine through Ollama, or even a custom endpoint you have created. agac is not an agent framework in which the model decides the next step. Instead, it falls under the definition of an LLM workflow. In agac you decide the steps and the model answers one narrow question at each of them, so that each business process can be defined as a workflow that balances ease of use, easy debugging and the right harness to check the form of every output.
To show the kind of work agac is built for, take one support ticket, "CSV export fails. Export returns 500 for all users." Someone has to decide what kind of issue it is, how severe it is, which part of the product it touches and which team gets it, and then write a summary and a reply. One approach is to give the whole job to a frontier model in one prompt and define the expected output fields, as shown below.
You are a support assistant. Read the ticket below.
1. Classify it as bug, feature_request, question, account_issue or performance.
2. Rate its severity as critical, high, medium or low.
3. Identify the product area.
4. Choose the team, using these routing rules: { ...30 lines of rules... }
5. Write a one-line summary for the dashboard.
6. Draft a reply to the customer.
Return JSON with the keys issue_type, severity, product_area, assigned_team,
summary and suggested_response.
Ticket: {{ title }} {{ body }} {{ labels }}
From a task decomposition standpoint, that prompt asks for six jobs in one answer. A top of the line model can usually do all six at once and return a valid JSON object with six keys, but when the ticket then goes to the wrong team, there is no way to tell whether the classification, the severity or the routing was at fault, because all three came out of the same call. The prompt also drafts a reply for every ticket, including the ones no agent will ever answer, so part of every call is spent on work nobody uses.
Here is the same job decomposed into steps, where each step asks for one thing and returns it as one JSON field:
| Step | Asks the model for (via a defined schema) | LLM Context (what the model sees) |
|---|---|---|
classify_issue | One field: issue_type | Title, body, labels |
assess_severity | One field: severity | Title, body, the category |
identify_area | One field: product_area | Title, body, the category |
assign_team | One field: assigned_team | The three answers above and the routing rules |
summarize_issue | One field: summary, one line | Title, body, the three answers |
draft_response | One field: the reply, only when severity is not low | The title, the category, the severity, the summary and the team; not the raw body |
format_output | Nothing. It is a Python function | Every answer above |
Each of these is a narrow task that a lower cost model, hosted or local, can do well, because each step has a single goal and needs little reasoning. If an issue is routed to the wrong team, we know exactly which step in the workflow to focus on, whether that means changing the model it uses or improving its prompt. The same structure has a cost. Each step builds on the answers before it, so a wrong issue_type is read by the severity, area and summary steps and can make all three wrong. A check on the steps that others depend on, such as a second rater that cannot see the first answer (Pattern 4 in Part 3), stops one error from spreading. This is what I mean by task decomposition, and agent-actions (agac) makes it a first class feature that applies to every record it processes.
As stated earlier, because each action names the action it reads its input fields from, the decomposed job is naturally a graph, and agac runs the steps that do not depend on each other at the same time. assess_severity and identify_area both depend only on classify_issue, so they run together, and the same is true of assign_team and summarize_issue. When we run the example, agac prints the plan it has worked out before making any call, much like terraform plan shows what will change before anything is applied, or dbt compile shows the SQL before it runs, as shown below.

Step 1/5 classify_issue
Step 2/5 2 actions: identify_area, assess_severity
Step 3/5 2 actions: assign_team, summarize_issue
Step 4/5 draft_response
Step 5/5 format_output
✓ 7 completed
agac uses task decomposition to make small and local models usable and reliable without you having to write manual glue code around them. A small or local model that runs on your own machine through Ollama often cannot follow a prompt with six parts and return a valid JSON object with six keys, and making it work usually means writing code to retry, repair and stitch its answers together. The same model can answer "which of these five categories is this ticket?" as a JSON object with one field, reliably and at no cost per call, and agac supplies the glue that would otherwise sit around it, from checking each answer to passing it on to the next step. Once every step asks for one or two fields, most of the steps no longer need a frontier model at all, and the few that do can still use one.
This design moves the cost of the job from model capability to engineering. With one large, well engineered prompt, we pay for capability by using a more capable model on every call, for every record and on every rerun. With task decomposition, we spend that budget on engineering instead, because someone has to break the job into steps, decide what each step may see, write the checks, handle the answers that fail and keep track of what has already run. That work has usually meant writing and maintaining a lot of code around the model calls, or picking up one of the existing tools and frameworks and extending it with custom implementations. In agac, the way a workflow is defined makes task decomposition a natural, first class feature rather than something we bolt on, and because every step has a name, a declared input and a declared output, prompt traces and observability come with that structure for free. As described above, each step is a few lines of YAML, the whole workflow is checked before it runs, an answer that breaks one of the step's rules is sent back with the reason, completed records are not billed again unless we choose to rerun them, and every prompt the model saw is stored. What is left for me is deciding where to set the step boundaries, which depends on understanding the task and is the part of the design I want to spend my time on.
This post covers how to decompose a job into steps, how to decide where a step boundary belongs, how to run steps on a local model, and how to try the example yourself.
This is a series of three posts:
- Splitting LLM Workflows into Single-Purpose Steps (this post): the method, and why it lets lower-cost and local models do the work.
- How One Record Moves Through a Step: how one record reaches the model, what the model receives, and the data-engineering techniques agac applies to every answer.
- Six Patterns for Setting Step Boundaries: the patterns I use, with their full config.
The series is designed to be read in order, though each part stands on its own. Part 1 is the method, and most of it applies to LLM workflows in any tool. Part 2 opens agac up and shows the machinery that runs the method for every record. Part 3 turns the method into reusable patterns, each with its complete config. All three parts follow one running example, the support workflow that ships with agac (examples/support_resolution). The snippets show a version of it in JSON mode, with a schema and rules on each step. The file that ships runs in plain-text mode, and the Try it section at the end of this part shows how to run it and what to change. Where the text uses a term that is agac's own, such as action, context_scope, guard or expect:, the term links to its page in the agac docs, so you can go deeper on any of them without losing the thread.
Task decomposition does not make a weak model strong, but it does make each request narrow enough that a lower cost or local model can answer it well, and it moves every decision that follows a fixed rule out of the model and into code, where we can test it and rely on it to behave the same way every time.
How to decompose a job
To showcase how I decompose a job, the steps below follow an approach that borrows from my experience as an analytics and data engineer and from ideas in data modelling, such as finding the grain of the data before deciding what to build on top of it. At a high level, the same steps extend to any job to be done that we are trying to break down, as long as it runs over many records.
1. Find the atomic unit. I start with the smallest piece of output that can be judged right or wrong on its own, which in data modelling terms is the grain. For support, that is one label for one ticket, one routing decision or one reply, rather than a whole triage in one answer. Each model call produces one unit, because when a call produces five, a mistake in one of them is hidden among the other four and a retry bills all five again.
2. List the decisions that make one unit. I write down, in order, every decision that sits between the raw ticket and a finished triage, such as what kind of issue it is, how severe it is, which team gets it and what to reply. Each decision is a candidate step, and a prompt that makes all of them at once is the large prompt I am trying to replace, and this holds even when that prompt was written with the best prompt engineering techniques.
3. Give each decision to a model or to code. A decision that needs reading or judgement goes to a model, while a decision that follows a rule, such as a count, a date comparison or a lookup in a routing table, goes to code, where it costs less, does not drift between runs and can be tested.
4. Decide what each step may see. Each step should see only what its decision needs, which keeps the prompt small and makes some checks possible in the first place, such as a second rater that rates the ticket without seeing the first rating. The idea behind this comes from my experience of working with LLMs over the past four years. Context is important, but its quality and amount matter just as much, and providing context that a specific response does not need can pollute the prompt and send the wrong signal to the model.
5. Write down what a good answer looks like. For each model step, I state the rules a good answer must pass, such as the right number of items, a value from an allowed list, a length or a format. Because the step is narrow, that list is short enough to describe a good answer fully, and it becomes the gate every answer has to pass. These rules also let me keep a set of golden outputs to test against, and because each step records how it arrived at its answer, the results become explainable to a useful extent.
6. Decide what happens when a unit fails. I choose, per step and in advance, whether a failed unit is sent back to the model with the reason, dropped, or stops the run, so that the same failure is always handled the same way. The right choice depends on the cost of failure. When I am generating content for a website, such as FAQs from a documentation page, retrying a failed record might not be worth it. In legal clause extraction, or when I am trying to resolve an incident, a failure means a user somewhere is affected, so I can choose to retry, or to quarantine the record and pass it to the human in the loop (HITL) step that agac supports, which surfaces the failure to a person.
7. Then choose the model. When choosing a model, I personally start with the smallest and cheapest one I can find that handles that one decision well, and the way agac is designed makes it easy to iterate quickly and swap models when needed. Since each step asks for one thing, that model usually costs far less than the one the large prompt needed, and for many steps it can be a local model with no cost per call.
If we apply the design principles above to the support workflow (the large prompt earlier), the atomic unit is one triage decision for one ticket. Each decision then becomes one of the seven actions in the table at the start of this post, six of them model calls and one a Python tool, and none of them needs a frontier model.
Where to set step boundaries
When I am defining step boundaries, there are a few considerations I use to justify why a boundary belongs where I have put it, and I treat a separate step as justified when it meets at least one of the conditions in the table below. Each condition maps to a feature in agac, which I will explain in more detail in Part 2, and Part 3 shows each one in a full workflow.
| Reason to make a separate step | What it looks like in agac |
|---|---|
| It does one job, so its prompt can be short and strict. A narrow step can carry its own contract, much like the data contract and quality checks we define on a column in an analytics pipeline. | A separate action with its own prompt and schema |
| It needs instructions or a role that would confuse the other steps. In data modelling we build the warehouse in layers, from raw to staging to presentation, so that each layer and each model has one purpose, and in the same way a classifier and a reply writer need different instructions and roles, so they live in separate steps. | A separate prompt for the same record |
| It must see less than its neighbours. Like an authorized view that exposes only the columns a user needs, the step sees only the fields its decision depends on, so a second rater never sees the first rating. | context_scope with only the fields it needs |
| Code can make its decision. A lookup, a count or a date comparison belongs in code, which is deterministic and can be tested. | kind: tool |
| The model cannot do the combined job within its token limit | Split the record, so each call does one part |
| A good answer can be stated as rules | An expect: block of rules on that step |
Running the workflow on a local model
Here is another version of the workflow above, where most steps run on a local model through Ollama and only the step that needs it calls a hosted API. Each action names its model with two settings, model_vendor and model_name, and any action can override the workflow default. With model_vendor: ollama_local, agac sends the step to a model running on your own machine, with no API key and no cost per call, so in the example below the local model is the default and only draft_response uses a hosted model.
defaults:
json_mode: true
model_vendor: ollama_local
model_name: qwen3:8b # local, no API cost
actions:
- name: classify_issue # one field from a fixed list: local is enough
intent: "Classify the issue"
schema: { issue_type: string }
prompt: $support_resolution.Classify_Issue
context_scope:
observe: [source.title, source.body, source.labels]
- name: draft_response # a reply a customer will read: use a hosted model
intent: "Draft a response"
dependencies: [classify_issue]
schema: { suggested_response: string }
prompt: $support_resolution.Draft_Response
model_vendor: openai
model_name: gpt-6-luna
api_key: OPENAI_API_KEY
context_scope:
observe: [source.title, classify_issue.issue_type]

This arrangement works for two reasons. The first is that each step asks for only one answer, which is a request that a local model can satisfy reliably. The second is that each schema is small, with a single field in this example, and for ollama_local agac sends that schema to Ollama in its format parameter, so the local model is constrained to return JSON that agrees with the schema.
Having every step give its answer in JSON is also what keeps a decomposed workflow manageable as it grows. agac sends the schema to the model together with the prompt, and it checks the reply against that schema before the next step is allowed to read it. The answer is then stored on the record under the name of the step, so the next step reads one named field, for example classify_issue.issue_type, rather than having to parse free text, and for the same reason a guard can test that field and a tool can read it as data. If a reply is not valid JSON, or a required field is missing, and the step has an expect: block, agac generates the reply again at the same step, and when structural: auto is set in the step's expect: block it also sends the schema error back to the model. In practice, it is best to keep each schema to one or two fields and to use expect: rules, such as an accepted_values list, to check the values themselves, which Part 3 covers in detail.
Try it
The support workflow ships with agac as an example, so the quickest way to see everything in this post in action is to run it yourself with the commands below.
pip install agent-actions
agac init example support_resolution my_project && cd my_project
agac run -a support_resolution
agac preview -w support_resolution --action assign_team
The shipped example uses a Gemini model by default, so set GEMINI_API_KEY first. It runs in plain-text mode; for the JSON mode this series uses, set json_mode: true and replace each output_field with a one-field schema, as shown above. To try it without an API key, agac run --sandbox runs the same workflow against a scripted model.
Another approach I use personally is to build the workflow together with a coding assistant. agac ships with skills that a coding assistant such as Claude Code, Codex or Pi can use to create a workflow, so I describe the job, let the assistant draft the actions, schemas and prompts, and then we run it, inspect the results and improve it over a few short iterations. Because there is one way to define a step, the assistant has a clear pattern to follow, and the checks agac runs before each run catch its mistakes early.
To set this up, install agac's skills into your project. Run the command from the project folder, the one that holds agent_actions.yml:
agac skills install --claude # Claude Code: copies the skills to .claude/skills/
agac skills install --codex # OpenAI Codex: copies them to .codex/skills/
agac ships four skills, each of which covers a different part of the work. The first, agac-agent-skills, helps the assistant build, run, inspect and debug workflows. The second, agac-expectations, helps it write and calibrate expect: rules. The third, agac-operations, covers running large workflows safely, including batch mode, resuming a run, reruns and retries, and the fourth, agac-blind-verification, checks outputs with verifiers that never see the reference answer. There is no need to call a skill by name, because Claude Code loads the skill that matches the request when you describe the job in plain words, for example "Add a step to the support workflow that tags each ticket with the customer's plan, then test it in the sandbox". A skill can also be called directly, for example with /agac-agent-skills, and after an upgrade of agac the install command should be run again with --force so that the skills are refreshed.
Part 2 goes inside agac: how one record reaches the model, the exact prompt and request the model receives, and the data-engineering techniques that keep every answer checked and traceable, and skip the work already done.