
Extending the System
this ainât some closed-source black hole. brainz is built to be ripped apart, modded, and pushed way past what we ship by default. every pieceâmemory, agents, inference, analyticsâis plug-and-play. you want custom logic? drop it in. you want to fork it? go wild.
build your own agent
agents are autonomous workers that watch, score, rewrite, or retrain the modelâbasically, your own little ops crew running 24/7.
how to drop one in:
# backend/agents/my_custom_agent.py
class MyCustomAgent:
def run(self, prompt: str, response: str) -> dict:
# do whatever â scoring, rewriting, tagging
return {
"log": "custom logic executed",
"action": "flagged",
"status": "ok"
}
register it in
core/registry.py
trigger via:
cli â
python cli/agent_runner.py
api â
/api/agent/trigger
other agents (chain âem up, if youâre crazy enough)
agents get full access to: â memory (vectors + tags) â logs â full prompt lifecycle + outputs
swap or extend your model
quick swap:
# .env
MODEL_NAME=tiiuae/falcon-rw-1b
wanna go harder? patch models/adapter.py
â wrap it with quantization, lora, or even hybrid inference setups.
restart the container â new brain, same runtime.
add new api routes
fastapi makes adding endpoints stupid easy:
# backend/api/routes/agent_control.py
from fastapi import APIRouter
router = APIRouter()
@router.post("/agent/trigger")
def trigger_agent(agent_id: str):
return {"status": "launched"}
include it in api/server.py
, done.
custom memory logic
want smarter vector recall or different scoring?
change
data/vectorizer.py
â swap cosine for dot, euclidean, hybrid anninject tag filters or session context before lookup
need scale? dump postgres â faiss, weaviate, or whatever ann flavor you like
log it â track whether hits actually improve inference quality
cli tooling â plug & extend
every script under cli/
has full runtime access.
drop your own tool in, no permission needed:
# backend/cli/summarize.py
from backend.core.registry import registry
def main():
model = registry.get("model")
print(model("summarize todayâs crypto news"))
if __name__ == "__main__":
main()
â model â logger â memory vectors â agents â config
hook it up to cronjobs, bash loops, or external apis for self-training loops on autopilot.
first hacks to try
daily twitter scraper agent that feeds memory + trains overnight
memory cleaner that purges old vectors by score
cli visualizer for prompt clusters
ui toggle to swap models mid-session
contributing or forking
brainz is open-source under mit. no bs, no locks. workflow:
git clone https://github.com/brainz/OS
git checkout -b feat/my-agent
git commit -m "add my agent"
push a pr with:
â
tests under /tests/
â
updated flags in docs
â
a short âwhat it doesâ
we merge anything that doesnât break the brain.
Last updated