Cap /reflect effective-token totals at configured maxEffectiveTokens#3208
Conversation
/reflect effective-token totals at configured maxEffectiveTokens
There was a problem hiding this comment.
Pull request overview
This PR updates the API proxy effective-token guard so /reflect reports budget usage capped at the configured maximum while preserving the true internal total for enforcement.
Changes:
- Clamps reflected
total_effective_tokenstomax_effective_tokens. - Derives reflected remaining budget and percent used from the clamped value.
- Adds focused guard tests for below, exact, and over-budget reflect behavior.
Show a summary per file
| File | Description |
|---|---|
containers/api-proxy/guards/effective-token-guard.js |
Caps effective-token values returned for reflect-state presentation. |
containers/api-proxy/guards/effective-token-guard.test.js |
Adds tests covering reflected budget clamping boundaries. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 0
Smoke Test Results
Overall: PARTIAL (2/3 tests) Notes:
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: FAIL — GitHub MCP auth and pre-step smoke data unavailable.
|
|
refactor: [Export Audit] Remove test-only re-exports from barrel modules Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🔬 Smoke Test Results
Overall: FAIL The workflow template variables (
|
Smoke Test Results
Overall Status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Chroot Smoke Test Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot.
|
🏗️ Build Test Suite Results
Overall: 7/8 ecosystems passed — ❌ FAIL ❌ Failure DetailsJava (gson, caffeine) — Both projects failed with: The
|
Smoke Test Results
Overall: FAIL —
|
|
@copilot address review feedback |
I don’t see any actionable reviewer comments on this PR to address yet. Please point me to the specific feedback (comment link or details), and I’ll apply the requested changes right away. |
Bug Fix
/reflectcould reporteffective_tokens.total_effective_tokensabove the configured budget (e.g., ~46M with a 25M max), which made the reported budget state look inconsistent. The issue was in reflect-state presentation, not in request-blocking enforcement.Reflect-state clamping
max_effective_tokens.remaining_effective_tokensandpercent_usedare now derived from the clamped value, so reported usage cannot exceed 100%.Enforcement behavior preserved
Focused boundary coverage