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
- Create a new directory as your project root.
- Navigate to the project root and run
This initializes a new
uv init
uv venvuv
project and creates a virtual environment. Theuv
tool will also create apyproject.toml
file in the project root, which is used to manage dependencies and project metadata. To add dependencies, you can use:For example, to adduv add <package_name>
br_rapp_sdk
, you would run:The command will automatically update theuv add br_rapp_sdk
pyproject.toml
file with the new dependency. To synchronize the virtual environment with thepyproject.toml
file, you can run:uv sync
- Create a
__init__.py
and a__main__.py
file in the project root, as for any Python package. - Create a
src/
directory to hold all your source code. Optionally, you can create atests/
directory for your tests. - 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. - Create a
.env
file in the project root to specify important environment variables like the model provider, model name, API key, and other configurations. - 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.