TL;DR
Building LLM agents with monolithic prompts or rigid, static pipelines makes handling errors incredibly expensive. This paper introduces Runtime-Structured Task Decomposition (RSTD), an architecture that uses deterministic code to handle control flow and isolates LLM calls to small, schema-validated subtasks. By enabling selective retries of only the failed steps, RSTD slashes retry token costs by up to 51.7% compared to monolithic prompts and 73.2% compared to static pipelines.
What Problem Does This Paper Address?
Agentic LLM systems are increasingly deployed for complex software engineering tasks like debugging and root cause analysis. However, most systems rely on monolithic prompts containing all the task logic, which are brittle and require a full pipeline rerun if any step fails.
Even newer frameworks that decompose tasks often do so statically at design time. If an intermediate step fails or produces malformed output, static pipelines typically force a cascading re-execution of all subsequent downstream steps. The authors show that this rigid approach can actually be more expensive in terms of token consumption than simply rerunning a monolithic prompt.
Methods
The authors propose Runtime-Structured Task Decomposition (RSTD), implemented via the open-source Mellea generative computing framework. RSTD splits an agent's architecture into three distinct layers:
- Decomposition Engine: Handles runtime control flow and branching deterministically using standard code logic based on schema validation outcomes or confidence thresholds.
- Judgment Operators: Narrowly scoped, typed LLM calls that output data adhering to strict schemas (e.g., JSON).
- State Manager: A persistent store for validated intermediate outputs, ensuring downstream tasks only see clean data and bounded context.
When a subtask fails validation, RSTD triggers a targeted repair prompt and retries only that specific subtask, preventing cascading reruns.
Datasets
The approach is evaluated on two realistic software engineering workloads (case studies):
- Multi-File Code Debugging: A two-file Python pipeline containing three causally ordered bugs (e.g., wrong aggregation operator, off-by-one error, type mismatch).
- Kubernetes Root Cause Analysis (RCA): A scenario involving a Kubernetes Out-Of-Memory kill (
OOMKill) on a payment service following a regression deployment, requiring log parsing and anomaly detection.
Key Insights and Ideas
- The Static Decomposition Trap: Decomposing a task into a fixed sequence of subtasks without runtime branching can actually increase token costs during a failure. Because fixed execution chains must rerun all downstream tasks from the point of failure, they end up wasting more tokens than a monolithic rerun.
- Code for Control, LLMs for Judgment: The core philosophy is to strip control flow logic entirely out of prompts. Let deterministic code handle the routing and state management, and use LLMs strictly as isolated "judgment operators."
- Validation as a Gatekeeper: By validating schemas before writing to the State Manager, malformed outputs are caught early and fixed locally, preventing cascading reasoning errors down the line.
Key Results
The authors compared Monolithic, Static Decomposition, and RSTD across 10 runs for both use cases:
- Kubernetes RCA: The static baseline's retry cost ($1,632 \pm 145$ tokens) was 80.5% higher than the monolithic baseline ($904 \pm 17$ tokens). RSTD dramatically reduced this to just $436 \pm 132$ tokens—a 51.7% reduction over monolithic and a 73.2% reduction over static.
- Multi-File Debugging: RSTD reduced retry costs to 460 tokens, outperforming both monolithic (703 tokens) and static (933 tokens) setups.
- The Trade-off: RSTD does introduce a higher baseline token cost for successful runs due to making multiple isolated API calls, alongside a framework latency overhead of ~18% of total wall time. However, this trade-off pays off significantly when failure rates are non-trivial or context re-ingestion is expensive.
Limitations and Future Work
- Controlled Evaluation: The evaluation was performed at temperature 0 with low natural failure rates, meaning the retry costs had to be measured using simulated failures.
- Manual Policies: The decomposition and branching policies are currently developer-authored and manual, which might not easily scale or generalize to automatically derived task graphs.
- Future Directions: The authors plan to evaluate RSTD on broader benchmarks like ITBench, extend the pattern to multi-agent settings, and explore learning decomposition policies dynamically from runtime signals.
Summary updated