Skip to content

fix(anthropic): withhold hosted advisor under captured spend ceilings - #835

Closed
luvs01 wants to merge 3 commits into
devfrom
fix/hosted-advisor-spend
Closed

luvs01 wants to merge 3 commits into
devfrom
fix/hosted-advisor-spend

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Translated Messages requests could forward Anthropic's optional hosted Advisor while token ceilings were configured, although the main model's terminal usage does not independently account for that secondary work.

  • Withhold the hosted Advisor declaration, completed Advisor replay and its beta when the request's captured root, identity or provider-pool ceiling applies. The main turn and other tools continue under their existing accounting contract.
  • Resolve the selected API key or admitted Anthropic/Anthropic2 OAuth snapshot through a separate, request-local hosted-Advisor target binding. Ordinary main-model target binding and physical log attribution retain their existing scopes.
  • Capture the immutable numeric ceilings at hosted preflight when needed, without starting accounting or reserving a send. Accounting mode, reservations and the physical-send limit remain decisions of the actual admission/start path. Combo prepayment keeps its already selected mode.
  • Preserve credential selection, instance separation, generation and bearer-ownership checks. Keep ordinary destination behavior without a ceiling and the separately budgeted proxy Advisor.
  • Document withholding and the distinction between numeric policy capture and accounting admission.

Addresses the Daybreak finding.

Verification

Linux, Bun 1.4.4; injected synthetic transports and the production ledger.

A one-token identity ceiling reproduced HTTP 429 before dispatch in four direct hosted-Advisor OAuth cases in the preceding implementation: both Anthropic instances, with account pooling on and off. The revised cases return HTTP 200 with one main-model send and withhold the optional Advisor. Combo controls retained HTTP 200. The tested no-Advisor Messages/Responses paths already returned HTTP 200; preservation controls keep their existing observe-only mode and identity-ledger behavior.

Focused validation Result
claude-translated-advisor-tool.test.ts 80 passed / 642 assertions
Copilot Auto runtime + Advisor internal authority 120 passed / 1,484 assertions
First-send policy + execution-budget permits + spend ledger 72 passed / 478 assertions
Spend-anchor cases excluding WS 62 passed / 292 assertions; 4 filtered
Exact server-auth upstream-reset case 1 passed / 6 assertions
File-size ratchet 9 passed / 85 assertions

The final synthetic-credential spelling adjustment was checked with the affected API-key control again: 1 passed / 7 assertions. Typecheck covered 2,536 files with no errors; structure, privacy and staged whitespace checks passed.

The Combo regression also verifies a single pool-only Q reservation, no abandonment/rebooking, four actual sends, bounded reservation amounts and correct final pool settlement with no added identity debt. The prepared-route authority fixture and real upstream-socket-reset test preserve their original authorization and failure-accounting assertions.

Local testing is focused because the broad local suite includes provider/network paths beyond these synthetic fixtures. The four spend-anchor WS cases are excluded after the same local fixture timeout reproduced on the unchanged base; hosted CI remains the broader gate. The reset case uses an isolated preload that refuses non-loopback fetches. No live-provider or billing test is claimed.

The existing SSE mask timing-test correction remains in this branch: it measures excerpt masking separately while retaining complete rewrite/redaction assertions. Production masking is unchanged.

Independent source review covered the final runtime changes, credential boundaries, accounting scopes and regressions. Maintainer security approval and native-platform acceptance remain separate.

Hosted CI

Latest-head hosted CI is running for 644a7d821329cdde3f8d53fab19a9b194f48bb42; earlier-head results are not reported as validation of this commit.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

The security checkbox records implementation review; explicit maintainer security review remains required before merge.


Devin Review

@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 16, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@luvs01 luvs01 closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant