Building a Simple Agent with Open-Source LLMs: A Hands-On Evaluation and Model Selection Guide

    This article shares a practical approach to building a basic multi-dimensional text analysis Agent using open-source large language models. It explains why decoupling the Agent framework from the model layer matters, presents a repeatable test scenario, summarizes three typical capability profiles observed across open-source models, and distills a reusable methodology for evaluating models, controlling costs, and designing a model-agnostic Agent architecture.

    Building a Simple Agent with Open-Source LLMs: A Hands-On Evaluation and Model Selection Guide

    1. Background: Why “Graft” LLMs onto an Existing Framework

    A common dilemma in Agent development is that a model paired with its native framework usually delivers the best experience, but models iterate so quickly that locking into one native framework means constantly switching development environments and toolchains. For individual developers or small teams, this migration cost is hard to justify.

    As a result, many developers adopt a compromise: use a mature coding framework as the Agent’s execution backbone, and connect different open-source LLMs through APIs. The benefits are:

    1. A stable framework layer that provides common capabilities such as task orchestration, tool calling, and context management;
    2. A pluggable model layer—whichever model is stronger or more cost-effective, switch to it;
    3. Controlled evaluation cost, enabling horizontal comparison of multiple models against the same task benchmark.

    This article follows this “framework-decoupled” approach. Around one basic task—a multi-dimensional text analysis Agent—it reviews how different models actually perform and distills a reusable evaluation methodology.

    2. Test Scenario Design

    To make the comparison meaningful, the test task was fixed to a single category: build an Agent that performs multi-dimensional analysis of input text, including topic extraction, sentiment judgment, key entity recognition, and structured output. The task flow is:

    1. User input text
    2. ↓
    3. Agent plans analysis steps (breaks the task into subtasks)
    4. ↓
    5. Executes subtasks via analysis tools / the model itself
    6. ↓
    7. Aggregates results, self-checks format and logic
    8. ↓
    9. Outputs structured results (JSON)

    The task looks simple, but it covers several core dimensions of Agent capability:

    • Instruction understanding: Can it accurately grasp which dimensions “multi-dimensional analysis” should output?
    • Plan and execute: Can it decompose steps before acting, rather than improvising step by step?
    • Self-checking and correction: When the output format is wrong, can it detect and fix the problem itself?
    • Coding ability: Can it correctly generate the scripts and parsing logic involved along the way?
    • Token efficiency: Is the consumption acceptable for completing the same task?

    3. Evaluation Dimensions and Observations

    Based on multiple rounds of testing, the performance of common open-source models can be grouped into several typical profiles (these are generalized capability profiles and do not refer to specific products):

    3.1 Strong at Code, Weak at Planning

    These models generate accurate code and handle single-point tasks well. But in multi-step Agent tasks, they often deviate from instructions—for example, when asked to output five analysis dimensions, they may only produce three. They lack proactive planning, behaving more like “push and it moves,” and their self-correction after errors is limited. In addition, discounted subscription resources for these models are often in tight supply, making the effective cost of access non-trivial.

    3.2 Well-Rounded, but Unfriendly Billing

    Other models perform adequately in instruction understanding and planning, with no obvious weaknesses. The problem lies mainly on the commercial side: there is no monthly or subscription-based resource plan, only pay-per-token billing. For Agent scenarios that require multiple rounds of reasoning and repeated reading of long contexts, costs accumulate quickly under pay-as-you-go pricing. In practice, a task lasting ten-plus minutes consumed an acceptable amount of token fees, but completing a full cycle of Agent design and debugging could accumulate costs on the order of tens of yuan within a few hours—not economical for long-term use.

    3.3 Strong at Planning, but Token-Hungry

    A third category excels at “understanding intent”: it can accurately infer what the user wants, and even generalize by proactively completing implicit steps in a task—precisely what the first two categories lack most. The downside is an overly long thinking process (reasoning chain). Although the quality is high, tokens are consumed extremely fast—a simple task can burn through a large token quota in a very short time. That said, under a monthly subscription model, the amortized unit cost is usually still better than pure pay-per-token plans.

    4. A Model Selection Methodology Distilled from Testing

    4.1 Evaluate Four Capabilities Separately

    Instruction understanding, task planning, code generation, and self-correction are four relatively independent capabilities. Many benchmarks only look at code generation, but in Agent scenarios, planning and self-checking are often what determine success or failure. Design independent probe tasks for each capability and score them separately.

    4.2 Model Costs by Task Type

    • Exploratory tasks (lots of debugging and trial-and-error): prioritize monthly/subscription-based resources to avoid runaway pay-as-you-go costs;
    • Production tasks (stable workflows): pay-per-token is fine, while reducing consumption by trimming system prompts, controlling context length, and caching intermediate results;
    • Long-thinking models need separate evaluation: the longer the reasoning chain, the faster tokens burn. Measure “cost per task” in real tests rather than looking only at the unit price.

    4.3 Keep the Framework Decoupled from the Model

    Implement task orchestration, tool calling, and memory management at the framework layer, treating the model purely as a replaceable inference engine. A schematic configuration abstraction:

    1. class AgentConfig:
    2. framework: str # Execution framework, kept stable
    3. model_endpoint: str # Model API endpoint, switchable anytime
    4. max_context_tokens: int # Context budget
    5. planning_mode: str # Planning mode: plan-then-execute / step-by-step
    6. def run_agent(config: AgentConfig, task: str):
    7. plan = make_plan(config, task) # Planning
    8. for step in plan:
    9. result = execute(config, step) # Execution
    10. if not validate(result): # Self-check
    11. result = repair(config, step, result)
    12. return aggregate(plan)

    With this design, switching models only requires changing one endpoint and a few parameters, keeping evaluation costs extremely low.

    4.4 Don’t Over-Customize for a Single Model

    Rapid model turnover means today’s “best” model may be surpassed within months. If your prompts and workflows are deeply bound to one model’s behavioral habits, migration costs will be high. A safer approach: write prompts as general intent descriptions, and confine model-specific differences to the configuration layer.

    5. Current Practice Summary and Outlook

    Overall, a common combination for developers building Agents today is a mature programming framework as the execution layer, plus a cloud platform’s model service as the inference layer. Some cloud platforms already offer unified access aggregating multiple open-source models, along with subscription-based resource bundles—friendly for Agent development scenarios that require frequent trial and error, since developers can switch and compare multiple models at low cost within a single account system.

    This approach has its shortcomings, of course—for example, some strong new models are not yet integrated into the unified gateway and require separate requests. But as long as no model emerges that clearly surpasses the current choice in capability, there is no need to switch for the sake of switching.

    Agent technology is still evolving rapidly, and the “planning and understanding” shortcomings of models are being progressively addressed. For developers, rather than chasing individual models, building “a reproducible evaluation benchmark + a decoupled system architecture + a clear cost model” is the long-term competitive edge in a fast-iterating environment.