How Open-Source Agent Frameworks Help Enterprises Build Custom AI Agents

    This article compares off-the-shelf AI agent tools with open-source agent frameworks and explains how plugins extend those frameworks. It walks through building a Python plugin that lists files in S3-compatible object storage, covering environment setup, least-privilege access, plugin interface definition, implementation with pagination and logging, and plugin registration.

    1. Off-the-Shelf Tools or Open-Source Frameworks: How to Choose

    AI agent tools generally fall into two categories. The first is off-the-shelf products from vendors. You open the interface and start using them, and the vendor predefines their features and interaction model. The second is open-source base frameworks. These provide only low-level capabilities such as task scheduling, dialogue management, and plugin loading. Specific features are added through plugins. The table below summarizes the differences.

    Dimension Off-the-shelf agent tool Open-source agent framework
    Time to start Fast, ready to use on opening Requires installation, configuration, and some development
    Customization Limited to vendor-defined features Can be extended to specific business needs through plugins
    Data and deployment Usually runs in the vendor’s cloud Can be deployed in your own environment
    Maintenance responsibility Mostly handled by the vendor Upgrades, security, and testing are the user’s responsibility
    Security boundary Relies on the vendor’s permission model Permissions and auditing must be designed in-house
    Use cases General, standardized tasks Long-tail business needs and internal system integration

    For general tasks such as writing documents or translation, off-the-shelf tools are usually the simpler choice. If you need to connect to internal storage, ticketing systems, or databases, and you have requirements for where data is located, an open-source framework is a better fit. Before you choose, run each tool on a real task and judge by the actual results, not only by the feature list.

    2. What Plugins Can Do

    The plugin mechanism of an open-source framework typically covers three types of capabilities.

    1. External service calls: The agent uses plugins to call external APIs, retrieve real-time data, or trigger operations in third-party systems.
    2. Local software control: Plugins can read and write files and run terminal commands. These capabilities carry higher risk, so their scope must be strictly limited.
    3. Workflow chaining: Multiple plugins can run in sequence to complete a series of automated steps. For example, the agent might list files, summarize their contents, and then generate a report.

    The value of plugins lies in connecting the understanding of a large language model (LLM) with concrete operational capabilities. The model decides when to call which plugin, and the plugin runs deterministic code. For this reason, a clear plugin description directly affects whether the model calls it correctly.

    3. Common Application Scenarios

    Community plugins generally fall into two categories. The first improves the user experience, for example through memory enhancement, interface customization, and tone settings. The second targets specific work scenarios, such as the following three.

    • Content creation: Combines steps such as topic selection, material collection, and publishing to multiple platforms.
    • Design assistance: Generates or modifies design drafts from natural language descriptions.
    • Literature reading: Parses papers, extracts key points, and supports follow-up questions about the literature.

    These scenarios share a common feature: context that was previously spread across several tools can be orchestrated within a single framework. For enterprises, the second category of business plugins deserves more attention, because these plugins map directly to existing systems and workflows.

    4. Building an Object Storage Query Plugin

    The following example shows the full development process for a plugin that lists files in object storage. The example uses Python and targets object storage that is compatible with the S3 API.

    1. Set Up the Environment

    Use Python 3.9 or later, and install the dependencies in a virtual environment.

    1. python -m venv .venv
    2. source .venv/bin/activate
    3. pip install boto3 moto pytest

    boto3 provides access to object storage. moto and pytest are used for testing.

    2. Configure Credentials and Least Privilege

    Do not write credentials into code or logs. There are two recommended approaches: configure an IAM role in the runtime environment, or inject keys through environment variables. If your object storage is privately deployed, you also need to specify its access endpoint.

    1. export OBJECT_STORAGE_ENDPOINT="https://oss.example.internal"
    2. export PLUGIN_LOG_FILE="/var/log/agent/plugin.log"

    Grant only the operations the plugin needs. The policy below allows listing objects only under the logs/ prefix in the logs bucket.

    1. {
    2. "Version": "2012-10-17",
    3. "Statement": [
    4. {
    5. "Effect": "Allow",
    6. "Action": "s3:ListBucket",
    7. "Resource": "arn:aws:s3:::logs",
    8. "Condition": {
    9. "StringLike": {"s3:prefix": ["logs/*"]}
    10. }
    11. }
    12. ]
    13. }

    If the plugin later needs to read file contents, request the s3:GetObject permission separately. Do not broaden access to all operations.

    3. Define the Plugin Interface

    Frameworks typically use JSON to describe a plugin’s name, purpose, and parameters. The model relies on these descriptions to decide whether to call the plugin. More specific descriptions lead to more accurate calls.

    1. {
    2. "name": "query_object_storage",
    3. "description": "List files in a specified object storage bucket, with optional prefix filtering",
    4. "parameters": {
    5. "type": "object",
    6. "properties": {
    7. "bucket_name": {
    8. "type": "string",
    9. "description": "Name of the object storage bucket, for example logs"
    10. },
    11. "prefix": {
    12. "type": "string",
    13. "description": "Path prefix to query, for example logs/2023/. Can be empty."
    14. }
    15. },
    16. "required": ["bucket_name"]
    17. }
    18. }

    4. Implement the Plugin Logic

    The implementation below validates input, reads results page by page, and writes error details to the log. It returns only messages that are safe to expose to the model.

    1. import logging
    2. import os
    3. import re
    4. import boto3
    5. from botocore.exceptions import BotoCoreError, ClientError
    6. logger = logging.getLogger("query_object_storage")
    7. logging.basicConfig(
    8. level=logging.INFO,
    9. filename=os.getenv("PLUGIN_LOG_FILE", "plugin.log"),
    10. format="%(asctime)s %(levelname)s %(name)s %(message)s",
    11. encoding="utf-8",
    12. )
    13. BUCKET_PATTERN = re.compile(r"^[a-z0-9][a-z0-9.\-]{1,61}[a-z0-9]$")
    14. MAX_RESULTS = 200
    15. _s3_client = boto3.client(
    16. "s3",
    17. endpoint_url=os.getenv("OBJECT_STORAGE_ENDPOINT") or None,
    18. )
    19. def query_object_storage(bucket_name: str, prefix: str = "") -> str:
    20. """List files in object storage."""
    21. if not BUCKET_PATTERN.match(bucket_name or ""):
    22. return "Invalid bucket name."
    23. if ".." in prefix or prefix.startswith("/"):
    24. return "Invalid prefix path."
    25. try:
    26. paginator = _s3_client.get_paginator("list_objects_v2")
    27. files = []
    28. for page in paginator.paginate(Bucket=bucket_name, Prefix=prefix):
    29. for obj in page.get("Contents", []):
    30. files.append(f"File name: {obj['Key']}, size: {obj['Size']} bytes")
    31. if len(files) >= MAX_RESULTS:
    32. break
    33. if len(files) >= MAX_RESULTS:
    34. break
    35. logger.info("List query succeeded bucket=%s prefix=%s count=%d",
    36. bucket_name, prefix, len(files))
    37. if not files:
    38. return "No matching files found."
    39. if len(files) >= MAX_RESULTS:
    40. files.append(f"(Results truncated to a maximum of {MAX_RESULTS} entries)")
    41. return "\n".join(files)
    42. except ClientError as e:
    43. code = e.response.get("Error", {}).get("Code", "Unknown")
    44. logger.error("List query denied or failed bucket=%s code=%s", bucket_name, code)
    45. return ("Query failed: you may not have permission to access this bucket, "
    46. "or the bucket does not exist. Please contact your administrator to check permissions.")
    47. except BotoCoreError:
    48. logger.exception("Object storage connection error")
    49. return "Query failed: unable to connect to object storage at the moment. Please try again later."

    The code uses a paginator because list_objects_v2 returns at most 1,000 objects per request. Setting an upper limit keeps the result from becoming too long and filling the model’s context window.

    5. Register the Plugin

    Registration methods differ between frameworks. File names and field names in the configuration depend on the framework you use, so refer to its documentation. The configuration below shows only the information that a registration needs to include.

    1. plugins:
    2. - name: query_object_storage
    3. module: plugins/object_storage.py
    4. function: query_object_storage
    5. schema: plugins/schemas/query_object_storage.json
    6. enabled: true
    7. timeout_seconds: 10

    After registration, confirm that the framework has loaded the plugin. Many frameworks list the names of loaded plugins in their startup logs.

    6. Write Tests

    Tests should use mock objects.