SevenTnewS

Research paper analysis

The tool explosion inside every AI agent just got a formal solution

A hierarchical, skill-based architecture for AI agents solves the bottleneck of flat tool registries. By organizing capabilities as a tree and using a stack-based execution loop, it scales sub-linearly with tool count while providing execution isolation and auditability for regulated domains like digital payments.

Emmanuel Fabrice Omgbwa Yasse AI-assisted

2026-07-21 · 5 min read

The tool explosion inside every AI agent just got a formal solution
Sources : A Formal Hierar…

Every AI agent runs into the same design problem. Give it too many tools, and the model can't decide which one to use. Give it too few, and complex tasks stay out of reach. A research paper from the team behind UPI Help, an AI-powered digital payments support product, proposes a solution built on an old idea: the pushdown automaton.

The paper, A Formal Hierarchical Architecture for Agentic Orchestration with Stack-Based Execution and Lazy Discovery, arranges agent capabilities as a rooted tree. Internal nodes make routing decisions. Leaf nodes execute deterministic tasks. A LIFO (Last-In-First-Out) stack governs the single-step execution loop, giving the agent memory like a pushdown automaton. That lets it handle nested execution and return cleanly from any depth. As one technical analysis notes, such formal structure is exactly what separates production-ready agents from sandbox demos that fall apart under real load, see how sandbox benchmarks hide agent failures.

The bottleneck that hierarchy solves

Current LLM agent frameworks usually load every available tool into a flat registry. When the registry grows to hundreds or thousands of APIs, the model must evaluate all of them at each reasoning step. The paper calls this 'decision-space explosion.' Context windows saturate. Routing accuracy drops. Latency climbs. At 256 tools with 800-character schemas, flat routing exceeds context limits and scores a 0% success rate in the paper's benchmarks.

The hierarchical alternative organizes capabilities into a skill tree. When the agent enters a decision-making node, it loads only the immediate children's metadata through localized JSON manifests. This lazy discovery protocol means memory and prompt costs scale with the explored path, not the global registry. At 512 tools, the hierarchical system uses 2,875 input tokens per task and maintains 100% routing success. The flat baseline hits context limits at 256 tools with nearly 50,000 tokens. The principle mirrors findings from other work on agent skill assessment, see SkillCoach's rubric for agentic skill use.

Stack-based control for nested workflows

The paper's main architectural contribution is replacing unstructured conversation-based orchestration with a formal stack discipline. Each time a decision-making node calls a child skill, the runtime pushes a context frame onto the stack. When the child completes, its output is appended only to the parent's localized accumulator. Then the frame is popped and control returns to the parent.

This structure keeps output from one execution branch from spilling into another. That matters for regulated enterprise environments like payment support. 'Localized memory frames provide isolation guarantees that are structurally unavailable in flat-registry or conversational multi-agent systems,' the authors write. 'Untrusted outputs can be constrained to leaf-level handling.'

The stack invariant is mathematically formalized: when a pending skill call targets a non-root node, the top of the stack must correspond to that node's parent. The runtime, not the LLM, manages execution flow, which reduces the chance of navigation errors during deep traversals. The broader lesson from production agent systems is clear, see how cost-efficient agent orchestration narrows the gap to frontier systems.

What the benchmarks reveal

The evaluation compares flat and hierarchical routing across several scenarios, holding the LLM constant. Key findings:

  • Prompt scalability: At N=128 tools (800-character schemas), hierarchical routing uses about 1,733 input tokens per task compared to about 28,178 for flat, a 16x reduction. Per-call schema tokens drop from 17,791 to 277.
  • Workflow pressure: With noisy chat history and two-step tasks, hierarchy maintains about 0.73 task success with 5.3k prompt characters at N=128, versus 140k for flat. Wrong-action and wrong-choice rates are near zero for the hierarchical system.
  • Agentic routing: At N=128 (400-character schemas), hierarchy achieves 0.70 task success with 3.6k prompt characters; flat uses 87k. Wrong-argument rates are 0.05 per decision versus 0.40 for flat.

The trade-off: hierarchical routing uses more sequential LLM calls, about 10 per task versus 2 for flat at N=128, but keeps total input tokens lower. The paper notes that 'hierarchical prompts remain an order of magnitude smaller' even when both architectures converge on similar task success rates. For teams evaluating whether to adopt such an architecture, a practical guide to working with AI coding agents provides useful context, see best practices for AI coding agents.

From theory to payments

The architecture was built for UPI Help, an AI support product handling transaction queries, complaint resolution, and mandate management for India's Unified Payments Interface. Hierarchical orchestration lets the root orchestrator first select a domain (like 'mandate operations'), then expose only that domain's sub-skills for subsequent routing.

The paper reports 100% route-level success on mandate and payment query families where the skill tree is fully populated, with lower per-query latency than a flat terminal baseline. Security controls including capability fencing, localized execution frames, and manifest-level governance metadata keep the system aligned with the requirements of high-trust payment-support environments.

The larger picture

The paper places itself within a lineage that includes Toolformer, Voyager, AutoGen, and MemGPT. What sets this approach apart is its formal debt to automata theory. The stack-based control loop moves the agent from a finite-state machine to a pushdown automaton, giving it context-free memory for nested workflows.

For teams building production agent systems, the architecture offers a declarative scaling path. New capabilities can be added as sibling skills (horizontal scaling) or deeper sub-orchestrators (vertical scaling) by appending JSON entries to a parent's manifest, with no changes to the core routing loop required. The paper's production context in digital payments also shows these patterns work under real-world constraints: auditability, capability boundaries, and controlled execution of sensitive flows. This aligns with the growing recognition that agent infrastructure, not just model performance, determines real-world reliability, see Meta's bet on agent infrastructure.

The full paper is available on arXiv. As agentic systems move from demos to production deployments, formal approaches to orchestration may become as essential as the models themselves.

Get the tech essentials in 3 minutes every morning

One email, every weekday, with what actually matters in AI and tech.