A generic Backend for Agents (BFA) SDK with FAISS semantic routing.
Project description
Backend for Agents SDK (BFA) & IRC-A Protocol
A generic and opinionated framework and SDK to implement the BFA (Backend for Agents) pattern and the IRC-A (Internet Relay Chat for Agents) protocol, featuring native support for FAISS-based Semantic Routing (vector search), asymmetric zero-trust security boundaries, and standard abstractions for A2A Agents and MCP Servers.
Read the official protocol specification: 👉 IRC-A Protocol Whitepaper (v1.0.0) - Decentralized Agent Networks, Semantic Capability Routing, and Secure-by-Design Software Architecture.
Multilingual Documentation
BFA / IRC-A Protocol Architecture
The BFA Gateway acts as a semantic middleware and registry broker layer between consumers (e.g., messaging UIs, chat systems) and specialized agents/tools.
graph TD
Consumer["Consumer UI / Whatsapp / WebApp"] -->|1. Resolve Query| BFA[BFA Gateway]
subgraph BFA_Gateway ["BFA Gateway (Backend for Agents)"]
Router[Semantic Router] -->|2. Search Embeddings| FAISS[FAISS Vector Store]
Registry[Registry] -->|Load metadata| Router
end
BFA -->|3. Route & Invoke| Agent1["Cuentas Agent (A2A)"]
BFA -->|3. Route & Invoke| Agent2["Tarjetas Agent (A2A)"]
BFA -->|4. Execute Tool| MCP1["MDBank MCP (FastMCP)"]
Key Features
- FAISS-Based Semantic Routing: Instead of matching exact keywords (like BM25), the BFA Gateway indexes the descriptions, tags, and examples of agents and tools in a local FAISS vector index. This resolves queries to matching functions even when synonyms are used (e.g., matching "plastic" to "credit card").
BFAAgentAbstraction: Simplifies building A2A agents using thea2a-sdkand Starlette. Forces standard metadata declarations (tags,examples,description) required for semantic indexing.BFAMCPAbstraction: Wraps and extendsFastMCPservers. Automatically exposes a standardized/toolsendpoint returning input schemas, descriptions, and custom tags/examples for discovery.- Secure-by-Design IRC-A Security (Roadmap): Employs asymmetric challenge-response registration handshakes, logical channel masking (via container-level
IRCA_CHANNELSenv variables) to segregate vector search spaces, and Ephemeral DET (Delegated Execution Tokens) to enable direct decentralized P2P invocation without gateway bottlenecks. - Serverless (AWS Lambda) Ready: Includes a built-in Mangum adapter in the Gateway. Combined with the cloud-based
OpenAIEmbedder, the BFA Gateway runs serverless on demand with zero cold-starts.
Configuring Embedding Providers & Chunking
The BFA Gateway uses semantic embeddings to index agent/tool metadata in FAISS. You can choose between local models, cloud APIs, or offline mock routing via environment variables:
| Mode / Provider | Environment Variables | Dependencies | Description |
|---|---|---|---|
| Local Real (Default) | None | bfa-sdk[local] |
Uses sentence-transformers locally. Recommended for Python <= 3.12 environments. |
| OpenAI (Cloud) | BFA_USE_OPENAI_EMBEDDINGS=true, OPENAI_API_KEY="..." |
openai |
Queries OpenAI's text-embedding-3-small endpoint. Perfect for serverless/Lambda environments. |
| Offline Mock (Feature Hashing) | BFA_USE_MOCK_EMBEDDINGS=true |
None | Uses a stable MD5 feature hashing trick to route queries based on keywords. Zero dependencies, fast, and local. |
[!NOTE] Why is there no Chunking in the Gateway? The BFA Gateway is a semantic router of services, not a document retrieval engine (RAG). It indexes short microservice metadata cards (names, descriptions, tags, examples) which fit completely within embedding token limits. If you need to perform Document Chunking (RAG over PDFs/manuals), it should be implemented inside the respective A2A Agent's internal database/logic, keeping the Gateway lightweight and decoupled from document storage.
Installation
You can install the BFA SDK directly from GitHub using pip:
# Install the development version from the main branch
pip install git+https://github.com/SandroG1977/bfa-sdk.git
# Or install a specific version with the secure IRC-A protocol support
pip install git+https://github.com/SandroG1977/bfa-sdk.git@feature/docstrings-init
Running the Demo
2. Run the MDBank Demo
The demo launches three mock servers in the background:
- A mock MDBank MCP server (
examples/mock_mdbank_mcp.py) on port8001. - A mock Cuentas A2A Agent (
examples/mock_cuentas_agent.py) on port8002. - A mock Tarjetas A2A Agent (
examples/mock_tarjetas_agent.py) on port8003. - The BFA Gateway on port
8000, running dynamic discovery and performing test queries.
To run:
python examples/run_demo.py
3. Run the UI Dashboard (IRC-A Central Hub)
We have included a React-based UI Dashboard under examples/frontend to visually monitor the active agents/tools registry, register new microservices dynamically (plug-and-play), and chat with the routed banking agents:
# Navigate to the frontend folder
cd examples/frontend
# Install dependencies
npm install
# Start the development server
npm start
Open http://localhost:3000 to interact with your local agent hub in real-time.
Credits & Acknowledgements
This SDK is a community-driven implementation and expansion of the BFA (Backend for Agents) architectural pattern originally designed and documented by Michael Douglas Barbosa Araujo (Staff AI Architect).
You can read his original article introducing the pattern here: 👉 O padrão Back-end para Agentes (BFA) - Medium
The goal of this project is to provide a standardized, packaged SDK extending his original concept with semantic vector routing (FAISS) and unified base adapters. All credit for the underlying protocol and architectural vision belongs to him.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bfa_irc_a_sdk-0.1.0.tar.gz.
File metadata
- Download URL: bfa_irc_a_sdk-0.1.0.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f53fd03771f78b7d6918589296e34ea3a0e4f7abce3023110f71a02fd587701
|
|
| MD5 |
03d1356b9029b42ababf801c1b3c60e2
|
|
| BLAKE2b-256 |
bb0890912d0ea01990f3308aacbee8407e14266bfc56c47d3717faef833298bd
|
Provenance
The following attestation bundles were made for bfa_irc_a_sdk-0.1.0.tar.gz:
Publisher:
publish.yml on SandroG1977/bfa-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bfa_irc_a_sdk-0.1.0.tar.gz -
Subject digest:
0f53fd03771f78b7d6918589296e34ea3a0e4f7abce3023110f71a02fd587701 - Sigstore transparency entry: 2166786560
- Sigstore integration time:
-
Permalink:
SandroG1977/bfa-sdk@06312464da457d4ac4befeab0c266e3b718eca60 -
Branch / Tag:
refs/tags/IRC-A-v.0.1.1.b1 - Owner: https://github.com/SandroG1977
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06312464da457d4ac4befeab0c266e3b718eca60 -
Trigger Event:
release
-
Statement type:
File details
Details for the file bfa_irc_a_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bfa_irc_a_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
229741bbf2b6ed329fd437ed75e5a5127c27174af0ff5771de1d8546eae6ffa7
|
|
| MD5 |
bd82e3f622ec7fd4e95b9c7e16f4e1ff
|
|
| BLAKE2b-256 |
335357bdf32d90fbd3443ff514fcf021805343a8bf30000b0b9f8829eacac4c3
|
Provenance
The following attestation bundles were made for bfa_irc_a_sdk-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on SandroG1977/bfa-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bfa_irc_a_sdk-0.1.0-py3-none-any.whl -
Subject digest:
229741bbf2b6ed329fd437ed75e5a5127c27174af0ff5771de1d8546eae6ffa7 - Sigstore transparency entry: 2166786571
- Sigstore integration time:
-
Permalink:
SandroG1977/bfa-sdk@06312464da457d4ac4befeab0c266e3b718eca60 -
Branch / Tag:
refs/tags/IRC-A-v.0.1.1.b1 - Owner: https://github.com/SandroG1977
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06312464da457d4ac4befeab0c266e3b718eca60 -
Trigger Event:
release
-
Statement type: