Skip to main content

Cost Management & Budget Control

Myrm provides a comprehensive multi-layer cost control system that ensures you never overspend on LLM usage — while maintaining task quality through intelligent routing.

Budget Policy

Configuration (Settings → Developer → Usage Statistics → Budget Control)

Set spending limits across three independent dimensions: Each dimension triggers a 4-level progressive response:

How It Works

  1. WARNING — Agent receives a budget hint via cache-safe prompt injection. Eco mode activates (compression threshold multiplied by 0.8)
  2. FINALIZATION — Agent is instructed to output final results immediately. Tool calls are stripped from model output
  3. EXCEEDED — Hard block. No further LLM calls until budget is reset or expanded
Budget status is displayed in real-time via SSE push to the frontend BudgetBadge and Goal status card.

The Agent Economy: Budgeted Spending, Not an On-Chain Wallet

TermiX-style agent marketplaces give agents an on-chain identity, a wallet, service listings and escrow. That fits public job-taking and crypto settlement; for a general office user, an on-chain wallet means gas, private keys, cross-chain assets and compliance burden. Myrm takes a different path: identity stays local, the budget stays local, approvals stay local.
  • Identity: each agent is a local profile you configure (name, model, tools, skills, memory); no .agent domain or on-chain wallet required.
  • Spending: set per-transaction and daily caps and a merchant allowlist in Settings → System → Spending Limit Gate, with one-click freeze and ledger reconciliation after a restart; none of “Always allow”, YOLO mode or Smart Intent Guard can release a payment-like tool call, so in a chat you are watching every one waits for your approval.
  • Collaboration: delegation goes to your own sub-agents and Kanban workers inside your workspace; there is no open marketplace of third-party agents.
  • Delivery: sandbox acceptance + artifact fingerprints + approvals + audit; settle after acceptance.
Not offered today: a public agent marketplace, on-chain identity/wallet/escrow, or cross-org reputation. If you need an agent to earn crypto, TermiX is the better fit; if you need a personal assistant that does work safely, Myrm is.

Breaking Free from Weekly Quota Lockouts: BYOK & Anti-Bloat Governance

A rigid weekly quota can lock a business out for days once its limit is exhausted. Furthermore, when single-chat context exceeds 200k tokens without active compaction, every subsequent round re-processes the entire uncompressed history, so consumption keeps climbing. Myrm addresses both:
  • Elastic BYOK Direct Connect (Zero Business Downtime): The local WebUI and Tauri desktop app are free and open source. Users bring their own API keys to directly access OpenAI, Anthropic, DeepSeek, and Google. Extra runs cost pennies directly to providers, keeping production pipelines operating 24/7 without quota blockades;
  • Deterministic Pre-compact Compression: Before session context reaches danger levels, Myrm extracts core facts and artifact references, archiving history in-place to compress the context, so later rounds stop re-processing the full history;
  • Prompt Cache Locking: Direct FC and task-oriented PTC ensure lightweight tools resolve in a single round-trip, preventing trigger-happy agent loops and keeping complex task costs down.
No bundle required. You do not need to buy a social + model + agent subscription stack. Myrm’s local WebUI and desktop app are free; cloud hosting is optional; with BYOK you pay your model provider directly. Each assistant can also be capped by a token/USD budget policy, so giving it more permissions does not mean giving it an unlimited bill.

Real-Time Cost Observability

Per-Message Display

Every assistant message shows detailed token breakdown:
  • 7 token types: prompt, completion, cached, cache_write, reasoning, citation, total
  • Cost in USD, the share of the prompt read from the cache, and the dollars the cache saved on that reply (shown as a negative amount when writing the cache cost more than reading it saved)
  • Model tier indicator (simple / standard / reasoning)
  • Cache break reason attribution when cache misses occur

Goal Panel (Active Goals)

While a goal is running, the expanded status card shows:
  • Burn rate — tokens/minute consumption
  • Cost rate — $/minute spending
  • ETA — estimated time to budget exhaustion
  • Progress bar — percentage of budget consumed

Usage Statistics Dashboard (Settings → Developer → Usage Statistics)

Full analytics dashboard with:
  • Daily spending chart (7/30/365 day ranges)
  • Session-level drill-down with token/cost breakdown
  • Model breakdown panel (cost per model)
  • Hour and weekday distribution heatmaps
  • Per-agent usage cards with sparkline trends
  • Routing analytics (how many requests used each tier)

Full-Chain Accounting — No Blind Spots

Every LLM call, streaming or not, lands in the same token ledger:
  • Unified recording — streaming and non-streaming calls are counted in one place (the adapter layer), so sub-agent spawns, dynamic workflows, background summaries, memory extraction, context compression and wiki compilation are all attributed correctly
  • Honest failure paths — a failed LLM call never fabricates usage, so the ledger never inflates
  • End-of-run accuracy — message_end events are back-filled with real usage from the tracker, so per-run totals match the sum of individual calls
For hosted / metered-billing users this means the bill you see is the bill you can trust — background work is never hidden, and nothing is double-counted.

Chat Totals — Exact at Message Level

A chat’s total calls / tokens / USD are rebuilt from the token economics snapshot stored on each active assistant message, never accumulated incrementally, so they cannot drift from the messages you see:
  • Latest message always counted — the rebuilt aggregate is cached against the id of the newest message; a new or sibling-switched message invalidates it, so the last turn is never missing
  • Mutations recompute — retry, regenerate, switch sibling, undo, truncate and rewind each re-aggregate after they commit, so discarded or deactivated messages stop counting immediately
  • Recovered turns keep their cost — the auto-continue recovery path persists the token economics snapshot of the resumed turn the same way a normal turn does
The same totals appear as usageSummary (totalCalls, totalTokens, totalUsd) in chat details and exports, and the usage radar (/statistics/usage/radar) sums them across chats.

Intelligent Cost Routing

ComplexityRouter (Automatic)

Myrm automatically routes requests to the most cost-effective model tier:
  • SIMPLE — Quick questions, greetings → cheapest model
  • STANDARD — Normal tasks → balanced model
  • REASONING — Complex multi-step problems → premium model
Features:
  • Two-phase classification (rule scoring + LLM judge)
  • Session momentum — follow-up messages inherit the conversation’s recent tier to prevent quality degradation
  • Min-tier floor — regenerate requests automatically escalate tier
  • Zero configuration — active by default on all accounts

Privacy-Aware Routing

Sensitive content is automatically routed to privacy-appropriate models based on PII detection level.

Search Provider Failover

Long autonomous tasks draw on third-party search APIs, and free tiers run out. With more than one search provider configured, a provider that fails or stops answering is passed over:
  • Priority chain — a provider that times out, answers with a server error or reports a spent quota is passed over, and the next configured provider answers the search
  • Hung providers yield — every provider except the last one is abandoned after half of the time the chain has left, so one that never answers cannot use up the whole budget; the last provider keeps the remaining time
  • Exhausted quota is remembered, then probed again — a provider that reports an exhausted quota is skipped for an hour, after which the next real search probes it again
  • Rate limits are short — a provider that answers with a rate limit (429) is skipped for a few seconds

Vercel AI Gateway

For teams that route several models through an aggregation gateway:
  • Built-in preset — Vercel AI Gateway is a built-in provider in Settings with its endpoint (https://ai-gateway.vercel.sh/v1) preconfigured
  • Namespaced model ids — models are addressed as vercel_ai_gateway/<vendor>/<model> and sent over the OpenAI-compatible route, so an id that already carries a vendor prefix (for example anthropic/claude-3-5-sonnet) stays routed through the gateway instead of being treated as a direct vendor call
  • Attribution headers — requests to the gateway carry HTTP-Referer and X-Title headers that identify Myrm Agent

Provider Policy Block Failover

Aggregators and providers can reject a request on policy grounds (guardrail or data-policy blocks). Myrm treats that as a failover case, not a task failure:
  • Fallback model — a policy-blocked model enters a cooldown and the run continues on a configured fallback model
  • Clear next step — the error card offers Switch to API Key and Switch Model, both opening model settings (/settings/models)
  • Credential errors are not failed over — an invalid API key is shown at once with a Check API Key action that opens /settings/credentials, because another model cannot fix it

Subagent Cost Isolation

Delegation Budget

Each root task has a max_descendants = 20 guard preventing runaway subagent spawning. This ensures a single task cannot create an unbounded delegation tree that drains budget.

Per-Root Budget Scope

Budget tracking is scoped per root agent run — subagent costs accumulate against the parent’s budget dimensions, providing unified visibility.

Multi-Agent Cost Pre-Flight

When the agent needs to spawn multiple sub-agents (batch delegation, council cross-review, or alternatives parallel generation), Myrm estimates the total LLM cost before execution begins:
  • Batch mode — estimates cost based on task count × per-task model pricing
  • Council mode — accounts for expert_count × (1 + cross_review_rounds) + 1 (chair synthesis) LLM calls
  • Alternatives mode — estimates based on the number of parallel expert agents
If the estimated cost exceeds $0.50, an interactive approval card appears in the chat, showing:
  • Total estimated cost in USD
  • Number of LLM calls to be made
  • Remaining budget
You can approve to proceed or reject to cancel the operation — no tokens are consumed until you approve. This prevents surprise bills from complex multi-agent operations.

Long Task Resilience

Checkpoint & Recovery

If the server process is interrupted during a long task:
  1. Signal-safe checkpoint — all running subagents are checkpointed to disk (JSON + fcntl file locking)
  2. Orphan recovery — on restart, orphan scanner detects interrupted checkpoints and publishes events to the UI
  3. Resume API — user can resume from checkpoint with full state restoration (messages + workspace)

Goal Continuation Guard

The continuation engine evaluates 9+ conditions before each turn:
  • Budget remaining check
  • Cancellation / steering token
  • Convergence detection
  • Goal drift detection (trajectory scoring every 5 turns)
  • Per-todo checkpoint (optional pause after each step)
  • Protected file integrity validation

Unattended Runaway Circuit Breaker

Scheduled tasks run without anyone watching, so a loop has to stop itself:
  • Loop detection — in unattended mode the loop guard treats three consecutive tool failures, repeated identical failing calls, or the same error recurring as a runaway and raises a hard circuit break instead of a recoverable stuck-tool error
  • No retry storm — the scheduler records the run as circuit_break, pauses a recurring job and clears its next run, so no backoff retry fires
  • Visible in the run history — the run shows a pulsing rose “Circuit Break” badge, a banner, and an expanded panel explaining that the run was stopped to prevent runaway retries

Output Compression

CLI tool output is automatically compressed using intelligent rules to minimize token consumption:
  • Path deduplication and summarization
  • Repeated pattern collapsing
  • Binary/noise filtering
  • Large output truncation with summary

Stable Prefix for Cache Efficiency

System prompts and tool schemas are carefully ordered and canonicalized to maximize prompt cache hit rates:
  • Deterministic tool schema ordering (SSOT)
  • Schema canonicalization (removing non-semantic differences)
  • Cache breakpoint detection with attribution reporting