Skip to main content

Agents

Building a Domain-Specific Agent

Prerequisites

  • Python 3.12 or higher (3.12.3 recommended).
  • BR rApp SDK installed.
  • Basic LangGraph knowledge.
  • Recommended: use uv as a virtual environment and package manager.

Codebase Setup

  1. Create a new directory as your project root.
  2. Navigate to the project root and run
    uv init
    uv venv
    This initializes a new uv project and creates a virtual environment. The uv tool will also create a pyproject.toml file in the project root, which is used to manage dependencies and project metadata. To add dependencies, you can use:
    uv add <package_name>
    For example, to add br_rapp_sdk, you would run:
    uv add br_rapp_sdk
    The command will automatically update the pyproject.toml file with the new dependency. To synchronize the virtual environment with the pyproject.toml file, you can run:
    uv sync
  3. Create a __init__.py and a __main__.py file in the project root, as for any Python package.
  4. Create a src/ directory to hold all your source code. Optionally, you can create a tests/ directory for your tests.
  5. Create a agent.json file in the project root. This file will contain the AgentCard for your agent. The AgentCard is a JSON file that describes the agent's capabilities, inputs, outputs, and other metadata.
  6. Create a .env file in the project root to specify important environment variables like the model provider, model name, API key, and other configurations.
  7. Create a src/llm_clients/ directory to hold your LLM client implementations. This is where you will define how your agent interacts with the language model (in terms of prompts, response handling, etc.).

At this point, your project structure should look like this:

my_agent/
├── agent.json
├── .env
├── __init__.py
├── __main__.py
├── pyproject.toml
├── README.md
├── src/
│   ├── graph.py
│   ├── __init__.py
│   └── llm_clients/
│   ├── __init__.py
│   └── tutorial_client.py
└── tests/
│ ├── __init__.py
│ └── tutorial_test.py
├── uv.lock
└── .venv/

Implementing the Agent

Follow Lab 13: Tutorial Agent for more details on how to implement your custom agents. The tutorial provides details on how to:

  • Build a task-specific agent using the BR rApp SDK.
  • Define the AgentCard in agent.json.
  • Implement the agent's logic in the src/graph.py file.
  • Integrate your custom agent into the MX-AI ecosystem.