A comprehensive AI platform for building enterprise-grade conversational AI systems with multi-agent orchestration, knowledge retrieval, and extensive integration capabilities.
Table of Contents
- Core Architecture
- Agno Agentic Framework
- API Services
- AI Models
- Data Processing Pipelines
- MCP (Model Context Protocol)
- Agent Frameworks
- Core Python Libraries
- Output Schemas
- Custom Agent Tools
- Persona System
- Testing & Quality
- Infrastructure & Deployment
- Summary
1. Core Architecture
Mono-repo Microservices Architecture
| Feature |
Description |
| Pantsbuild |
Build management, testing, and packaging |
| Poetry |
Python dependency management |
| Docker |
Containerization support |
| Centralized Dependencies |
Shared libraries with unified resolution |
| Service Independence |
Individual microservice lifecycle management |
Directory Structure
src/
├── agent/ # Agent framework implementations
├── apis/ # REST API services
├── mcp/ # Model Context Protocol servers
├── models/ # AI conversation models
├── pipelines/ # Data processing pipelines
├── python/ # Core Python libraries
└── scripts/ # Utility scripts
2. Agno Agentic Framework Integration
Location: src/python/agno/
Factory System
| Factory |
Purpose |
AgnoAgentFactory |
Create agents from JSON configurations or templates |
AgnoTeamFactory |
Create multi-agent teams for autonomous coordination |
AgnoWorkflowFactory |
Create deterministic workflows with sequential/conditional steps |
Agent Configuration Types
Core Agents
basic_agent_config - Standard helpful assistant
minimal_agent_config - Minimal configuration
verbose_agent_config - Detailed explanations
memory_disabled_agent_config - No memory persistence
greeting_agent_config - Welcome/greeting responses
end_conversation_agent_config - Polite conversation endings
early_exit_agent_config - Quick exit decision detection
Specialized Agents
| Type |
Description |
| Memory Agents |
Full memory capabilities (create/update/delete) |
| Session-Aware Agents |
Multi-turn conversations with history |
| Knowledge (RAG) Agents |
Domain-specific knowledge bases with search |
| Tool-Enabled Agents |
External API/web search integration |
| Reasoning Agents |
Step-by-step thinking (light, standard, deep) |
| Context Engineering |
Datetime, location, name awareness |
| Hooks & Guardrails |
Pre/post execution hooks, safety guardrails |
Memory & Storage
# Memory Resources
AgnoMemoryResources # Memory manager integration
AgnoMongoDBResources # Separate databases for agents and workflows
Capabilities:
- Agentic Memory: Create, update, delete memories
- User Memories: User-specific memory persistence
- Session Summaries: Automatic session summarization
Knowledge/RAG Capabilities
| Component |
Description |
BastRetrieverMongo |
Hybrid search (text + vector similarity) |
BastJSONReader |
Enhanced JSON document reader with chunking |
Search Modes:
- Text-only search
- Vector-only search
- Hybrid search (combined)
Features:
- Entity filtering by categories
- Score normalization across methods
- MongoDB Atlas integration
- Embedding caching for performance
Workflow System
# Workflow example
workflow = factory.create_workflow_from_json({
"name": "content_workflow",
"steps": [
{"agent": {"name": "researcher", "instructions": [...]}},
{"agent": {"name": "writer", "instructions": [...]}}
]
})
response = workflow.run(input="Your query", stream=False)
Features:
- Sequential agent execution
- Conditional routing (early exit workflows)
- Support for agents, teams, and custom functions as steps
- Separate workflow storage database
3. API Services
Location: src/apis/
CAT API (Chat/Conversation)
| Endpoint |
Description |
/api/v1/cat/chat |
Unified chat with dynamic routing (legacy/agno) |
/api/v1/cat/agno_chat |
Agno agent-based chat |
/api/v1/cat/legacy_chat |
Multi-model legacy chat |
/api/v1/cat/conversations |
Conversation management (list, history, delete, rename, search) |
/api/v1/cat/config |
Configuration synchronization |
Response Format:
{
"service": "AnswerUsingAgnoAgent",
"event": "agno_chat",
"ts": 1699123456.789,
"stopwatch": "5.23",
"data": {
"output_text": "Response text here",
"references": ["chunk_id_1", "chunk_id_2"],
"reasoning": ["reasoning_step_1", "reasoning_step_2"],
"agent_name": "research_agent"
}
}
Security API
| Feature |
Description |
| JWT Authentication |
Stateless token-based auth |
| Role-Based Access |
Granular permission system |
| Session Management |
User session handling |
| User Registration |
Account creation flow |
| Password Management |
Forgot/reset password |
| Email Verification |
Account verification |
| Profile Management |
User profile CRUD |
Analytics API
- Chat categorization
- Persona assignment
- ETL pipeline integration (Extract, Transform, Load) (in progress)
- Topic classification
Additional APIs
| API |
Purpose |
| Feedback API |
User feedback collection and analysis |
| Ontology API |
Knowledge graph management (CRUD, queries) |
| Parse API |
Data parsing and transformation |
| Status API |
Health checks and status endpoints |
| User Management API |
User administration |
4. AI Models
Location: src/models/
Conversation Models
| Model |
Purpose |
| Chitchat Model |
Casual conversation, journal prompts, random questions |
| Greeting Model |
Welcome/greeting messages |
| End Conversation Model |
Polite conversation endings |
| Early Exit Model |
Quick exit decision detection |
| Empty Model |
Handle empty input |
Intelligence Models
| Model |
Purpose |
| Intent Model |
Intent recognition and classification |
| QA Model |
Question-answering systems |
| Context Model |
Context-aware responses |
| Nothing Found Model |
Graceful fallback responses |
| Default Model |
Default response handling |
Integration Models
| Model |
Purpose |
| OpenAI Assistant Model |
OpenAI Assistants API integration |
| OurEliza Model |
Eliza-style pattern matching |
| Command Model |
Bot command processing |
5. Data Processing Pipelines
Location: src/pipelines/
Document Processing
| Pipeline |
Capabilities |
| PDF Pipeline |
Document extraction, OCR, text processing, chunking |
| Excel Pipeline |
Spreadsheet processing and transformation |
| Web Extract Pipeline |
Web scraping and content extraction |
Database Pipelines
| Pipeline |
Database |
| MongoDB Pipeline |
Document database operations |
| MSSQL Pipeline |
SQL Server integration |
| Milvus Pipeline |
Vector database operations |
AI Processing Pipelines
| Pipeline |
Purpose |
| OpenAI Pipeline |
Content generation, embeddings |
| Azure Index Pipeline |
Azure Search index management |
| Bedrock Pipeline |
AWS Bedrock multi-model integration |
| Agno Pipeline |
Knowledge base processing for Agno agents |
Specialized Pipelines
| Pipeline |
Domain |
| Intent Pipeline |
Intent data loading and processing |
| Annotation Pipeline |
Data annotation workflows |
| First Aid Pipeline |
Medical/first aid data processing |
| Initialization Pipeline |
System setup and initialization |
6. MCP (Model Context Protocol)
Location: src/mcp/
| Service |
Description |
| MCP Base |
Abstract service foundation |
| MCP MongoDB |
MongoDB MCP server for AI model access |
| MCP Ontology |
Ontology/knowledge graph MCP server |
7. Agent Frameworks
Location: src/agent/
| Agent Type |
Description |
| OpenAI Agent |
OpenAI API integration |
| Pydantic Agent |
Structured output agents with validation |
| Smol Agent |
Lightweight agent implementation |
| Base Agent |
Abstract agent foundation |
8. Core Python Libraries
Location: src/python/
Base Library (bast_ai.base)
| Component |
Purpose |
BastObject |
Base class for all services |
BastAbstractObject |
Abstract base with lifecycle management |
ObjectEnforcer |
Runtime type validation |
Stopwatch |
Performance timing measurement |
IdealWrapper |
Exception handling wrapper |
Utilities (bast_ai.utils)
| Utility |
Purpose |
FileIO |
JSON, YAML, CSV, text file operations |
TextUtils |
Text processing, NLP operations, cleaning |
EnvIO |
Type-safe environment variable access |
TextMatcher |
Fuzzy text matching |
TimeHelper |
Date/time operations |
Security (bast_ai.crypt)
- Encryption/decryption (AES)
- Password hashing and validation
- Secure key management
Database Connectors
| Library |
Database |
bast_ai_mongo |
MongoDB with Atlas support |
bast_ai_mssql |
SQL Server |
bast_ai_neo4j |
Neo4j graph database |
bast_ai_oracle |
Oracle database |
bast_ai_milvus |
Milvus vector database |
AI/ML Libraries
| Library |
Purpose |
bast_ai_openai |
OpenAI API integration |
bast_ai_azure_index |
Azure Search integration |
bast_ai_llm_evaluation |
Model evaluation tools |
bast_ai_graphrag |
Graph-based RAG |
bast_ai_cot_generation |
Chain of Thought generation |
Classification (bast_ai_classifier)
| Classifier |
Purpose |
| Entity Classifier |
Named entity classification |
| Schema Classifier |
Mapping rule classification |
| Sentence Classifier |
Question type classification (what, where, when, how) |
| Intent Classifier |
Intent resolution |
NLP Processing
| Library |
Purpose |
bast_ai_tokenizer |
Text tokenization |
bast_ai_spacy_token_parser |
SpaCy integration |
bast_ai_segmenter |
Text segmentation |
bast_ai_timeparser |
Temporal expression parsing |
bast_ai_htmlparser |
HTML content extraction |
Ontology Management
| Library |
Purpose |
bast_ai_buildowl |
OWL ontology construction |
bast_ai_parseowl |
OWL ontology parsing |
Cloud Integrations
| Library |
Services |
bast_ai_aws |
S3, AWS services |
bast_ai_dvc |
Data Version Control |
bast_ai_msgraph |
Microsoft Graph API |
bast_ai_email |
Email services (Azure) |
Communication
| Library |
Platform |
bast_ai_slack |
Slack bot integration |
bast_ai_rest |
REST client utilities |
Configuration
| Library |
Purpose |
bast_ai_config |
Centralized configuration management |
Features:
- Encrypted YAML configuration files
- Environment-specific settings
- CAT (Conversational AI Template) configurations
9. Output Schemas & Structured Responses
Pydantic Output Schemas
| Schema |
Purpose |
EarlyExitDecision |
Early exit decision output (action + reason) |
InputClassificationOutput |
Input classification results |
AgentOutputStruct |
Structured agent responses |
Example:
class EarlyExitDecision(BaseModel):
action: Literal["HARD_EXIT", "SOFT_EXIT", "KEEP_GOING"]
reason: str # e.g., "EMPTY_INPUT", "HAS_ENDING_PHRASE", "NO_EXIT"
| Tool |
Purpose |
ToolIdentifier |
Identify tool usage patterns |
ToolParseInputText |
Input text parsing and preprocessing |
ToolOntologyAccess |
Ontology/knowledge graph queries |
ToolExtractUserChatIds |
Extract chat identifiers |
BastReferenceExtractor |
Knowledge reference extraction |
11. Persona System
Location: dto/prompts/personas/
| Persona |
Domain |
DefaultPersona |
Base persona configuration |
BastPersona |
Bast AI specific persona |
CraigHospitalPersona |
Healthcare/hospital domain |
MSUPersona |
University/education domain |
Components:
- Persona configuration
- Formatting rules
- Response guidelines
12. Testing & Quality
Testing Framework
| Type |
Tool |
| Unit Tests |
Pants test runner |
| Integration Tests |
Standalone test files |
| Coverage Reports |
pytest-cov |
| Type Checking |
MyPy |
| Code Formatting |
Black |
Running Tests
# Run all tests
make test
# Run tests for specific service
pants test --output=all src/python/base:: -- -s --no-header
# Run with coverage
pants test --output=all --use-coverage --coverage-py-filter="['bast_ai.base']" src/python/base::
# Run integration test
pants run src/python/agno/integration/add_knowledge.py
13. Infrastructure & Deployment
Build System
| Tool |
Purpose |
| Pantsbuild |
Mono-repo management |
| Poetry |
Dependency management |
| Custom Scripts |
Service creation, versioning |
CI/CD
- Bitbucket Pipelines
- Automated testing and deployment
- Package publishing to private PyPI server
Containerization
| Technology |
Purpose |
| Docker |
Container deployment |
| Terraform |
Infrastructure as Code |
Configuration Management
# Example CAT configuration
config:
chat_mode: "agno"
default_agno_agent: "research_agent"
agno_agents:
research_agent:
config:
instructions:
- "You are a helpful research assistant"
search_knowledge: true
model_id: "gpt-4o"
enabled: true
knowledge_base: "research_kb"
14. Summary
Component Counts
| Category |
Count |
Key Components |
| API Services |
9 |
CAT, Security, Analytics, Feedback, Ontology, Parse, Status, User Management, Base |
| AI Models |
13 |
Chitchat, Intent, QA, Context, Greeting, Early Exit, OpenAI Assistant, etc. |
| Pipelines |
15 |
PDF, MongoDB, OpenAI, Milvus, Bedrock, Azure Index, etc. |
| Core Libraries |
30+ |
Base, Config, Crypto, OpenAI, Mongo, Neo4j, Classifier, etc. |
| Agent Types |
4 |
OpenAI, Pydantic, Smol, Base |
| MCP Services |
3 |
Base, MongoDB, Ontology |
| Agno Configs |
15+ |
Core, Memory, Session, Knowledge, Tools, Reasoning, etc. |
Key Capabilities
✅ Multi-Agent Orchestration - Teams and workflows with conditional routing
✅ Knowledge Retrieval (RAG) - Hybrid search with vector and text
✅ Memory Persistence - User and session memory management
✅ Multiple Database Backends - MongoDB, SQL Server, Neo4j, Oracle, Milvus
✅ Enterprise Security - JWT auth, RBAC, encryption
✅ Cloud Integrations - AWS, Azure, OpenAI, Slack
✅ NLP Processing - Classification, tokenization, entity extraction
✅ Ontology Support - OWL-based knowledge graphs
✅ ETL Pipelines - Document processing, data transformation
✅ MCP Protocol - Model Context Protocol servers
Quick Start
Creating an Agent
from bast_ai_agno.bp import AgnoAgentFactory, AgnoMongoDBResources, AgnoModelResources
from bast_ai_agno.dto.agent_configs import basic_agent_config
# Initialize resources
factory = AgnoAgentFactory("my_cat")
storage = AgnoMongoDBResources("my_cat").get_agent_storage("my_agent")
model = AgnoModelResources("my_cat").get_open_ai_chat("gpt-4o-mini")
# Create agent
agent = factory.create_openai_chat_agent(
name="my_agent",
model=model,
db=storage,
config_raw=basic_agent_config
)
# Run agent
response = agent.run("Hello, how can you help me?")
print(response.content)
Running the API
# Run CAT API server
pants run src/apis/cat/integration/api_tester.py -- --catname mycat
# Test endpoint
curl "http://localhost:9090/api/v1/cat/chat?chat_text=Hello&user_id=user123"
Documentation
Last Updated: June 2026
Maintained by: Bast AI Development Team