feat(dynamic-pricing) F1: measured per-route economics (route_economics)#35
Draft
jmlago wants to merge 1 commit into
Draft
feat(dynamic-pricing) F1: measured per-route economics (route_economics)#35jmlago wants to merge 1 commit into
jmlago wants to merge 1 commit into
Conversation
Price is the one ranking input the host still mostly DECLARES (sources stamp a pulled/advertised price) instead of MEASURING — while reliability, latency and tool-capability are already rolling route_* folds. This adds the missing measured-economics member. - route_economics.py: a per-route EMA of the EFFECTIVE blended cost a route actually charged (USD/Mtok), from `response.cost_reported` (e.g. OpenRouter usage.cost) over token count. Exact twin of route_latency: success-only fold, None when no cost reported, in-process, reuses route_reliability.route_key. - llm_router_host: fold the call's reported cost at the same outcome site as reliability/latency. - shim market/perf view: surface `measured_usd_per_mtok` next to latency_ms, so the operator sees what a route REALLY cost vs the price the catalog stamped — the gap that matters most for marketplace peers that advertise a price they do not settle. Observability + measurement ONLY: this does NOT yet feed ranking (that changes selection — a separate, deliberate step). Additive: full suite 394 -> 402 passed (+8 new unit tests), 2 skipped, 0 failed; behaviour preserved.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
First increment of
dynamic-pricing(supersedes the static-prices approach of #32).Adds the missing measured-economics member of the
route_*family. Price isthe one ranking input the host still mostly DECLARES (sources stamp a pulled /
advertised price) while reliability, latency and tool-capability are already
rolling measured folds. This measures it.
route_economics.py— per-route EMA of the EFFECTIVE blended cost a routeactually charged (USD/Mtok), from
response.cost_reported(e.g. OpenRouterusage.cost) over token count. Exact twin ofroute_latency.llm_router_host.measured_usd_per_mtokin the market/perf view (shim), next tolatency_ms.Observability + measurement ONLY — it does NOT yet feed ranking.
Verify
Full suite 394 → 402 passed (+8 new unit tests), 2 skipped, 0 failed, under
nix-shellvs pinned core97d0333. Behaviour preserved (additive).NOT in this commit — these change selection (new external behaviour), the
form-giver's call, not mine:
the catalog's stamped price. Open design: a per-route correction ratio
(actual ÷ expected-from-stamped-price) applied to the stamped price — which
keeps the price_in/price_out split (the measured total can't be split per
direction). For OpenRouter it converges ~1.0 (the pulled price is already
right); for antseed it catches peers settling above what they advertised.
ranking+billing adjustment (the credit-purchase fee, off-band, not per-call
observable). Kept distinct from any ranking-only preference (codex
scarcity-price precedent, object §3).
provenance tags
measured | pulled | advertised-untrusted.Plan:
/tmp/unhardcoded-dynamic-pricing-plan.md. #32 stays draft, closed at theend. This PR is a proposal for independent adjudication — not to self-merge.