aibast-agents-library
Copilot instructions8 starsChanged 3 months agoMITView on GitHub
AIBAST Agents Library is the stable Microsoft downstream for the RAPP stack (see CONSTITUTION.md for architectural principles): The repository also owns agents/@aibast-agents-library/, registry.json, build_registry.py, rapp_ai/, the production guide, and Microsoft governance files. These are not upstream Grail mirrors. Read beta/GOLDEN_PATH.md before changing the beta. The beta is a chat-driven educational tool: users learn AI by watching GitHub Copilot build, hotload, run, test, explain, screenshot, and record real RAPP capabilities. External AIs can visibly drive the same Brainstem or Brain Surgeon…
- Reads credentials
In this repository8 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- rapp_ai/CLAUDE.mdCLAUDE.md
- rapp_brainstem/CLAUDE.mdCLAUDE.md
- community_rappSkill
- rapp-brainstemSkill
- aibast-easy-mode-brainstemSkill
- aibast-easy-mode-copilotSkill
- aibast-staging-ring-testSkill
The file
We split this copilot-instructions.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Read beta/GOLDEN_PATH.md before changing the beta.
- Very specific: line 45
Auto-pip-install: When loading an agent hits ModuleNotFoundError, _extract_package_name() maps import names to pip packages via _PIP_MAP …
- Distinctive: line 79
No linter or type-checker is configured.
- Very specific: line 148
Single-file server: All server logic lives in brainstem.py — auth, routing, LLM calls, agent orchestration.
- Very specific: line 152
Never overwrite AIBAST-owned content with Grail equivalents: agents/@aibast-agents-library/, registry.json, build_registry.py, rapp_ai/, …
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
Copilot Instructions — AIBAST Agents Library
Architecture
AIBAST Agents Library is the stable Microsoft downstream for the RAPP stack (see CONSTITUTION.md for architectural principles):
- Brainstem (
rapp_brainstem/) — The core. A local-first Flask server (Python 3.11) using GitHub Copilot's API for LLM inference. No API keys needed — justgh auth login. This is where all development happens. - Spinal Cord (
azuredeploy.json,deploy.sh) — Azure deployment. ARM template creates Function App, Azure OpenAI, Storage, App Insights. All Entra ID auth. - Nervous System (
MSFTAIBASMultiAgentCopilot_*.zip) — Power Platform solution for Copilot Studio. Connects the Azure Function to Teams and M365 Copilot.
The repository also owns agents/@aibast-agents-library/, registry.json, build_registry.py, rapp_ai/, the production guide, and Microsoft governance files. These are not upstream Grail mirrors.
Product Golden Path
Read beta/GOLDEN_PATH.md before changing the beta.
The beta is a chat-driven educational tool: users learn AI by watching GitHub
Copilot build, hotload, run, test, explain, screenshot, and record real RAPP
capabilities. External AIs can visibly drive the same Brainstem or Brain Surgeon
chat to keep users unstuck.
Preserve these invariants:
- unchanged Grail
brainstem.pyand exact RAPP/1 chat wire; - global + routed agents composed into isolated hardlinked
AGENTS_PATHworkers; - visible Explorer, Copilot Brain Surgeon, Brainstem execution, and evidence;
- VS Code/terminal remain optional expert surfaces;
- portable skills promote into Hippocampus and Microsoft downstream hosts without rewriting the agent or chat contract.
Brainstem internals
brainstem.py is the single-file server containing auth, agent orchestration, the tool-calling loop, and all HTTP endpoints.
Tool-calling loop (/chat, /chat/stream): Builds messages from soul + conversation history, then runs up to 3 rounds of LLM calls. Each round checks for tool_calls, executes matching agents via run_tool_calls(), appends tool results, and loops. The streaming route returns server-sent events and does not replay an accepted request after interruption.
Agent auto-discovery: load_agents() globs *_agent.py in AGENTS_PATH, dynamically imports each file, finds classes with a perform method (excluding BasicAgent itself), and instantiates them. Each agent's to_tool() generates its OpenAI function-calling schema.
Import shims: _register_shims() injects fake sys.modules so agents written for the cloud (CommunityRAPP) work locally:
utils.azure_file_storage→local_storage.AzureFileStorageManagerutils.dynamics_storage→ same local shim (aliased asDynamicsStorageManager)utils.storage_factory→ returns aLocalStorageManagerinstanceagents.basic_agent→ the localbasic_agent.py
Auto-pip-install: When loading an agent hits ModuleNotFoundError, _extract_package_name() maps import names to pip packages via _PIP_MAP (e.g., bs4 → beautifulsoup4, PIL → Pillow), auto-installs, and retries once.
Memory agents: ManageMemory and ContextMemory get special treatment — the LLM-invented user_guid arg is stripped before calling perform(). The /chat handler auto-injects <memory> context from ContextMemory into the system prompt if that agent is loaded.
Auth chain (in priority order):
GITHUB_TOKENenv var.copilot_tokenfile (JSON withaccess_token+refresh_token+saved_at)gh auth tokenCLI (skipsgho_tokens — they lack Copilot access)- Device code OAuth flow via
/loginendpoint
Copilot API tokens are exchanged from the GitHub token, cached in memory (with 60s expiry buffer) and on disk. A refresh_token flow allows automatic re-auth without user interaction.
Model compatibility: _NO_TOOL_CHOICE_MODELS auto-detects models with o1 in their ID — these don't support the tool_choice parameter. Claude models work but return multi-choice responses (text and tool_calls in separate choices); call_copilot() merges these into a single choice automatically.
Running & Testing
# Start the brainstem server (creates venv at ~/.brainstem/venv if needed)
cd rapp_brainstem && ./start.sh # port 7071
# Run all Brainstem tests
cd rapp_brainstem && python -m pytest tests -v
# Run a single test
python -m pytest tests/test_local_agents.py::TestLocalStorage::test_write_and_read -v
# Validate the AIBAST registry
python build_registry.py
python -m pytest tests -v
# Health check
curl -s localhost:7071/health | python3 -m json.toolNo linter or type-checker is configured.
API Endpoints
| Endpoint | Method | Purpose |
/ | GET | Serves index.html (chat UI) |
/chat | POST | {"user_input": "...", "conversation_history": [], "session_id": "..."} |
/chat/stream | POST | Server-sent events for streamed replies and agent activity |
/health | GET | Status, model, loaded agents, token state |
/login | POST | Start GitHub device code OAuth flow |
/login/poll | POST | Poll for completed device code auth |
/login/status | GET | Check current auth state |
/models | GET | List available models |
/models/set | POST | Change the active model |
/agents | GET | List agent files with loaded agent names |
/agents/import | POST | Upload an agent .py file |
/agents/export/<filename> | GET | Download an agent .py file |
/agents/<filename> | DELETE | Remove an agent .py file |
/voice | GET | Voice mode status |
/voice/toggle | POST | Toggle voice mode |
/voice/config | GET | Read voice config from encrypted voice.zip |
/voice/config | POST | Save voice config to encrypted voice.zip |
/voice/export | POST | Export voice.zip for download |
/voice/import | POST | Import voice.zip from upload |
/version | GET | Server version (reads VERSION file) |
/debug/auth | GET | Auth diagnostics |
/diagnostics/report | POST | Prepare a privacy-scrubbed GitHub issue draft |
Writing Agents
Agents extend BasicAgent (agents/basic_agent.py) with name, metadata (OpenAI function schema), and perform():
from agents.basic_agent import BasicAgent
class MyAgent(BasicAgent):
def __init__(self):
self.name = "MyAgent"
self.metadata = {
"name": self.name,
"description": "Description the LLM reads to decide when to call this.",
"parameters": {
"type": "object",
"properties": {"param1": {"type": "string", "description": "..."}},
"required": ["param1"]
}
}
super().__init__()
def perform(self, param1="", **kwargs):
return f"Result: {param1}"- File must be named
*_agent.pyin the agents directory (subdirectories likeexperimental/are not auto-discovered) perform()must accept**kwargs— the LLM may pass unexpected argsto_tool()onBasicAgentconvertsmetadatato OpenAI function-calling format- Agents importing
AzureFileStorageManagerget the local shim automatically - For storage, use
from utils.azure_file_storage import AzureFileStorageManager— the shim handles local vs cloud - Return a string from
perform()— this becomes the tool result the LLM sees
Key Conventions
- Python 3.11 target runtime; venv at
~/.brainstem/venv - No API keys for local dev — GitHub Copilot token exchange handles auth
- Config via
.env—GITHUB_TOKEN,GITHUB_MODEL(autoby default),SOUL_PATH,AGENTS_PATH,PORT,BRAINSTEM_LAN_MODE,BRAINSTEM_ALLOWED_HOSTS,VOICE_ZIP_PASSWORD(see.env.example) - Local-first storage:
local_storage.pystores to.brainstem_data/on disk, mirroring the CommunityRAPP Azure File Storage layout (shared_memories/memory.jsonfor shared,memory/{guid}/user_memory.jsonfor per-user) - Soul file (
soul.md): System prompt loaded as the first message in every conversation. Users customize by editing it or pointingSOUL_PATHto their own - Skill-based onboarding:
skill.mduses the Moltbook pattern — YAML frontmatter, autonomous execution steps, ⏸️ pause points for user input, state saved to~/.config/brainstem/state.json - Single-file server: All server logic lives in
brainstem.py— auth, routing, LLM calls, agent orchestration. Keep it that way.
Downstream Sync Safety
Never overwrite AIBAST-owned content with Grail equivalents: agents/@aibast-agents-library/, registry.json, build_registry.py, rapp_ai/, root README.md/index.html/CLAUDE.md, docs/index.html, docs/tutorial.html, docs/rapp-guide.html, .github/, legal/governance files, .vscode/, and tools/. Rewrite only Grail repository-identity URLs to microsoft/aibast-agents-library; review content-repository links such as CommunityRAPP individually.
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.

