Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BRAHMO Composition Agent

Token Budget + 8-Block Assembly + Iterative Compression

A full-stack system that transforms 28 raw candidate nodes into a structured, token-efficient context string that fits within a hard 4,000-token ceiling.

Quick Start

1. Backend

cd backend
pip3 install fastapi uvicorn supabase python-dotenv tiktoken
uvicorn main:app --reload --port 8000

2. Frontend

cd frontend
npm install
npm run dev
# Opens at http://localhost:3000

3. Configure Supabase (Optional)

Edit .env with your Supabase URL and key. Without it, the app uses local JSON data.

Architecture

The 6 Modules

Module File Purpose
Token Counter token_counter.py tiktoken 3-source counting (BEFORE API call)
Importance Scorer importance_scorer.py Dual retrieval + injection weights
Block Assembler block_assembler.py 8-block fixed-order structure
Compressor compressor.py Distance-weighted levels + CONSTRAINT protection
Budget Fitter budget_fitter.py Iterative compression loop
Context Builder context_builder.py Final string assembly

The Pipeline

28 nodes → Dual Importance Scoring → 8-Block Assembly
        → Distance-Weighted Compression → 3-Source Token Count
        → Iterative Budget Fitting → Context String Output

Key Rules

  • CONSTRAINTs are ALWAYS FULL — never compressed regardless of distance or budget
  • 3 sources counted BEFORE API call: system prompt + context + user reserve
  • 8-block order is LOCKED: 1→2→3→4→5→6→7→8, never reordered
  • Block 7 (Stale) only appears when REVIEW_REQUIRED nodes exist
  • Lowest injection_weight non-CONSTRAINT compressed first

Submission Checklist

  • 28 candidate nodes with 3 compression levels
  • tiktoken cl100k_base token counting
  • ALL THREE sources counted before API call
  • 8 blocks in correct locked order
  • CONSTRAINT nodes always FULL
  • Iterative compression with CONSTRAINT protection
  • Dual importance weights visible per node
  • Compression log pass-by-pass
  • Budget slider (1000–6000) with live recomposition
  • Context string viewer modal
  • Block 8 CAPTURE instruction
  • docs/architecture.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages