feat(economy): enterprise-aware mode (Bedrock/Vertex/OTEL) with USD-saved estimate#6
Closed
jhonatanjunio wants to merge 1 commit into
Closed
feat(economy): enterprise-aware mode (Bedrock/Vertex/OTEL) with USD-saved estimate#6jhonatanjunio wants to merge 1 commit into
jhonatanjunio wants to merge 1 commit into
Conversation
…+ USD savings Adds `economy::enterprise` which detects whether the host is wired to an enterprise-cost transport (AWS Bedrock, Google Vertex, or an OTEL metrics exporter) and exposes a small USD-savings estimator at Anthropic's public input rates (Sonnet 4.6 $3/MTok, Opus 4.7 $5/MTok). Three surfaces now expose the signal: - Wrap header gains `[squeez: enterprise=<slug>]` whenever a transport is detected, so users see in real time that their saved tokens convert to workspace USD rather than to subscription credits. - 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 estimates at both Sonnet and Opus rates, so finance dashboards and agents can quote a number. Detection is env-var only, no network or credential access. Defaults are conservative — Sonnet rate, no overstating value. Closes claudioemmanuel#129 Signed-off-by: Jhonatan Junio <jhonatanjuniocp@gmail.com>
ac329b5 to
259ecb8
Compare
Owner
Author
|
Superseded by upstream PR — moved to claudioemmanuel/squeez. See README of this fork for the upstream link. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5
Summary
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 (requires a manual refill ticket). This PR makes that economics visible inside squeez.
What changed
src/economy/enterprise.rs— env-var detection (Bedrock, Vertex, OTEL) + USD-savings estimator at Anthropic's public Sonnet 4.6 and Opus 4.7 rates. Zero new deps, no network calls.[squeez: enterprise=<slug>]when a transport is detected.squeez_enterprise_savingsreturns mode + saved tokens + USD at both Sonnet and Opus rates — finance dashboards and the agent itself can quote a number.How detection works
CLAUDE_CODE_USE_BEDROCK=1orAWS_BEDROCK_REGIONbedrockCLAUDE_CODE_USE_VERTEX=1orANTHROPIC_VERTEX_PROJECT_IDvertexOTEL_EXPORTER_OTLP_ENDPOINT/OTEL_METRIC_EXPORT_INTERVAL/CLAUDE_CODE_ENABLE_TELEMETRY=1otelnone(no banner, no tag)Precedence: Bedrock > Vertex > OTEL.
Verification
Tests
11 new unit tests:
bedrock_beats_otel_when_both_set)falsy_use_flag_is_not_enterprise)Full lib suite: 170/170 passing (159 prior + 11 new).
Design choices