Deploying AI Agents and Choosing Small Language Models: Practice Notes (Part 2)

    This article explains how to move large language model applications from impressive demos to dependable production systems. It covers how to split model capability into base, task execution, and engineering layers, when AI agents are worth their added complexity, how to set boundaries on tool calls and stop conditions, when small and mid-sized models are enough, how to estimate memory and latency, and how to build a minimal evaluation loop for model selection.

    1. Rethinking Large Models: From Answering Questions to Completing Tasks

    When people first learn about large models, they are often impressed by how fluent the answers are and how complete the reasoning appears. Once they start building applications, the focus usually shifts. The questions become whether the model understands business constraints, whether it calls tools correctly, whether it recovers after a failure, and how much time and cost it takes to complete one task that actually works.

    Judging a model by single-turn question answering no longer covers real applications. A response that looks complete may miss a key condition. A successful demo does not necessarily mean the system can handle large volumes of real requests reliably.

    So, instead of asking whether a model is “strong” in general, it helps to break the question into three layers:

    • Base capability layer: Can the model understand input, extract information, reason, and generate content that meets the requirements?
    • Task execution layer: Can the system use retrieval, computation, and external business interfaces to complete concrete work?
    • Engineering and operations layer: Can the system keep running under constraints on cost, latency, security, and maintainability?

    This is the common starting point for understanding the value of AI agents and smaller models. A large model is no longer just a chat interface. It is a capability component inside a software system.

    2. The Value of Agents Is More Than “Letting the Model Think a Few More Steps”

    An agent usually organizes its actions around a goal. It forms a task loop by combining a model, tools, and state management. The main difference from ordinary question answering is not longer answers. It is the ability to decide the next action based on external feedback.

    A typical workflow can be summarized as:

    User states a goal → Collect necessary information → Plan steps → Call tools → Check results → Continue or finish.

    For example, when handling an internal document review task, the system may first need to confirm the time range, retrieve relevant materials, extract key facts, check whether different sources conflict, and finally produce a conclusion backed by evidence. This kind of task is not a single text generation step. It is a combination of multiple constrained steps.

    1. Do Not Hand Fixed Workflows Entirely to the Model

    Being more autonomous is not always better for an agent. For tasks with fixed steps and clear rules, a deterministic workflow is usually easier to test and easier to explain when it fails.

    For example, form field validation, amount calculation, and permission checks should rely on explicit rules. Models are better suited to semantic ambiguity, unstructured information, and expressions that are hard to enumerate.

    A sensible division of labor is to let code handle what is deterministic and let the model handle what is uncertain. Add autonomous planning only when the task path truly needs to change based on intermediate results.

    2. Tool Calls Need Clear Boundaries

    When a model generates a tool call intention, that does not mean the system should execute it directly. The execution layer should check, at a minimum, the caller’s permissions, parameter format, operation scope, and business state.

    For read-only queries, moderate constraints based on risk are usually sufficient. For high-risk operations such as deleting data, making payments, publishing content, or changing permissions, require human confirmation or an independent approval step.

    Pay particular attention to the fact that retrieved documents, web page text, and tool outputs should all be treated as external data. A command-like sentence inside such content must not be allowed to change system permissions or override established rules. This principle is an important defense against prompt injection.

    3. Stop Conditions and Failure Recovery Matter Just as Much

    An agent that keeps trying without ever stopping can easily turn into a costly loop. In implementation, define a maximum number of steps, a total time limit, detection of repeated actions, and a clear exit path for cases where the task cannot continue.

    Write operations also raise the problem of repeated execution. A network timeout does not necessarily mean the operation failed. Blind retries can create duplicate records or duplicate submissions. For this reason, business interfaces should support idempotency where possible, and the system should store key execution states.

    3. Why Small and Mid-Sized Models Deserve a New Look

    Parameter count is an important measure for understanding a model, but it is not the only factor that determines how well an application works. Training data quality, training methods, task adaptation, and inference configuration all affect performance in a specific scenario.

    The most notable progress in small and mid-sized models is not that they are replacing larger models across the board. It is that a growing number of tasks with clear boundaries can now be completed with lower resource requirements.

    1. Simple Tasks Do Not Always Need the Strongest Model

    Intent classification, field extraction, short text rewriting, fixed-format generation, and knowledge question answering within a defined scope usually have clear input and output constraints.

    For these tasks, a model only needs to reach the accuracy and stability the business requires. Adding more parameters may increase computing costs without a clear business benefit.

    However, this judgment must come from task testing, not be inferred from parameter count. Even within text classification, different industry terminology, numbers of categories, and error costs can significantly change how hard the task is.

    2. Limitations of Small Models Often Appear in Complex Constraints

    A model that can converse naturally does not necessarily handle multi-condition reasoning reliably. Common difficulties include:

    • Inputs containing many similar details, where the model must locate the right one accurately;
    • Multiple requirements that have priorities or conflict with each other;
    • Tasks that require calling several tools in sequence while keeping intermediate state;
    • Outputs that must follow a strict format without omitting business conditions;
    • Questions outside the model’s knowledge, where it must express uncertainty.

    For this reason, a model that “sounds good in conversation” should not be treated as ready for production. For real business use, test how the model behaves at boundary conditions, with abnormal inputs, and when information is insufficient.

    3. Fewer Parameters Do Not Always Mean Faster Results

    Inference speed also depends on hardware, concurrent load, input length, output length, numerical precision, and scheduling strategy.

    If a smaller model often misunderstands the task, needs several retries, or must generate longer explanations to reach the goal, its total task time may not be shorter. Evaluate the complete task, not a single isolated generation.

    4. How to Estimate Resources Instead of Looking Only at Model File Size

    When deploying a model, first separate the memory used by the weights from the total memory used at runtime.

    Weight storage can be estimated with a simplified relationship:

    Weight storage ≈ number of parameters × bytes required per parameter.

    For example, a model with about 8 billion parameters that uses 2 bytes per parameter needs roughly 16 billion bytes for the weights alone. This calculation uses decimal byte units and is only a theoretical estimate.

    Actual deployment also needs room for runtime buffers, intermediate computation results, attention caches, and the serving framework. As context length and the number of concurrent requests grow, cache usage can rise noticeably.

    Lowering weight precision usually reduces storage and GPU memory use. The actual benefit, however, depends on hardware support, the execution implementation, and the model itself. Quantization can also affect complex reasoning, numerically sensitive tasks, and strict output formats. Confirming that a model loads is not enough to call the optimization complete.

    A safer sequence is to first set the minimum acceptable quality for the task, then test different precision levels, context lengths, and concurrency settings to find an operating point that meets the business constraints.

    5. Breaking “It Feels Slow” Into Problems You Can Locate

    The latency users notice usually comes from several stages:

    End-to-end latency = request queuing + input processing + model generation + external tool execution + result validation and post-processing.

    In multi-turn agent tasks, these costs repeat at each step. For this reason, replacing the model alone may not fix a slow overall response.

    1. Separate Time to First Response From Task Completion Time

    Time to first response affects how interactive the system feels, while total task time determines how efficiently the work gets done. Streaming output lets users see content sooner, but it does not automatically reduce time spent on tool queries, waiting on external systems, or later validation.

    Record these two metrics separately so that a fast start is not mistaken for a fast finish.

    2. Reduce Unnecessary Context and Unnecessary Output First

    Sending the full message history with every turn increases computation and can let irrelevant information distort the model’s judgment. Keep only the state needed for the current stage, compress history into structured summaries, and retain the source of key facts.

    Output should also match its purpose. If the downstream program only needs a few fields, do not ask the model to write a long explanation first and then extract the fields from it.

    3. Run Steps in Parallel Only When Dependencies Allow

    Independent queries can run in parallel. Operations that depend on earlier results must run in sequence. Blind parallelism wastes resources and can lead the system to make decisions too early, based on incomplete information.

    The goal of performance optimization is not to run more steps at the same time. It is to shorten the critical path.

    6. Building a Minimal Evaluation Loop for Model Selection

    Without a consistent evaluation method, model selection can easily become a matter of subjective impression. A more reliable approach is to build a repeatable validation process around real tasks.

    1. Define What Success Means First

    Different tasks need different standards. Field extraction should focus on correctness, completeness, and format compliance. Knowledge question answering should focus on factual accuracy and supporting evidence. Tool execution should focus on whether the goal was actually achieved and whether any unauthorized operations occurred.

    For tasks that cannot be measured against a single standard answer, define manual scoring rules in advance so that reviewers do not judge based only on writing style.

    2. Make Sure the Test Set Covers Failure Cases

    In addition to typical samples, include cases with insufficient information, ambiguous wording, very long inputs, contradictory materials, unavailable tools, and malicious instructions.

    Keep test data properly separated from debugging samples. Otherwise, the system may only adapt to a limited set of examples without actually improving its ability to generalize.

    3. Track Quality, Latency, and Cost Together

    At a minimum, track task success rate, format compliance rate, tool call success rate, number of retries, human intervention rate, and latency distribution.

    Beyond average latency, pay attention to high-percentile latency, since a small number of very slow requests can seriously hurt the user experience. Calculate cost per successful task where possible, including failed retries, tool calls, and manual review, rather than counting only the cost of a single generation.

    4. Tiered Routing Adds Engineering Cost

    For businesses where request difficulty varies widely, a lightweight model can handle simple requests, a more capable model can handle complex tasks, and high-risk results can go to human review.

    Routing is not free. The system must judge task difficulty, define conditions for upgrading to a stronger model, and handle misrouted requests. Do not rely only on the model’s own statement that it is confident. Decide whether to escalate based on format validation, evidence completeness, rule checks, and historical evaluation results.

    7. A Safer Path to Production

    For developers who are just starting out, begin with tasks that have a clear scope, verifiable results, and low risk.

    Step one: define the inputs, outputs, and business boundaries. Write down what the system should do, what it must not do, and how failures are handed back to a human.

    Step two: build a baseline that does not depend on a complex agent. Validate the requirements first with rules, retrieval, or a single model call, and avoid introducing multi-turn planning too early.

    Step three: compare different models and runtime configurations on the same test set. Fix the evaluation conditions, record versions, prompts, and sampling settings, and reduce interference in the comparison.

    Step four: add tool calls and dynamic planning only when the existing approach is clearly limited. Each new autonomous behavior should come with matching permission checks, logs, and test cases.

    Step five: launch on a small scale and keep collecting failure cases. Classify the errors to determine whether the cause is model capability, data quality, tool design, or business rules, and then make targeted improvements.

    Conclusion

    The key to practical work with large models is shifting from chasing impressive single demos toward building systems that can be verified, controlled, and improved over time.

    AI agents provide a way to connect language understanding with external actions. Small and mid-sized models expand the options for low-cost deployment and task-specific use. Neither one is a solution by default. Agents need strict execution boundaries, and smaller models need solid task evaluation.

    What is worth pursuing is not larger parameter counts, longer reasoning traces, or more tool calls. It is completing tasks reliably, within clear constraints, using appropriate resources.