aibast-agents-library / project
CLAUDE.md8 starsChanged 3 months agoMITView on GitHub
Read CONSTITUTION.md first. It defines what belongs in this repo and what doesn't. CommunityRAPP is a base memory agent platform built on Azure Functions with Azure OpenAI integration. Think of it as a "brainstem" — a minimal, extensible runtime that gives any AI agent persistent memory across conversations. The platform provides: - Two built-in agents: ContextMemory (read) and ManageMemory (write) - Dual-layer memory: shared (all users) + user-specific (per GUID) - Five HTTP endpoints, including grail-compatible and legacy conversation routes…
- Reads credentials
- Installs packages
- Sends data out
In this repository539 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- rapp_ai/CLAUDE.mdCLAUDE.md
- rapp_brainstem/CLAUDE.mdCLAUDE.md
- community_rapp/project/.github/copilot-instructions.mdCopilot instructions
- .github/copilot-instructions.mdCopilot instructions
- rapp_ai/.github/copilot-instructions.mdCopilot instructions
- docs/vault/llms-full.txtllms.txt
- docs/vault/llms.txtllms.txt
- csv-surgeonSkill
- json-doctorSkill
- log-detectiveSkill
- markdown-medicSkill
- pii-scoutSkill
- generate-demoSkill
- community_rappSkill
- generate-demoSkill
- rapp-brainstemSkill
- aibast-easy-mode-brainstemSkill
- aibast-easy-mode-copilotSkill
- aibast-staging-ring-testSkill
- account-intelligence-account-overviewSkill
- account-intelligence-competitive-intelSkill
- account-intelligence-executive-briefingSkill
- account-intelligence-risk-assessmentSkill
- account-intelligence-stakeholder-mapSkill
- account-intelligence-value-messagingSkill
- escalation-routingSkill
- follow-up-planSkill
- handle-inquirySkill
- interaction-summarySkill
- knowledge-searchSkill
- prepare-actionsSkill
- recommend-resolutionSkill
- satisfaction-surveySkill
- benefits-summarySkill
- health-insuranceSkill
- leave-balanceSkill
- parental-leaveSkill
- remindersSkill
- remote-workSkill
- submit-time-offSkill
- time-off-checkSkill
- asset-maintenance-forecast-asset-healthSkill
- asset-maintenance-forecast-budget-projectionSkill
- asset-maintenance-forecast-maintenance-forecastSkill
- asset-maintenance-forecast-work-order-planSkill
- compare-plansSkill
- deadline-remindersSkill
- document-checklistSkill
- election-draftSkill
- enrollment-windowSkill
- life-event-changeSkill
- provider-networkSkill
- approval-routeSkill
- content-scanSkill
- draft-briefSkill
- figure-checkSkill
- gap-reportSkill
- list-templatesSkill
- proactive-applicant-updatesSkill
- The first 60 shown.
The file
We split this CLAUDE.md into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 53
Azure auth: Run az login for local development with cloud storage
- Very specific: line 89
Guiding principle: Start small, layer up when ready.
- Very specific: line 128
Create Assistant with user GUID (from request body, prompt, or default)
- Distinctive: line 130
Call Azure OpenAI with agent function definitions
- Distinctive: line 131
If tool called → execute agent → feed result back → get final response
- Distinctive: line 140
If no delimiter present, voice response is auto-generated from first sentence
- Very specific: line 188
Create a new file in agents/ (e.g., my_agent.py):
- Very specific: line 221
Use the Copilot deploy skill (.github/copilot/skills/deploy-to-azure.md) or deploy manually:
- Very specific: line 233
Use --build remote, never --build local (avoids macOS binary issues like jiter)
- Distinctive: line 234
After deploy, sync triggers if functions don't appear
- Distinctive: line 247
Import the resulting ZIP into Power Platform at make.powerapps.com → Solutions → Import.
- Very specific: line 253
Response format: must include |||VOICE||| delimiter for proper voice/formatted splitting
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Governance
Read CONSTITUTION.md first. It defines what belongs in this repo and what doesn't.
Project Overview
CommunityRAPP is a base memory agent platform built on Azure Functions with Azure OpenAI integration. Think of it as a "brainstem" — a minimal, extensible runtime that gives any AI agent persistent memory across conversations.
The platform provides:
- Two built-in agents: ContextMemory (read) and ManageMemory (write)
- Dual-layer memory: shared (all users) + user-specific (per GUID)
- Five HTTP endpoints, including grail-compatible and legacy conversation routes
- A pattern for adding custom agents by dropping files into
agents/
Disclaimer: This is an experimental research project managed by a v-team, not an officially supported Microsoft product. The Copilot Studio YAML schema may change without notice. Always review and validate generated output before pushing to your environment — AI-generated output may contain errors or unsupported patterns.
Development Commands
Running Locally
# Activate virtual environment
source .venv/bin/activate
# Start the function app
func startThe local endpoints will be available at:
http://localhost:7071/api/health— Health checkhttp://localhost:7071/api/version— Runtime versionhttp://localhost:7071/api/chat— Grail-compatible conversationhttp://localhost:7071/api/businessinsightbot_function— Main conversationhttp://localhost:7071/api/trigger/copilot-studio— Copilot Studio direct invocation
Testing the API
curl -X POST http://localhost:7071/api/businessinsightbot_function \
-H "Content-Type: application/json" \
-d '{"user_input": "Hello", "conversation_history": []}'Environment Setup
- Python 3.11 required (3.13+ breaks Azure Functions v4)
- Dependencies:
pip install -r requirements.txt - Configuration: Copy
local.settings.template.jsontolocal.settings.jsonand fill in values - Azure auth: Run
az loginfor local development with cloud storage
Running Tests
# Run all unit tests (mocked, no API keys needed)
python -m pytest tests -q
# Compare Tier 2 with the unchanged reference Brainstem. Check out rapp-1
# at the commit in grail-suite.json and the Grail at that suite's kernel pin.
PYTHONPATH="$PWD/tests" \
GRAIL_DIR=/path/to/rapp-installer/rapp_brainstem \
python /path/to/rapp-1/conformance/grail/run.py \
--candidate module:grail_adapter:create_candidateArchitecture
The Brainstem Concept
This platform is the foundational layer — the "brainstem" — that other agent systems build on. It handles:
- Memory persistence — storing and recalling facts, preferences, insights, and tasks
- User isolation — separate memory contexts per user GUID
- Agent orchestration — OpenAI function calling to route to the right agent
- Response formatting — dual output (markdown + voice) via
|||VOICE|||delimiter
The Hatchery Pattern (T1 → T2/T3 Bridge)
The RAPP Brainstem (T1, rapp-installer) is the local on-device AI. CommunityRAPP is the customer's cloud instance (T2/T3). The hatchery agent bridges them:
hatchery/rapp_hatchery_agent.py— Self-contained agent (stdlib only, no Azure SDK) hosted here for distribution, runs in the brainstemhatch.sh/hatch.ps1— One-liner scripts that download the hatchery agent into the brainstem'sagents/folderdocs/BRAINSTEM_GUIDANCE.md— What to add to the brainstem'ssoul.md
Hatched projects live at ~/rapp-projects/{name}/ with their own venvs and ports (7072+). The brainstem stays on 7071. Projects are tracked in ~/rapp-projects/.hatchery.json.
Guiding principle: Start small, layer up when ready. See CONSTITUTION.md Article XIII.
HTTP Endpoints
| Route | Auth | Methods | Purpose |
/api/health | Anonymous | GET | Health check (supports ?deep=true) |
/api/version | Anonymous | GET | Runtime version |
/api/chat | Function key | POST | Grail-compatible conversation endpoint |
/api/businessinsightbot_function | Function key | POST/OPTIONS | Main conversation endpoint |
/api/trigger/copilot-studio | Function key | POST | Direct agent invocation from Copilot Studio |
Core Components
function_app.py — Main entry point:
Assistantclass orchestrates conversations with OpenAI- Singleton caches: OpenAI client (30-min TTL), agent cache (5-min TTL)
- GUID-based user context with default:
c0p110t0-aaaa-bbbb-cccc-123456789abc - Supports both tools API (gpt-4o) and legacy functions API (gpt-4-turbo)
- Retry logic (max 3 attempts, 2s delay) for OpenAI calls
agents/ — Agent implementations:
basic_agent.py— Base class withname,metadata,perform(**kwargs)context_memory_agent.py— ContextMemory: Recalls stored memories with keyword filtering, pagination, full recall modemanage_memory_agent.py— ManageMemory: Stores memories with type (fact/preference/insight/task), importance (1-5), tags
utils/ — Platform utilities:
storage_factory.py— Singleton factory with 30-min TTL; returns Azure or Local storage managerazure_file_storage.py—AzureFileStorageManagerusing Entra ID (ChainedTokenCredential)local_file_storage.py—LocalFileStorageManagerusing.local_storage/directoryenvironment.py— Detection helpers:is_running_in_azure(),should_use_azure_storage()result.py—Result/Success/Failuretypes withAgentLoadErrorandAPIErroragent_manager.py— Singleton agent registry withdiscover_agents()auto-loadinggenerate_memory_agent_solution.py— Generates Power Platform solution ZIPs for Copilot Studio
Request Flow
- HTTP POST → endpoint with
{ user_input, conversation_history, user_guid? } - Load agents from local
agents/folder (cached 5 min) - Create
Assistantwith user GUID (from request body, prompt, or default) - Initialize memory contexts (shared + user-specific)
- Call Azure OpenAI with agent function definitions
- If tool called → execute agent → feed result back → get final response
- Parse response at
|||VOICE|||delimiter into formatted + voice parts - Return:
{ assistant_response, voice_response, agent_logs, user_guid }
Response Format
Responses use the |||VOICE||| delimiter:
- Before delimiter: Full markdown-formatted response (headings, code blocks, lists)
- After delimiter: 1-2 sentence conversational summary for speech synthesis
- If no delimiter present, voice response is auto-generated from first sentence
Memory Storage Layout
Shared Memory (all users): {storage}/shared_memories/memory.json
User-Specific Memory: {storage}/{user_guid}/memory.jsonWhere {storage} is Azure File Share (cloud) or .local_storage/ (local dev).
Key Design Patterns
- String safety:
ensure_string_content()andensure_string_function_args()sanitize all values - CORS:
build_cors_response()adds headers to every response; OPTIONS preflight supported - Graceful degradation: Agent load failures are logged but don't crash; memory init failures handled
- Intentionally invalid default GUID:
c0p110t0-aaaa-bbbb-cccc-123456789abccontains non-hex chars ('p','l') — this is a security feature that prevents accidental DB insertion in UUID columns
Configuration
Environment Variables (local.settings.json)
See local.settings.template.json for the full template. Key variables:
| Variable | Purpose |
AZURE_OPENAI_ENDPOINT | Azure OpenAI endpoint URL |
AZURE_OPENAI_DEPLOYMENT_NAME | Model deployment (e.g., gpt-4o) |
AZURE_OPENAI_API_VERSION | API version (e.g., 2024-08-01-preview) |
AZURE_OPENAI_API_KEY | API key (optional if using Entra ID) |
ASSISTANT_NAME | Bot display name |
CHARACTERISTIC_DESCRIPTION | Bot personality description |
USE_CLOUD_STORAGE | true for Azure File Storage, false for local |
USE_IDENTITY_BASED_STORAGE | true for Entra ID auth to storage |
AzureWebJobsStorage | Azure Storage connection string |
Authentication
Uses Entra ID (token-based) authentication:
ChainedTokenCredential: ManagedIdentity (Azure) → AzureCliCredential (local)- Required RBAC roles on Function App's managed identity:
- Storage:
Storage Blob Data Contributor,Storage File Data Privileged Contributor - OpenAI:
Cognitive Services OpenAI User
- Storage:
For local dev: az login is required.
Adding Custom Agents
Create a new file in agents/ (e.g., my_agent.py):
from agents.basic_agent import BasicAgent
class MyAgent(BasicAgent):
def __init__(self):
self.name = 'MyAgent'
self.metadata = {
"name": self.name,
"description": "What this agent does",
"parameters": {
"type": "object",
"properties": {
"input": {
"type": "string",
"description": "Input parameter"
}
},
"required": ["input"]
}
}
super().__init__(self.name, self.metadata)
def perform(self, **kwargs):
input_data = kwargs.get('input', '')
return f"Processed: {input_data}"Agents are auto-discovered on startup. Files matching *_agent.py in agents/ are loaded.
Deploy to Azure
Use the Copilot deploy skill (.github/copilot/skills/deploy-to-azure.md) or deploy manually:
# ARM template provisions: Function App, OpenAI, Storage, App Insights
az deployment group create --resource-group YOUR_RG --template-file azuredeploy.json
# Deploy code (MUST use --build remote for Linux compatibility)
func azure functionapp publish YOUR_FUNCTION_APP --build remoteKey deployment notes:
- Storage
publicNetworkAccessmust stay enabled (Flex Consumption requires it) - Use
--build remote, never--build local(avoids macOS binary issues likejiter) - After deploy, sync triggers if functions don't appear
Deploy to Copilot Studio
Generate a Power Platform solution ZIP to connect this platform to Teams/M365 Copilot:
python utils/generate_memory_agent_solution.py \
--function-url https://YOUR_APP.azurewebsites.net \
--function-key YOUR_FUNCTION_KEY \
--output CommunityRAPPMemoryAgent_1_0_0_0.zipImport the resulting ZIP into Power Platform at make.powerapps.com → Solutions → Import.
Important Notes
- Never commit
local.settings.json— contains secrets; use the template - Python 3.11 required — 3.13+ breaks Azure Functions v4
- Response format must include
|||VOICE|||delimiter for proper voice/formatted splitting - Default GUID is intentionally invalid — security guardrail, not a bug
- Memory trimming — conversation history limited to last 20 messages
- Singleton TTLs — OpenAI client: 30 min, agent cache: 5 min, storage manager: 30 min
- Tests are fully mocked — no API keys or Azure access needed to run the test suite
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

