l6e Documentation

website·Indexed 31 days ago

https://docs.l6e.ai

l6e provides session-scoped budget enforcement for AI coding agents, allowing users to set dollar limits per task. It features an MCP server that integrates with tools like Cursor, Claude Code, Windsurf, and OpenClaw to gate expensive operations using pre-call token estimates and calibration.

Tokens
7.7K
Snippets
39
Records
63
Agent score
52%

What's inside l6e

  1. Understand l6e cost calibration

    l6e uses a calibration factor (a multiplier) to bridge the gap between raw token-based cost estimates and actual provider billing. When l6e_authorize_call estimates a cost, the calibration factor is applied to determine the amount recorded against the budget. This ensures that remaining_usd and budget_pressure in gate responses reflect actual billing rather than estimates, reducing the estimate-to-billing error from 2-10x down to 2-3x.
  2. Understand l6e-mcp local-only operation

    By default, after pip install l6e-mcp, the system runs entirely locally without a remote backend or proxy. In this mode, it provides a budget gate that fires before expensive operations, a local SQLite session store to persist spend, and a run log saved to .l6e/runs.jsonl at the end of a session. The system returns allow, reroute (advising a cheaper model), or halt decisions to the agent before each call.
  3. Calibrate l6e cost estimates using billing data

    l6e computes a personal calibration factor to ensure budget pressure and halt thresholds reflect actual costs rather than raw estimates. This is achieved by importing billing CSVs from your provider (currently only Cursor CSV is supported). l6e matches billing line items against session data by timestamp and model to refine the factor. It is recommended to import data weekly or after each billing cycle.
  4. Implement exact real-time usage accounting

    l6e uses estimate-based accounting by default. To achieve exact real-time accounting, the AI agent must call l6e_record_usage with the actual token counts immediately after each LLM call completes.
  5. Handle rerouting requirements for local Ollama instances

    When the l6e_authorize_call function returns an action of "reroute", a running local Ollama process with a compatible model must be available to execute the reroute. Note that the MCP protocol does not have a primitive to force a model switch; therefore, reroute actions are always advisory.
  6. Install l6e-budget MCP server for Windsurf

    The l6e-budget MCP server provides session-scoped budget enforcement for Windsurf (Cascade). It is recommended to use uvx to run the server in an isolated environment without a separate installation. Alternatively, you can install it manually via pip.
    # Recommended: No install needed, just use uvx in config
    # Manual install:
    pip install l6e-mcp
  7. Implement checkpoints for multi-step workflows

    For complex, multi-step work, use checkpoint instructions to ensure the agent pauses for authorization between phases. Use the specific instruction call l6e_authorize_call between each step to enforce this behavior.
    Perform the following steps: 1. Analyze logs, 2. Propose fix, 3. Apply fix. Call l6e_authorize_call between each step.
  8. Manage budget estimates in local-only mode

    Because the MCP protocol cannot intercept LLM provider responses, l6e-mcp relies on token estimates provided to l6e_authorize_call before a call is made. These estimates are directionally accurate for models like Claude, GPT-4, and Gemini, but can drift (2-10x) from actual billing without calibration.

    To minimize drift:

    • Use dual-token estimates (estimated_prompt_tokens and estimated_completion_tokens) rather than a single total, as prompt and completion tokens have different prices.
    • Be conservative with estimates; overestimating is safer than underestimating to avoid unaccounted expensive work.
    • Ensure the model string passed to l6e_run_start matches the actual billed model.
  9. Install l6e-budget MCP server

    The l6e-budget MCP server can be installed using uvx (recommended) which runs the server in an isolated environment on first use, or via a manual pip installation.
    # Recommended: No install needed, just use uvx in config
    # Manual install:
    pip install l6e-mcp
  10. Orchestrate large tasks with multi-session budgets

    For large, multi-phase implementations, use a manager agent to spawn sub-agents. Each sub-agent starts its own l6e session with an independent budget ceiling via l6e_run_start. This prevents a single runaway phase from consuming the entire project budget. Child sessions are linked to the manager via parent_session_id and are grouped together in the l6e dashboard.
    I want you to make a todo list for phase 3 and execute it in a sub agent that will use l6e to build phase 3 with a budget of $3 — ensuring that the sub agent runs authorize before major checkpoints.
    
    Then while that sub-agent runs, make a todo list for phase 4 and spin up another sub agent that will use l6e with a budget of $4 — ensuring that the sub agent runs authorize before major checkpoints.
    
    For your parent session as the main agent, use a budget of $3 to manage the subagents.
  11. Install l6e-mcp for OpenClaw

    The l6e-budget MCP server can be run using uvx (recommended) for an isolated environment on first use, or installed manually via pip.
    # Recommended: No install needed, just use uvx in config
    # Manual install:
    pip install l6e-mcp
  12. Configure l6e-budget MCP server in Windsurf

    Configure the MCP server by editing ~/.codeium/windsurf/mcp_config.json or using the Windsurf Command Palette (Cmd+Shift+P → Windsurf: Configure MCP Servers).

    Critical Requirement: L6E_LOG_PATH must be set because Windsurf spawns MCP servers with cwd=/. Without this, logs will fail to write due to permission errors.

    Optional variables:

    • L6E_API_KEY: Enables cloud sync and personal calibration factors.
    • L6E_CLOUD_SYNC: Set to 1 to sync session run logs to the l6e cloud.

    Restart Windsurf completely after saving the configuration.

    {
      "mcpServers": {
        "l6e-budget": {
          "command": "uvx",
          "args": ["l6e-mcp"],
          "env": {
            "L6E_LOG_PATH": "${HOME}/.l6e/runs.jsonl",
            "L6E_API_KEY": "sk-l6e-...",
            "L6E_CLOUD_SYNC": "1"
          }
        }
      }
    }