Repository navigation
🤖 feat: count AI calls from bash commands in workspace costs (opt-in) - #5772
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccb29071fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rd configured account headers
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b02260512b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Heads-up from #5791: #5799 makes config-backed palette toggles show "Current: On" or "Current: Off". "Toggle Keep Screen Awake" reads Generated with |
Summary
Bash tool commands can now send their Anthropic and OpenAI calls through Xum, so the spend shows up in the workspace's Cost tab and in Analytics. Turn on Settings → Providers → Bash commands (off by default). Each Local or Worktree bash command then gets
ANTHROPIC_BASE_URL,OPENAI_BASE_URLand a per-workspacexum-proxy-…key that point at a loopback proxy. The proxy forwards with the provider keys from Xum's settings and records the reported usage.This is PR 1 of 4 in a stack. PR 2 keeps the port and keys stable across restarts, PR 3 adds SSH and Coder hosts, and PR 4 adds a bug-bash scenario for the feature.
Background
Test harnesses (
make bug-bash, e2e explorers, SDK scripts) that the agent runs in bash call providers directly. Today that spend never reaches Xum's ledger, so the Cost tab and Analytics undercount.Implementation
src/node/services/bashAiProxy/bashAiProxyService.ts: a loopback HTTP proxy. Allowed paths: Messages, Responses, Chat Completions, token counting and model listing. It replaces the proxy key with the real key and provider headers, addsstream_options.include_usageto streamed Chat Completions, dropsExpect, and does not follow redirects. It builds the upstream URL from the configured base URL (normalized like the chat path, query kept) and keeps headers configured in providers.jsonc, such asOpenAI-Project.usageExtract.tsreads usage from JSON and SSE bodies (Anthropic and OpenAI). The proxy records usage throughSessionUsageService.recordHeadlessUsagewith analytics sourcebash_proxy, and emits a livesession-usage-delta.TurnRequestBuilderadds the variables toxumEnvon a best-effort basis. It adds none when:XUM_DISABLE_PROJECT_AUTOMATION=1). The bash tool blanks provider keys there, so a proxy URL would pair with a blank key.Validation
Unit tests with a fake upstream: both Anthropic SDK path styles, OpenAI chat and responses, SSE usage, header handling, the refusals above, and the env rules.
aiService.test.tscovers the trust gating for trusted, untrusted and kill-switch workspaces. I mutation-checked it and the 403 test.Dogfood with a fake provider and no real spend: a bash
curlthrough the proxy shows up in the Cost tab rows next to the chat turns.Four agent bug-bash rounds (Opus 5.5 and Sonnet 5.5 explorers, effort high, PR 4 scenario) against the top of the stack. The last round found no defect in branch code. Earlier rounds found unclear setting copy and two trust gaps. This stack fixes them.
Risks
claude -pbill the Xum API key instead of a subscription login. That is why the switch is opt-in. The docs and the setting text say so.Related issues filed from the bug bashes (not fixed here): #5766, #5767, #5768, #5769, #5771.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$32.63