AI Agent Deployment Guide: Model Selection, Tool Calling, and Go-Live Checks
Deploying an AI Agent in production requires more than picking a model with high benchmark scores. This article covers how to evaluate function-calling reliability (schema adherence, parallel calls, error handling, and termination), estimate VRAM correctly by distinguishing total parameters from activated parameters in MoE models, and choose between on-device and cloud deployment with a structured comparison table. It also addresses multimodal and long-context acceptance testing, and outlines a robust tool-calling loop with timeouts, retries, and step limits.
1. Define the Deployment Goal First
High scores on public leaderboards do not guarantee that a model can reliably power an Agent. In every round, an Agent must decide whether to call a tool, generate parameters that conform to a JSON Schema, read the tool’s response, and then plan the next step. A failure at any point breaks the entire pipeline. Before selecting a model, answer three questions: where will the model run, how much VRAM is available, and how stable is its tool calling.
How do you evaluate function-calling capability? Use a fixed set of test samples and check at least four aspects:
- Schema adherence: Do parameter names, types, and required fields exactly match the definition? Can the output be parsed directly as JSON?
- Parallel calls: When multiple tools are requested in one round, does each call return a result, and do the call IDs map one-to-one?
- Error handling: After a tool error or timeout, can the model interpret the error message and adjust its parameters, instead of repeating the same request?
- Termination judgment: Once the task is complete, can the model stop calling tools and produce a final answer?
Record the pass rate and sample size for every test run. When the sample size is too small, the pass rate has limited reference value.
2. VRAM Estimation: Activated Parameters ≠ Memory Usage
Mixture-of-Experts (MoE) models split the network into multiple experts and activate only a subset during each inference pass. When selecting a model, distinguish between two numbers:
- Total parameters: Determine how much storage and VRAM the weights occupy. All experts must be loaded, even if only a few are used in any given inference pass.
- Activated parameters: Determine the compute per forward pass, which mainly affects generation speed and compute consumption.
Therefore, “3.8B activated parameters per pass” only means the compute is comparable to a 4B dense model—it does not mean VRAM usage is anywhere near that of a 4B model.
Weight VRAM can be roughly estimated with a simple formula: total parameters (in billions) multiplied by bits per parameter, divided by 8, gives the approximate size in GB. For example, a 25B-parameter model at 4-bit quantization requires about 12.5 GB for weights. This covers weights only. Actual deployment also requires KV cache, the inference framework, and runtime overhead—and the more concurrent requests, the larger the KV cache footprint.
Parameter scale, post-quantization VRAM, and context length should always be verified against the official model card. For every selection, record the following:
- Model name and version
- Quantization format, e.g., GGUF Q4_K_M, AWQ, GPTQ
- Inference framework, e.g., llama.cpp, vLLM
- Hardware model and VRAM capacity
- Measured time to first token and tokens per second, with prompt length, output length, batch size, and concurrency noted
Performance numbers without a measurement methodology are only a rough reference.
3. On-Device vs. Cloud: How to Choose
| Dimension | Lightweight On-Device Models | Mid-to-Large Cloud Models |
|---|---|---|
| Primary scenarios | Offline commands, local retrieval, simple tool calls | Long-document analysis, cross-file code edits, complex reasoning |
| Hardware constraints | Limited memory and power; heavier quantization required | Requires GPU VRAM; scale with concurrency |
| Function-calling stability | Must be tested separately; higher risk with complex schemas | Generally better, but still needs real-world testing |
| Context window | Shorter; input length must be controlled | Longer, but long inputs slow down responses |
| Multimodal input | Some support audio; vision capability varies by model | Generally stronger visual understanding |
| Data compliance | Data stays on the device | Data must be uploaded; compliance requirements must be evaluated |
| Cost structure | One-time hardware cost | Billed by usage duration or call volume |
You can copy the following table and fill it out for each candidate model:
| Item | Details |
|---|---|
| Model name and version | |
| Quantization format | |
| Inference framework | |
| Hardware and VRAM | |
| Official context length | |
| Function-calling pass rate (with sample size) | |
| Multimodal support | |
| Measured time to first token and tokens/s (with methodology) |
4. Multimodal and Long Context: Validate Capabilities in Real Scenarios
Multimodal models can accept image input, and some lightweight models also support audio. These capabilities should be accepted item by item in concrete scenarios.
- UI testing: When screenshot resolution is too low, button text and status indicators may not be recognized. It is recommended that the short edge of a screenshot be at least 1080 pixels—but this is only a starting point; you still need to verify with the actual font sizes in your interface. Spot-check key elements in each batch and manually review recognition results.
- Chart analysis: Results depend on OCR and coordinate reading. Numbers extracted from charts should be cross-checked against the source data item by item. A workable convention is to spot-check at least one result out of every ten; if the error exceeds the threshold, return the entire batch for manual review.
- Long context: A longer window does not necessarily mean better recall. Models generally reference information more reliably when it appears at the beginning or end of the input. Use a fixed question set to test recall of information located in the middle of the context.
5. A Stable Tool-Calling Loop
The tool-calling loop should break down each step, and every step must have a clear exit path when it fails. The Python code below illustrates the basic structure. In practice, replace it with the interfaces of the SDK you are using.
```python
import json
from jsonschema import validate, ValidationError
MAX_STEPS = 8 # Maximum loop rounds per task, to prevent infinite calls
TOOL_TIMEOUT = 10 # Timeout for a single tool call (seconds)
MAX_RETRY = 2 # Maximum retries after a read operation fails
def run_agent(llm, tools, schemas, user_input):
messages = [{“role”: “user”, “
