Getting Started with Open-Source AI Agent Frameworks: Build Your First Assistant

    This article explains how an AI agent framework differs from a large language model, why tool calling makes agents able to act, and how to connect a model, register a simple tool, and run your first task loop. It also covers practical tips on memory, context use, cost, and human confirmation.

    1. Two Concepts First: What an Agent Is, and What a Model Is

    A common mix-up when people first meet AI agents is treating an agent framework and a large language model as the same thing. They sit at two different layers.

    An agent is the “hands and feet.” An open-source AI agent framework is an engineering shell that lets a model carry out real tasks for you. It usually runs in a local terminal environment and provides a few core capabilities:

    • Task breakdown: If you say, “Help me organize last week’s meeting notes,” it can split that into a chain such as “read the document → extract key points → summarize → produce the result.”
    • Tool use: Through a standard interface protocol, the model can call external tools, such as reading and writing files, searching a knowledge base, or invoking a code interpreter.
    • Memory: It can remember what you have done before, so every conversation does not start from zero.
    • Extensibility: You can install plugins, register custom skills, and even connect an instant-messaging app so the agent stays online as a bot.

    The model is the “brain.” An agent framework does not create intelligence by itself. It schedules and executes work; the actual reasoning comes from the model behind it. That model needs a few basic capabilities:

    1. Tool calling / function calling: This is the core requirement. The model must recognize when to call which tool and which arguments to pass. Otherwise the agent has hands but no judgment.
    2. A long enough context window: The longer the context, the longer the task chain an agent can handle. Mainstream models now commonly support context on the order of hundreds of thousands to a million tokens, which makes complex multi-step work possible.
    3. Switchable reasoning modes: Some tasks need deep thinking; others only need a fast reply. A model that supports both “thinking” and “non-thinking” modes lets the agent match effort to task complexity and balance quality with cost.

    In one sentence: the model decides intelligence, and the agent decides execution. When the two fit well, you get a “point it and it goes” experience—you state what you want, and it breaks down the steps, calls tools, and keeps moving with little supervision.

    2. Why “Agent + a Tool-Calling Model” Works So Smoothly

    The old pain point with large models was that they could talk but not act. If you asked one to handle a file, it would tell you what to do instead of doing it. Tool-calling protocols changed that:

    1. User intent → model decides whether a tool is needed → structured call (tool name + arguments) → agent executes → result returns to the model → model continues reasoning from the result → until the task is done

    The loop looks simple, but the engineering key is a standard protocol. When both the model side and the framework side follow the same function-calling convention, you can:

    • Swap models: Use different models for different tasks without changing code or reinstalling the framework—often only one configuration line.
    • Reuse tools: A tool function you have written can still be called after you change models.
    • Fall back on failure: If the current model cannot handle a task, such as a long document or complex reasoning, retry with a stronger model.

    Another practical benefit is cost control. Many model providers price inference differently by time of day: weekday daytime is peak, and other periods are cheaper. For an individual developer, running batch jobs in lower-price windows keeps the cost small enough to use the setup freely.

    3. Hands-On: Run Your First Agent from Scratch

    Step 1: Get an API Key

    An API key is a credential. With it, your agent program can call a model service. If you have not done this before, the flow is straightforward:

    1. Register in the console of a model provider, such as Baidu AI Cloud’s Qianfan platform, and finish the account setup that provider requires.
    2. Open the API key management page and create a new key.
    3. Copy it and store it in a local environment variable.
    1. # Store the key in an environment variable instead of hard-coding it
    2. export MODEL_API_KEY="your-key"

    Security note: Never send the key to anyone. Whoever has it can spend your quota. Protecting the key protects your budget. If you suspect it has leaked, revoke it in the console and issue a new one immediately.

    Step 2: Configure Model Access

    In the agent framework’s configuration file, enter the model endpoint and the key. It is useful to configure more than one model and switch by task:

    1. {
    2. "models": {
    3. "daily": {
    4. "endpoint": "standard inference endpoint",
    5. "mode": "non-thinking"
    6. },
    7. "hard": {
    8. "endpoint": "deep reasoning endpoint",
    9. "mode": "thinking"
    10. }
    11. }
    12. }

    Step 3: Register a Simple Tool and Close the Loop

    Registering a tool usually means a function definition plus a short description so the model knows what the tool does:

    1. @tool
    2. def read_file(path: str) -> str:
    3. """Read a text file at the given path and return its contents"""
    4. with open(path, "r", encoding="utf-8") as f:
    5. return f.read()

    Then give the task in natural language, for example: “Summarize the error messages in the logs into a report.” The agent decides which file to read, how to filter the content, and what format to use. You mainly check the result.

    4. A Few Practical Tips

    • Validate with a simple task first: Start with a single-tool job such as “read a file and summarize it,” then add multi-tool collaboration.
    • Use memory: For repeated work, let the agent remember your preferences, such as a report format, so later tasks take less effort.
    • Watch context usage: Long tasks consume context quickly. Summarize and compress intermediate results in time.
    • Keep a human confirmation step: For irreversible actions such as deleting or sending, require confirmation before the tool runs.

    5. Wrap-Up

    An AI agent is not mysterious. It is the combination of a model that thinks and a framework that does the work. Choose a model that supports tool calling and a long context, pair it with an actively maintained open-source agent framework, and you can build a digital assistant that actually does work at a very low cost. The barrier to entry is modest, and it is worth a try for developers and anyone who cares about productivity.