Troubleshooting Tool Call Failures When Deploying LLMs on Heterogeneous AI Chips

    When deploying open-source LLMs on heterogeneous AI accelerators, tool calls may fail silently—the model outputs JSON as plain Markdown text instead of structured tool-call tokens, breaking the entire Agent workflow. This article walks through a real-world troubleshooting case: how the issue was traced to a customized prompt template that overrode the model's native tool-call protocol, why the inference framework's built-in parser then failed, and how to fix it. It also examines the deeper root cause—insufficient adaptation between the chip's software stack and the model—and shares practical advice on containerized deployment and log-based monitoring for stable private deployment.

    1. Background and Symptoms

    In current LLM adoption practices, many enterprises deploy open-source large language models on domestic heterogeneous AI accelerators to meet data compliance and compute sovereignty requirements. However, deploying models in heterogeneous environments is rarely smooth—incomplete low-level adaptation often introduces subtle, hard-to-diagnose bugs.

    In a recent deployment, we used a mainstream open-source inference framework to serve an open-source LLM with tool-calling support on a cluster of heterogeneous AI accelerator cards. Basic chat functionality worked fine: the model generated text and answered questions fluently. But when testing the core Agent capability—tool calling—an anomaly appeared: instead of returning structured tool-call instructions that the inference framework could recognize, the model emitted the JSON payload (including tool arguments) as plain text into the conversation stream, wrapped in a “```json” Markdown code block. As a result, the upstream business application could not extract the function name and arguments, and the entire Agent workflow was interrupted.

    2. Troubleshooting and Root Cause Analysis

    The team quickly began investigating. Since the model clearly understood user intent and generated correct arguments, the problem was obviously not model capability, but output format control and parsing.

    2.1 Reviewing the Request Chain and Parameter Passing

    First, we inspected the request payload sent from the upstream application to the inference framework. The request body correctly included the tools parameter, with complete function names, descriptions, and JSON Schema for the arguments. In theory, the inference framework should inject these tool definitions into the model’s prompt and intercept the specific tool-call tokens in the model’s output, converting them into a structured response for the client. In reality, the client received only a plain text stream containing JSON.

    2.2 Comparing the Native Template with the Custom Template

    Further investigation revealed that, to help the model better understand tool definitions, the operations team had modified the default prompt template when configuring the inference framework. In this custom template, to “help” the model produce structured output more reliably, the following instruction was explicitly added to the system prompt: “When you need to call a tool, strictly output the tool-call arguments in ```json format.”

    This became the key clue. During pretraining, open-source LLMs typically learn a special token sequence (e.g., <|tool_call_start|>) to distinguish tool calls from ordinary text generation. The model’s native behavior is to emit these special tokens directly when it decides to call a tool; the inference framework detects them to trigger tool parsing. Our custom instruction forcibly changed this behavior, making the model follow the Markdown code block convention instead.

    2.3 Analyzing the Framework’s Built-in Parser Logic

    Reviewing the source code of the open-source inference framework showed that it ships dedicated tool parsers for various open-source models. These parsers use strict regular expressions designed to match the models’ native special token sequences and extract the JSON payload. When the model outputs “json ...“ instead, the regex simply doesn’t match, and the parser fails. Once parsing fails, the framework passes the content through to the client as an ordinary text stream—producing exactly the symptom we observed.

    3. Solution and Adaptation

    Once the root cause was clear, the fix was straightforward: respect the model’s native protocol established during pretraining, and avoid manually overriding the output format.

    3.1 Fixing the Custom Template

    We removed all non-standard instructions such as “output in ```json format” from the custom template, keeping only the standard tool-list injection placeholders. The revised template relies entirely on the model’s own instruction-following ability and its pretraining alignment.

    3.2 Verifying the Parsing Logic

    After resubmitting the tool-call request, the model correctly emitted the native special tokens during generation. The framework’s built-in parser matched them, truncated the streaming output, extracted the JSON arguments, and returned a standard tool-call object to the upstream application. The application then parsed the arguments and executed the corresponding local function, and the entire Agent workflow returned to normal.

    4. Deeper Root Cause: Insufficient Hardware-Model Adaptation

    Although fixing the template resolved the immediate problem, deeper reflection reveals why the operations team “over-engineered” the template in the first place: in initial deployment tests, the model’s native tool-call success rate was not high. This points to a deeper hardware-model adaptation issue.

    The underlying drivers, compute language, and operator libraries of heterogeneous AI chips often lag behind the latest open-source LLMs. Open-source models iterate extremely fast, frequently introducing new operators or attention mechanisms. When the base software stack in a heterogeneous environment is outdated, small deviations may appear in operator precision or special-token decoding. Such deviations are barely noticeable in ordinary text generation, but in tool-calling scenarios that demand strict format control, they can manifest as probabilistic call failures or malformed output.

    The fundamental fix, therefore, is to rebuild the inference image based on the chip vendor’s latest adaptation toolkit, compiled specifically for the current open-source model version. This ensures that every operator is not only functionally correct but also precision-accurate, so the model can fully exercise its native pretrained capabilities—rather than “patching” the underlying environment through prompt modifications.

    5. Improving Deployment Stability with Cloud Platforms

    Private LLM deployment and image rebuilding in complex heterogeneous environments place high demands on operations teams. In practice, it is advisable to leverage general-purpose cloud-native infrastructure to improve deployment standardization and observability.

    For example, during image rebuilding and environment validation, a cloud container platform and image registry can be used to package the heterogeneous environment’s dependencies, the inference framework, and their specific versions into standardized images. Containerization ensures consistency across development, testing, and production environments, avoiding “non-reproducible bugs” caused by environment drift. Storing model weights in object storage and mounting them over a high-performance network can also significantly speed up model loading.

    In addition, when investigating subtle issues like tool-call failures, cloud logging services and monitoring/alerting systems are invaluable. Feeding detailed inference-framework logs into a log service lets you quickly search for key fields (such as token sequences and regex match results) during troubleshooting. Setting up alerts on API call failure rates or specific error codes lets you detect environment-adaptation issues immediately, so you can roll back or intervene quickly.

    6. Conclusion

    Deploying LLMs on heterogeneous chips is a systems engineering effort that requires both a deep understanding of the model’s native protocol and attention to low-level hardware adaptation. When encountering tool-call anomalies, first check whether any manual intervention has overridden the model’s native output logic, and ensure the prompt template stays consistent with the inference framework’s parser regex rules. Then, assess how well the heterogeneous environment adapts to the open-source model, and resolve underlying operator and precision issues by rebuilding an adapted inference image. Combining this with a mature cloud-native platform for containerized management, logging, and monitoring helps enterprises complete private LLM deployment and business innovation more efficiently and reliably.