Skip to content

feat: enterprise-aware mode — detect Bedrock/Vertex/OTEL and quote USD-saved #129

Description

@jhonatanjunio

Problem

On Anthropic's usage-based enterprise plans there is no included token allowance — every token is billed at API rates and an admin-set spend cap pauses the workspace when hit, requiring a manual refill ticket. In that regime, every byte squeez removes converts directly to USD on the workspace bill and to runway before the next budget request.

Squeez already saves the tokens; what's missing is surfacing that value so operators and finance can quote a number, and showing the user when they're in an enterprise-cost regime so they know it matters.

Proposal

New src/economy/enterprise.rs:

  • pub enum EnterpriseMode { None, Bedrock, Vertex, Otel } + pub fn detect() -> EnterpriseMode.
  • Detection via env vars: CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX, AWS_BEDROCK_REGION, ANTHROPIC_VERTEX_PROJECT_ID, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_METRIC_EXPORT_INTERVAL, CLAUDE_CODE_ENABLE_TELEMETRY. Precedence Bedrock > Vertex > OTEL.
  • pub fn estimate_usd(saved_input_tokens: u64, model: PricingModel) -> f64 at Anthropic's public Sonnet 4.6 ($3/MTok) or Opus 4.7 ($5/MTok) rates. Default Sonnet — conservative.

Three surfaces consume the signal:

  • Wrap header gains [squeez: enterprise=<slug>] when a transport is detected.
  • init banner prints an enterprise hint, including USD saved in the prior session when available.
  • New MCP tool squeez_enterprise_savings returns mode + saved-tokens + USD at both Sonnet and Opus rates.

Tradeoff

  • Detection is env-var only, no network or credential access.
  • Conservative pricing — Sonnet rate by default; never overstates savings.
  • No code path executes when not in enterprise mode (zero overhead).

Out of scope

  • Enforcing or reporting to OTEL collectors (would couple us to a transport).
  • Per-key spend caps in the binary — those live on Anthropic's admin side.

Area

  • MCP server (src/commands/mcp_server.rs)
  • Other — new src/economy/enterprise.rs

Confirmations

  • I've searched existing issues and this isn't a duplicate.
  • This respects the zero-runtime-dependency rule (only libc allowed in Cargo.toml).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds-triageAwaiting maintainer triage

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions