Abstract
Enterprise deployment of Large Language Model (LLM) agents is often hindered by execution instability and a lack of domain-specific procedural knowledge. We present Routine, a structural planning framework that bridges the gap between high-level intent and low-level execution. By providing agents with explicit, multi-step scripts, Routine significantly improves tool-calling accuracy. Our results show that smaller models, when fine-tuned on Routine-based distilled data, can achieve performance levels (95.5% accuracy) comparable to frontier models like GPT-4o.
Introduction
In enterprise environments, LLM agents frequently encounter a "last-mile" problem. While they can interpret complex user intents, they often struggle with the precise sequence of API calls, parameter passing, and tool selection required by rigid corporate processes. Research indicates that over 85% of agent errors in these settings stem from execution instability rather than a lack of general reasoning capability.
The Routine framework addresses these challenges by introducing a structured intermediate representation—a "Routine"—that guides the agent through specific workflows. This approach mitigates hallucinations and ensures that domain-specific procedures are followed consistently.
The Routine Framework
A "Routine" is a structured script that defines a sequence of operations to fulfill a specific goal. Unlike open-ended planning, a Routine provides explicit instructions, tool mappings via the Model Context Protocol (MCP), and detailed input/output descriptions for each step.
By transforming a complex reasoning task into a series of structured execution steps, Routine allows models to focus on accurate tool invocation rather than discovering the process from scratch.
Architectural Innovations
The Routine system utilizes a modular architecture to optimize both performance and cost.
Modular Design
The system decouples the Planning Model from the Execution Model. The Planning Model (typically a high-capacity model like GPT-4o) generates or retrieves the appropriate Routine based on the user's request. The Execution Model (which can be a smaller, specialized model) then follows the Routine to perform the actual tool calls.
Variable Memory
To handle large data payloads without exceeding context windows or increasing token costs, the system implements Variable Memory. Large tool outputs are stored as unique variables (e.g., VAR_001). The model only manages these references, while the system injects the actual data at the API level during subsequent tool calls, preventing "context drowning."
Evaluation and Results
The framework was evaluated using a combination of open-source (BUTTON) and proprietary enterprise HR datasets. The results demonstrate a dramatic increase in stability across various model sizes.
| Model | Baseline (No Routine) | With Routine | Fine-tuned (Distilled) |
|---|---|---|---|
| GPT-4o | 41.1% | 96.3% | - |
| Qwen3-14B | 32.6% | 83.3% | 95.5% |
| GPT-3.5-Turbo | 22.1% | 52.7% | - |
Notably, the Qwen3-14B model, when fine-tuned on high-quality distilled data guided by Routines, nearly matched the performance of GPT-4o. Ablation studies confirmed that explicitly naming the required tool within the Routine was the most critical factor for success, providing a significant accuracy boost.
Conclusion
The Routine framework provides a robust solution for deploying LLM agents in structured enterprise environments. By externalizing procedural knowledge into stable scripts and optimizing the execution pipeline, Routine enables even smaller models to perform complex, multi-step tasks with high reliability. Future work will focus on autonomous Routine generation through reinforcement learning and expanding the framework to multi-agent coordination.
Summary updated