CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Feature: Track Claude usage served via AWS Bedrock

Open zyaiire opened this issue 5 months ago • 2 comments

Summary

Currently, the AWS Bedrock provider reads aggregate month-to-date spend from Cost Explorer (ce:GetCostAndUsage), which gives a dollar total across all Bedrock models but no per-model token or request breakdown.

The Claude provider tracks session/weekly usage against Anthropic's own API — it has no visibility into Claude models accessed through AWS Bedrock.

Users who route Claude calls through Bedrock (e.g. anthropic.claude-3-5-sonnet-20241022-v2:0) therefore have a gap: they can't see token consumption or request counts for Claude-on-Bedrock in CodexBar.

Proposed improvement

Add per-model usage tracking to the Bedrock provider by pulling from one of the available AWS data sources:

Source What it gives Requirements
CloudWatch AWS/Bedrock namespace InputTokenCount / OutputTokenCount per ModelId cloudwatch:GetMetricData permission
Bedrock Model Invocation Logs (S3 / CloudWatch Logs) Full per-request detail Logging must be enabled by user
Cost Explorer with GROUP BY on USAGE_TYPE Rough token-based cost split Already in use, minimal extra IAM

The lowest-friction path would be adding a CloudWatch GetMetricData call filtered to ModelId values matching Claude (e.g. containing claude), so users get token-level usage without enabling extra logging.

Use case

  • Teams using Claude via Bedrock for compliance/data-residency reasons want to track their Claude token budget the same way direct-API users do.
  • Would complement the existing Bedrock cost view with meaningful usage metrics (tokens in/out, request count) rather than just dollars.

Current workaround

Manual CloudWatch console check or a custom script — neither integrates with CodexBar's reset countdowns or usage bars.

Happy to help test if a prototype lands. Thanks for the great tool!

zyaiire avatar Jun 11 '26 05:06 zyaiire

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 11, 2026, 1:37 AM ET / 05:37 UTC.

Summary Codex review failed: codex execution failed.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Ways to help us reproduce this

  • Add a screenshot or short recording showing the behavior.
  • Include the exact command, prompt, or workflow that triggered it.
  • Add expected vs actual behavior.

Next step Review did not complete, so no work-lane recommendation was made.

Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

Do we have a high-confidence way to reproduce the issue?

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Remaining risk / open question:

  • No close action taken because the review did not complete.

Codex review notes: model internal, reasoning high; reviewed against 6d156e70c712.

Label changes

Label changes:

  • add issue-rating: 🦪 silver shellfish: Current issue advisory state selects this label.
  • add clawsweeper:needs-info: Current issue advisory state selects this label.
Evidence reviewed

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Codex review failed for this issue with exit 1.
  • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

clawsweeper[bot] avatar Jun 11 '26 05:06 clawsweeper[bot]

Fixed by #1655 (36f0657d).

The Bedrock provider now adds optional rolling 14-day Claude input-token, output-token, and invocation totals from the configured region's AWS/Bedrock CloudWatch metrics, while retaining the existing Cost Explorer spend and budget data. CloudWatch is best-effort, permission failures preserve spend data, and matching Claude model IDs are aggregated while other model families are excluded.

Proof covers the signed regional request shape, server-side metric sums, bounded pagination, incomplete-result rejection, display projection, permission fallback, secure endpoint overrides, all supported AWS partition suffixes, make check, full-suite validation, autoreview, and exact-head hosted CI.

steipete avatar Jun 19 '26 21:06 steipete