Repository navigation
fix: estimate missing model prices with same-backend medians - #11164
Conversation
Use exact per-component family medians after configured defaults, falling back to the serving backend median without changing execution selection. Charge estimates to budgets and expose warnings and provenance. Co-authored-by: Copilot App <[email protected]>
Documentation PreviewDocumentation has been built for this PR. To view locally:
Built from commit c38d2a6 |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved pricing-resolution defects can discard valid rates, misidentify or double-count tariff donors, and apply incorrect fallbacks or freshness checks, affecting estimated credits and budget enforcement.
6 open issues
Use pinned runtime time for provider freshness checks · New Preserve bundled family when merging feed captures · New Group equivalent source IDs without losing alias lookups · New Allow missing cache-write rates during donor resolution · New Preserve publisher namespaces in donor lookups · New Preserve output fallback when reasoning is omitted · New
What changed in this PR
Extends AWF’s pricing resolver so concrete models without exact or configured-default prices can contribute estimated usage to AI-credit totals and budget enforcement using same-backend donors.
Changes:
- Adds exact per-component medians, preferring declared-family donors before backend-wide donors.
- Carries estimate warnings and provenance through accounting, reflection, and HTTP/WebSocket usage records.
- Expands unit and offline smoke coverage and documents the estimation policy.
| File | Description |
|---|---|
src/model-information-contract/pricing-resolution.js |
Mirrors median resolution and partial-provider merge logic. |
src/model-information-contract/pricing-resolution.d.ts |
Adds estimate sources, metadata, and helper types. |
shared/model-information/pricing-resolution.js |
Implements exact medians and the new fallback stage. |
shared/model-information/pricing-resolution.d.ts |
Defines the shared estimate contract. |
scripts/ci/smoke-pricing-resolution.cjs |
Extends offline protocol, budget, and provenance checks. |
docs/model-catalogue-publication.md |
Documents estimated accounting and residual unpriced usage. |
docs/awf-config-spec.md |
Defines donor eligibility, precedence, and estimate semantics. |
docs/adr/0004-model-information-management.md |
Updates the accounting and eligibility boundary. |
containers/api-proxy/token-tracker.schema.test.js |
Checks estimate metadata in serialized usage records. |
containers/api-proxy/token-tracker-shared.js |
Copies estimate metadata into usage records. |
containers/api-proxy/token-budget-log.test.js |
Updates the no-donor accounting scenario. |
containers/api-proxy/token-budget-log.js |
Adds estimate metadata to accounting log fields. |
containers/api-proxy/server.websocket.test.js |
Updates WebSocket estimate-warning expectations. |
containers/api-proxy/server.token-guards.test.js |
Checks estimated charging for missing-price HTTP models. |
containers/api-proxy/runtime-model-catalog.js |
Associates runtime pricing captures with capture times. |
containers/api-proxy/provider-pricing-overlays.js |
Exposes operator-configured model IDs for donor selection. |
containers/api-proxy/model-recovery.js |
Excludes median estimates from automatic recovery selection. |
containers/api-proxy/model-pricing-catalog.js |
Exposes configured catalogue model IDs. |
containers/api-proxy/guards/pricing-resolution.test.js |
Updates precedence and partial-fill accounting expectations. |
containers/api-proxy/guards/median-pricing.test.js |
Adds median, donor, precision, and enforcement coverage. |
containers/api-proxy/guards/ai-credits-guard.test.js |
Updates estimate warnings, accounting, and priceability checks. |
containers/api-proxy/guards/ai-credits-guard.js |
Integrates estimates, warnings, and reflected metadata. |
containers/api-proxy/catalogue-pricing.test.js |
Tests donor exclusions and capture stability. |
containers/api-proxy/catalogue-pricing.js |
Resolves donors and builds estimate fingerprints. |
containers/api-proxy/catalogue-loader.test.js |
Updates fallback expectations when central pricing is unavailable. |
containers/api-proxy/catalogue-contract/pricing-resolution.js |
Mirrors the shared resolver for the API proxy. |
containers/api-proxy/catalogue-contract/pricing-resolution.d.ts |
Mirrors estimate types for API-proxy consumers. |
Review effort: Max (auto)
| const time = options.catalogue?.time ?? getRuntimePricingCaptureTime(runtime, provider); | ||
| const maxAge = options.catalogue?.maxAge ?? 30 * 24 * 3600 * 1000; |
| for (const record of catalogue?.snapshot.models || []) { | ||
| // Feed family evidence may enrich pricing, but feed aliases cannot extend naming policy. | ||
| models.set(record.identity.key, { ...record, identity: { | ||
| ...record.identity, aliases: declared.get(record.identity.key)?.identity.aliases || [], | ||
| } }); | ||
| } |
| const resolved = resolve(id); | ||
| if (!resolved.identity || seen.has(resolved.identity.key)) continue; | ||
| seen.add(resolved.identity.key); | ||
| const canonical = resolved.identity.rawId; |
| const resolution = resolvePricing({ | ||
| identity: resolved.identity, scope, inputTokens, time, maxAge, sources: { |
| operator: () => getProviderPricingFact(provider, canonical), | ||
| configured: () => getConfiguredPricingFact(provider, canonical), |
| if (result?.estimate) { | ||
| const selected = Object.hasOwn(runtime.pricing, 'reasoning') ? runtime : result; | ||
| pricing.reasoning = exact.rate(selected.pricing, 'reasoning'); | ||
| componentSources.reasoning = componentProvenance(selected); | ||
| } |
|
✅ Copilot review passed with no inline comments. @lpcox Add the |
|
@copilot address review feedback |
Addressed the pricing review feedback in |
|
@copilot fix this failing ci check and make sure that 'npm test' runs without any failures https://github.com/github/gh-aw-firewall/actions/runs/42098337408/job/127552257668?pr=11164 |
Fixed the stale smoke-test expectation in |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.
|
|
Smoke Cloud Hypervisor completed. Cloud Hypervisor + Copilot passed.
|
|
✅ Smoke Claude passed
|
|
🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅
|
|
✅ Build Test Suite completed successfully!
|
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 Smoke CodexOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
💎 Smoke Gemini is crystallizing results on this pull request... |
|
🔌 Smoke Services is testing service connectivity for this pull request... |
|
🔑 Smoke Copilot BYOK AOAI (api-key) is testing Azure OpenAI BYOK (api-key) mode on this pull request... |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅
|
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤
|
|
✅ Security Guard completed successfully! Security GuardOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
Smoke test: FAIL
|
|
OTEL smoke test
|
|
Fix canonical Copilot placeholder checks in daily runtime regression
|
Copilot BYOK Smoke Test: ✅ PASSTest Results:
Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY) with api-proxy credential injection All smoke tests passed successfully.
|
🏗️ Build Test Suite Results
Overall: 7/8 ecosystems passed — FAIL Java failure: .NET note: the first
|
|
Smoke Copilot: PR #11161 "Fix canonical Copilot placeholder checks in daily runtime regression"; PR #11159 "fix: make daily Codex regression noninteractive and sidecar-backed"
Overall: PASS — @lpcox
|
|
EGRESS_RESULT allow=pass deny=pass
Overall: PASS — cc @lpcox
|
Smoke Test: Claude Engine Validation
Overall result: PASS
|
Chroot Version Comparison
Result: ❌ Not all tests passed. Node.js differs between host (v24) and chroot (v22). The
|
|
@copilot fix the failing ci check. make sure that 'npm test' has no failures https://github.com/github/gh-aw-firewall/actions/runs/42117523325/job/127672068997?pr=11164 |
The failing run compiled merge commit |
Bring in the upstream runHost consolidation so the PR's merged root test suite compiles. Co-authored-by: Copilot App <[email protected]>

Summary
Activate median accounting for the final concrete named model with no applicable price or configured default bucket. Estimated usage now contributes to AI-credit totals, steering, configured budgets, and the hard cap instead of being silently left out of accounting.
estimated_model_ai_credits_pricingwarnings. Carry family/backend estimate policy, donor/component counts, source kinds and a deterministic tariff fingerprint through real HTTP/WebSocket JSONL records and reflected accounting, including partial-provider fills. Quiet probes remain quiet, and malformed prices retain sanitized errors and dispatch blocking.Validation
npm run build,npm run type-check,npm run models:check, changed-document Markdown lint andgit diff --checkpassed. Commit hooks ran root lint with no errors and the production build.No live provider inference, workflow dispatch, extra guest/container runs or merge performed.
Relates to #10295 and #10290; this does not close either parent phase.