Cost & Token Usage Analysis
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The BrightPath AI Operations system is designed as a lightweight multi-agent pipeline that processes inbound messages through a series of specialized LLM calls. Each interaction involves a minimum of three agents: Triage, a Specialist (Sales or Customer Service), and a Manager Briefing agent. This multi-step architecture ensures high accuracy and specialized responses but necessitates a clear understanding of token consumption and associated API costs.
The system primarily utilizes Anthropic's Claude models. By leveraging a mix of high-capability models for reasoning (Sonnet) and faster, more efficient models for summarization (Haiku), the project optimizes the balance between operational intelligence and financial efficiency.
Sources: README.md:3-10, README.md:18-20
Model Strategy & Token Allocation
The pipeline is structured to distribute workloads across two specific Claude models based on the complexity of the task.
Model Selection
The system defaults to the following model configuration:
- Claude 3.5 Sonnet (
claude-sonnet-4-5): Used for the Triage and Specialist agents (Sales/Customer Service) where deep context understanding of memory files, CRM data, and complex policy application is required. - Claude Haiku (
claude-haiku-4-5-20251001): Used for the Manager Briefing agent to produce concise, Telegram-ready summaries.
Sources: app.py:277-278, orchestrator.py:34-35, README.md:27
Consumption Metrics
A standard execution of the pipeline consists of three sequential API calls. The token usage and estimated costs are summarized below:
| Metric | Estimate |
|---|---|
| Total Tokens per Run | 3,000 – 5,000 tokens |
| Estimated Cost per Run | £0.01 – £0.02 |
| API Calls per Message | 3 (Triage → Specialist → Briefing) |
| Max Tokens per Request | 2,000 (standard), 3,000 (admin briefing) |
Sources: README.md:18-20, app.py:342, orchestrator.py:168
Token Data Flow Analysis
Token usage is driven by the injection of context into the system prompt for each agent. The system reads from five markdown-based memory files and a JSON-based CRM database on every run, which increases the input token count as the company history grows.
Sequential Processing Flow
The following diagram illustrates how context is passed through the pipeline, accumulating or transforming data at each step, which influences token consumption.
The diagram shows the cumulative context injection where the Specialist Agent receives both the original message and the Triage output.
Sources: app.py:393-455, orchestrator.py:241-290
Context Variables
The load_memory() and load_crm() functions gather the data that populates the LLM's system prompt. As these files grow, the "baseline" token cost per request increases.
| File/Source | Purpose | Impact on Tokens |
|---|---|---|
company_context.md | Policies, pricing, guidelines | Static/Low growth |
customer_history.md | Per-customer logs | High growth over time |
sales_notes.md | Pipeline activity | Medium growth |
open_tasks.md | Outstanding actions | Variable |
crm.json | Contact metadata | High growth over time |
Sources: app.py:321-337, orchestrator.py:141-155
Operational Optimization
To manage costs and token usage, the system implements specific logic to limit output length and use more efficient models where appropriate.
Model Switching Logic
The call_claude function includes a fast parameter. When set to True, the system switches to MODEL_FAST (Haiku). This is currently implemented for the Manager Briefing agent to reduce costs for the final summarization step.
# app.py:341-351
def call_claude(system_prompt, user_message, fast=False, max_tokens=2000):
client = anthropic.Anthropic(api_key=API_KEY)
response = client.messages.create(
model=MODEL_FAST if fast else MODEL,
max_tokens=max_tokens,
system=system_prompt,
messages=[{"role": "user", "content": user_message}]
)
Sources: app.py:341-351, orchestrator.py:163-173
Specialized Admin Briefings
The system includes a build_admin_context() function which compiles a significantly larger context, including database tasks and recent pipeline events. This request is given a higher max_tokens limit of 3,000 to accommodate the increased data density.
Sources: app.py:289-312, app.py:365
Summary of Cost Management
The BrightPath architecture manages costs by:
- Tiered Modeling: Reserving the expensive Sonnet model for complex triage and specialist logic while using Haiku for simple summarization.
- Constraint-Based Output: Enforcement of strict JSON formatting and word counts (e.g., Telegram summaries under 120 words) to minimize unnecessary output tokens.
- Local Memory Files: Using flat files for memory allows for easy monitoring of context size before it is sent to the API.
Sources: agents/manager_briefing_agent.md:16, README.md:18-20, orchestrator.py:34-35
Token usage and cost analysis remain integral to the project's scalability, particularly as the customer_history.md and crm.json files expand with continued operational use.
Sources: README.md:18-20, app.py:321-337