Bitter Lessons in Tool Use: Empirical Superiority of Programmatic Tool Calling over JSON
This paper systematically evaluates the performance of Programmatic Tool Calling (PTC) compared to native JSON calling in Large Language Models (LLMs). Using the BFCL v4 benchmark, we empirically compare 14 models across different generations. PTC exposes tools as typed Python stubs, enabling chained or parallel invocation via code, with execution and result processing completed within a single agent turn. Results show PTC matches or exceeds the JSON baseline in 11 out of 14 models, with the GPT-5.6 family seeing a 10.6% performance boost. PTC demonstrates superior robustness in complex scenarios like parallel fan-out and context rotation, suffering only minor degradation. The study confirms PTC as a viable, robust alternative to JSON, with performance scaling alongside model capabilities, offering key insights for building stronger agent architectures.
Background and Context
Large Language Models are undergoing a fundamental architectural shift, evolving from passive information responders into proactive autonomous agents capable of executing complex workflows. At the heart of this transition lies the mechanism of tool calling, which allows models to interface with external APIs, databases, and computational resources. However, the prevailing standard for this interaction has long been the generation of structured JSON objects. While effective for simple, isolated queries, this rigid, text-based serialization format struggles with tasks requiring intricate logical chains, conditional branching, or parallel execution. The limitations of JSON become particularly apparent when models must coordinate multiple dependent actions or handle noisy contexts, often leading to parsing errors and degraded performance in real-world deployments.
To address these systemic limitations, recent research introduces Programmatic Tool Calling (PTC), a novel paradigm that redefines how models interact with external tools. Instead of outputting static JSON structures, PTC exposes tools as typed Python stubs, allowing the model to generate executable code snippets. This approach leverages the inherent flexibility and expressive power of programming languages, enabling natural chaining of function calls and parallel execution within a single agent turn. By treating tools as code, PTC transforms the interaction from a simple data exchange into a dynamic execution flow, potentially overcoming the logical constraints imposed by rigid schema definitions.
The motivation for this shift is driven by the need for more robust and scalable agent architectures. As applications demand higher levels of autonomy and complexity, the ability to handle multi-step reasoning and concurrent operations becomes critical. PTC aims to fill the gap in empirical evidence regarding how different model generations perform under this new paradigm. By systematically evaluating PTC against traditional JSON methods, the study seeks to establish a solid foundation for understanding the evolution of tool use, providing developers with data-driven insights into whether code-based invocation offers tangible advantages over established text-based protocols.
Deep Analysis
The technical implementation of PTC fundamentally alters the interface between the language model and the tool execution engine. In this framework, tools are not merely described by schemas but are exposed as typed Python stubs. When a model determines a tool is necessary, it generates Python code that invokes these stubs. This code is then parsed and executed by a runtime engine within a single agent turn, with results fed back to the model for further processing. This mechanism eliminates the latency and error accumulation associated with multi-turn JSON parsing, streamlining the interaction loop and enhancing efficiency.
Empirical evaluation was conducted using the BFCL v4 benchmark, a comprehensive standard for assessing tool use capabilities. The study analyzed 14 distinct language models across various generations, ensuring a representative sample of current and past model architectures. The results demonstrated that PTC matches or exceeds the performance of the JSON baseline in 11 out of the 14 models tested. This broad compatibility suggests that the paradigm is not limited to specific model types but offers generalizable benefits across the landscape of large language models.
A particularly significant finding relates to the performance of the GPT-5.6 family, which exhibited a 10.6% performance boost when using PTC compared to JSON. This improvement highlights the synergy between advanced model reasoning capabilities and the structured logic of code-based invocation. Furthermore, in complex scenarios such as parallel fan-out, where multiple tools must be called simultaneously, PTC showed superior robustness across 13 models. In context rotation tests, which simulate real-world noise and distraction, JSON baselines degraded by an average of 2.3%, whereas PTC maintained high stability with minimal performance drop, underscoring its resilience in challenging environments.
Industry Impact
The adoption of Programmatic Tool Calling signals a pivotal shift in agent architecture design, moving towards a "tools as code" standard. This paradigm offers significant advantages for both open-source communities and industrial applications. For developers, PTC provides a more flexible and expressive method for integrating tools, lowering the barrier to constructing complex agent workflows. The ability to use standard programming constructs like loops and conditionals directly within the agent's logic simplifies the development of sophisticated applications that require dynamic decision-making.
In industrial settings, the robustness of PTC makes it particularly suitable for high-reliability, high-throughput environments. The reduced error rates in noisy contexts and the efficient handling of parallel tasks address key pain points in production deployments. As models continue to improve in reasoning and code generation capabilities, the potential of PTC is expected to scale accordingly. This trend suggests that future agent systems will increasingly rely on code-based tool invocation to achieve higher levels of autonomy and complexity.
The study also highlights the importance of type systems and execution environments in optimizing PTC. By reducing the ambiguity inherent in natural language descriptions, typed stubs help minimize model errors during tool invocation. This precision is crucial for building trustworthy agents that can operate safely in critical applications. The findings imply that investment in better type inference and execution frameworks will yield substantial returns in agent performance and reliability.
Outlook
Looking forward, the success of PTC points to a future where code generation and tool execution are tightly integrated components of the agent core. As foundation models become more proficient at understanding and generating complex code, the gap between natural language reasoning and programmatic execution will continue to narrow. This evolution will enable agents to tackle increasingly difficult problems that require multi-step planning and precise tool coordination.
Future research should focus on optimizing the synergy between code generation and tool execution. This includes developing more efficient type systems that can adapt to dynamic tool schemas and reducing the overhead of parsing and executing generated code. Additionally, exploring hybrid approaches that combine the strengths of JSON for simple queries and PTC for complex workflows could offer a balanced solution for diverse application needs.
Ultimately, PTC represents more than a technical improvement; it is a redefinition of the large language model as a programmable problem solver. By embracing the flexibility and logic of code, agents can transcend their current limitations and evolve into truly autonomous entities capable of navigating the complexities of the real world. This shift promises to unlock new possibilities in automation, decision-making, and human-AI collaboration, setting the stage for the next generation of intelligent systems.