Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(vibey): compact below the route's context price step (#2659)

Call White09bbc459f0b7
diff --git a/core/agent_core/ai/provider.py b/core/agent_core/ai/provider.py
index 7f41641eb..8c72c2c0f 100644
--- a/core/agent_core/ai/provider.py
+++ b/core/agent_core/ai/provider.py
@@ -128,6 +128,9 @@ class ModelCapabilities:
supports_images: Optional[bool] = None
supports_reasoning: Optional[bool] = None
reasoning_efforts: tuple[str, ...] = ()
+ #: The context sizes past which the model's list price steps up, ascending; empty when flat or unknown. C-9 keeps
+ #: the compaction threshold below the smallest one it can (``context.md`` section 1).
+ context_price_steps: tuple[int, ...] = ()
class MediaLoader(Protocol):
diff --git a/core/agent_core/harness/context.py b/core/agent_core/harness/context.py
index 60b958973..9259d8b43 100644
--- a/core/agent_core/harness/context.py
+++ b/core/agent_core/harness/context.py
@@ -55,6 +55,9 @@ MARGIN_RATIO = 0.03
#: The margin is at most an eighth of the window: with ``O <= W / 4`` (the Avibe Agent's budget), ``T >= 0.625 * W``.
MARGIN_CAP_RATIO = 0.125
THRESHOLD_RATIO = 0.9
+#: A context price step (``ModelCapabilities.context_price_steps``) smaller than this is not kept below (section 1): a
+#: checkpoint's own context is some 30,000 tokens, so a lower threshold would compact almost every request.
+PRICE_STEP_MIN = 100_000
KEEP_MAX = 20_000
KEEP_RATIO = 0.25
IMAGE_TOKENS = 1_600
@@ -497,7 +500,7 @@ def budget(
) -> Budget:
"""``W, L_in, O, M, T, keep`` and ``est`` of a composed ``request`` on the route resolved for it.
- Sections 1 and 2: it derives ``W, L_in, M, T, keep`` and ``est`` and reads ``O`` from ``request.max_tokens``,
+ Sections 1 and 2: it derives ``W, L_in, M, P, T, keep`` and ``est`` and reads ``O`` from ``request.max_tokens``,
which ``output_tokens`` or ``checkpoint_max_tokens`` set when the request was built. ``transcript`` is the part
of the request's messages that comes from the rows, which is what an anchor is checked against.
"""
@@ -506,6 +509,10 @@ def budget(
output = request.max_tokens
margin = min(max(MARGIN_MIN, math.ceil(MARGIN_RATIO * window)), math.floor(MARGIN_CAP_RATIO * window))
threshold = min(limit - output - margin, math.floor(THRESHOLD_RATIO * window))
+ # A step at or past the window cannot lower T, and is never multiplied: a hand-edited price may name any size.
+ step = min((size for size in capabilities.context_price_steps if PRICE_STEP_MIN <= size < window), default=None)
+ if step is not None:
+ threshold = min(threshold, math.floor(THRESHOLD_RATIO * step))
keep = max(0, min(KEEP_MAX, math.floor(KEEP_RATIO * threshold)))
return Budget(window, limit, output, margin, threshold, keep, _estimate(request, transcript, anchor))
diff --git a/core/handlers/model_hub/pricing.py b/core/handlers/model_hub/pricing.py
index 97aa72cb2..a1e183825 100644
--- a/core/handlers/model_hub/pricing.py
+++ b/core/handlers/model_hub/pricing.py
@@ -2,7 +2,9 @@
A valuation, never a bill: it answers "what would this usage have cost at the
vendor's published API price", so a subscriber can see whether the plan pays for
-itself. Nothing in resolution, admission, or cooldown reads it.
+itself. Nothing in routing, admission, or cooldown reads it. Hop resolution only
+reports where a model's price steps up with its context (`context_price_steps`),
+which Vibey's context management keeps below (C-9 `context.md` section 1).
Prices come from two places, highest precedence first: the user's hand-edited
override file (`<state dir>/model_hub_prices.json`), then the models.dev catalog
@@ -184,6 +186,23 @@ def context_tier_size(price: Optional[ModelPrice], context_input_tokens: int) ->
return max((size for size, _rates in price.context_tiers if context_input_tokens > size), default=0)
+def context_price_steps(price: Optional[ModelPrice]) -> tuple[int, ...]:
+ """The context sizes past which a call costs more than at the base rates, ascending.
+
+ Each context tier with an input, cache read, or output rate above the base
+ one; a tier no dearer than the base is no step. A model with no price, or a
+ flat one, has none.
+ """
+
+ if price is None:
+ return ()
+ return tuple(
+ size
+ for size, rates in price.context_tiers
+ if rates.input > price.input or rates.cache_read > price.cache_read or rates.output > price.output
+ )
+
+
def context_tier_price(price: ModelPrice, size: int) -> ModelPrice:
"""The rates usage recorded in the context tier `size` is valued at.
diff --git a/core/handlers/model_hub/service.py b/core/handlers/model_hub/service.py
index cf04dd801..6aa117f38 100644
--- a/core/handlers/model_hub/service.py
+++ b/core/handlers/model_hub/service.py
@@ -181,7 +181,14 @@ from .oauth import (
OAuthFlowRegistry,
UnavailableNativeOAuthAdapter,
)
-from .pricing import VALUE_WINDOW_DAYS, PriceTable, hosted_response_cost, load_price_table, quota_values
+from .pricing import (
+ VALUE_WINDOW_DAYS,
+ PriceTable,
+ context_price_steps,
+ hosted_response_cost,
+ load_price_table,
+ quota_values,
+)
from .quota import QuotaSourceRef, SubscriptionQuotaCache, SubscriptionQuotaError
from .provenance import (
REQUEST_NONFALLBACK_TURN_OUTCOME,
@@ -6430,6 +6437,16 @@ class ModelHubService:
basis, usd = priced
return HostedCost(basis=basis, usd=None if usd is None else round(usd, 6))
+ def context_price_steps(self, model_id: str) -> tuple[int, ...]:
+ """Where ``model_id``'s list price steps up with its context (``pricing.context_price_steps``), ascending.
+
+ Memory-only, like ``hosted_call_cost``: read from the table the usage writer already holds, so a hop resolved
+ before the first table is read, or for a model with no price, reports none.
+ """
+
+ prices = self.usage_writer.held_prices
+ return context_price_steps(prices.price(model_id)) if prices is not None else ()
+
def _admitted_executor(self, slot: ExecutorSlot, tool: str) -> ExecutorCandidate | None:
"""The chain's candidate as the current snapshot admits it, else None (``vibey-hosted-tools.md`` §6).
diff --git a/docs/plans/agent-core-contracts/context.md b/docs/plans/agent-core-contracts/context.md
index 4ba9a1d62..48ad23b6e 100644
--- a/docs/plans/agent-core-contracts/context.md
+++ b/docs/plans/agent-core-contracts/context.md
@@ -1,7 +1,8 @@
# C-9 Context management
Frozen 2026-10-04 by owner decision; amended 2026-10-13 by owner decision (the estimate of opaque reasoning payloads
-and the anchor's validity, §2; the cache lifetime per route, §3; the checkpoint request's output budget, §1 and §6).
+and the anchor's validity, §2; the cache lifetime per route, §3; the checkpoint request's output budget, §1 and §6);
+amended 2026-10-15 by owner decision (the threshold stays below the route's context price step, §1).
The `harness` owns the rules (`core/agent_core/harness/context.py`, `projection.py`); the loop applies them before
every model request (`core/agent_core/agent/loop.py`); the adapter supplies the Session-specific parts (§9). Row
shapes: [`transcript-rows.schema.json`](transcript-rows.schema.json); events:
@@ -21,7 +22,7 @@ projects the full original context (C-5 §4).
The hop capabilities Model Hub returns for the route resolved for the request (C-6) give the limits. `O` is set
when the request is built, as its `max_tokens` (`output_tokens()`, `checkpoint_max_tokens()`). One pure function,
-`harness/context.budget(request, capabilities, transcript, anchor)`, derives `W, L_in, M, T, keep` and the request's
+`harness/context.budget(request, capabilities, transcript, anchor)`, derives `W, L_in, M, P, T, keep` and the request's
`est` (§2) and reads `O` from the request, once per request (§10, invariant 1). No state keeps these values between
requests, so a route change is picked up at once; a smaller window than expected is handled by the overflow path
(§8). Every fit decision is `budget()` on a request actually composed (§10, invariant 1), including the two the
@@ -33,7 +34,8 @@ L_in = input_limit (W when unknown)
O = the request's max_tokens: for a conversation request max_output_tokens (8,192 when unknown), capped by the
Agent's output budget; for a checkpoint request min(64,000, that)
M = min(max(8,000, ceil(0.03 * W)), floor(W / 8))
-T = min(L_in - O - M, floor(0.9 * W)) the compaction threshold
+P = the smallest context_price_steps size of at least 100,000 and below W (none when there is none)
+T = min(L_in - O - M, floor(0.9 * W), floor(0.9 * P)) the compaction threshold; without P, the first two
keep = min(20,000, floor(0.25 * T)) the verbatim tail of a normal checkpoint
```
@@ -44,8 +46,24 @@ be sent), and 296 more would leave `T < 0.25 * W`. The adapter therefore asks fo
`min(max_output_tokens, floor(W / 4))` on every hop it resolves (a retry's fallback included), the maximum 8,192 when
unknown, so the output never takes more than a quarter of any window; the limits themselves still come from Model
Hub. `M` is at most an eighth of the window, so with `O <= W / 4` the threshold stays positive on every window:
-`T >= 0.625 * W` (with `L_in = W`). Windows of 64,000 tokens and more are unchanged (`M = max(8,000, 3% W)`); on an
-8,000-token route `O = 2,000`, `M = 1,000`, and `T = 5,000`.
+`T >= 0.625 * W` (with `L_in = W`), and `T >= min(0.625 * W, 90,000)` with a price step `P` (below). Windows of
+64,000 tokens and more are unchanged (`M = max(8,000, 3% W)`); on an 8,000-token route `O = 2,000`, `M = 1,000`, and
+`T = 5,000`.
+
+`P` is where the route's price steps up. `context_price_steps` (C-6) lists the input sizes past which the target
+model's list price rises, from Model Hub's price table (the user's override file, then models.dev's first-party
+`cost.tiers`). Past 272,000 input tokens, OpenAI's GPT-5.4 and later models bill the whole request at twice the input
+and cache rates and 1.5 times the output, on a 1,050,000-token window; Gemini and Grok models step at 200,000. A long
+request is slower as well: on the gpt-6-astra Sessions recorded from 2026-10-10 to 2026-10-15, with about the same
+output, the median request took 23 s under 100,000 tokens, 43 s at 200,000 to 300,000, and 78 s past 800,000, and
+65% of the requests were past the step (86% of their input tokens) at `T = 890,500`. Replaying those requests with
+`T = 244,800` costs about a quarter at list price, checkpoints included, with 126 checkpoints instead of 9. So
+`T` stays a tenth below the step, the window's ratio: the tenth leaves room for one tool batch and the checkpoint
+request, so the checkpoint is written below the step too. A step under 100,000 tokens is not kept below: a
+checkpoint's own context (system prompt, tools, checkpoint, `keep`) is some 30,000 tokens, so a lower threshold would
+compact almost every request, and a dearer step above it still counts. A step at or past the window cannot lower
+`T` and is ignored without arithmetic, whatever size a hand-edited price names. The step is the model's list price whatever
+the Source bills (a subscription's request is as slow). With no price, or a flat one, `T` is as before.
A conversation request **fits** when `est + O + M <= L_in`, where `est` is its estimate (§2); `M` absorbs the
estimate's error. A request **can fit** when `est + O <= L_in`. A checkpoint request (§6) is sent only when it can
diff --git a/docs/plans/agent-core-contracts/hop-resolution.schema.json b/docs/plans/agent-core-contracts/hop-resolution.schema.json
index ff0037da5..5dab974f0 100644
--- a/docs/plans/agent-core-contracts/hop-resolution.schema.json
+++ b/docs/plans/agent-core-contracts/hop-resolution.schema.json
@@ -71,7 +71,8 @@
"supports_tools",
"supports_images",
"supports_reasoning",
- "reasoning_efforts"
+ "reasoning_efforts",
+ "context_price_steps"
],
"additionalProperties": false,
"properties": {
@@ -120,6 +121,14 @@
"items": {
"type": "string"
}
+ },
+ "context_price_steps": {
+ "type": "array",
+ "items": {
+ "type": "integer",
+ "minimum": 1
+ },
+ "description": "The input sizes past which the target model's list price rises (any of input, cache read, or output above the base rate), ascending, from Model Hub's price table; empty when its price is flat or unknown. C-9 keeps the compaction threshold below the smallest one it can (context.md section 1)."
}
},
"description": "Null means Model Hub does not know the value; it never guesses. supports_images is null when the model declares no input modalities."
@@ -374,7 +383,8 @@
"medium",
"high",
"xhigh"
- ]
+ ],
+ "context_price_steps": []
},
"hosted_tools": {
"web_search": {
diff --git a/docs/plans/agent-core-contracts/model-hub-consumer.md b/docs/plans/agent-core-contracts/model-hub-consumer.md
index 72929de1e..8718ea1de 100644
--- a/docs/plans/agent-core-contracts/model-hub-consumer.md
+++ b/docs/plans/agent-core-contracts/model-hub-consumer.md
@@ -23,6 +23,10 @@ consumer's requirements, and the Model Hub lane lands the change in both places.
and capabilities. A capability Model Hub does not know is `null`, never guessed; `input_limit` is `null` until Model
Hub stores one. The agent treats unknown values conservatively (C-2). It resolves once per run and again after a
retryable error.
+ - `capabilities.context_price_steps` lists the input sizes past which the target model's list price rises,
+ ascending, read from the price table Model Hub's usage writer holds (the user's override file, then models.dev's
+ first-party `cost.tiers`); it is empty when the price is flat or unknown. C-9 keeps the compaction threshold
+ below the smallest one it can (`context.md` §1).
- `request_headers` carries `x-avibe-turn-id`, the Turn the resolution was made for, and the agent sends it on
every gateway request: model calls and proxied hosted calls.
- `source_identity` is the primary hop Source's credential-free identity (`identity_digest`: kind, vendor,
diff --git a/docs/plans/model-hub-contracts/README.md b/docs/plans/model-hub-contracts/README.md
index 0a4dfa1cf..f0fab58ef 100644
--- a/docs/plans/model-hub-contracts/README.md
+++ b/docs/plans/model-hub-contracts/README.md
@@ -15,6 +15,8 @@ before it ships.
and `POST /api/models/sources/<source_id>/evidence/clear` clear refusals; the PUT is per field.
- The provider overlay gains a vendor's `executor_model` and `image_models[]`, and loses the native `image_generation`
declaration.
+- `HopResolution.capabilities` gains `context_price_steps` (`hop-resolution.schema.json`): where the target model's
+ list price rises with its context, from the price table, which Vibey's compaction threshold stays below.
It builds on v14 (2026-10-14): opaque history is bound to the account that issued it, the Source
identity, not only to the origin (#2620): a provider refuses another account's encrypted reasoning.
diff --git a/docs/plans/model-hub-contracts/hop-resolution.schema.json b/docs/plans/model-hub-contracts/hop-resolution.schema.json
index 90e8d44fe..16c3f95e5 100644
--- a/docs/plans/model-hub-contracts/hop-resolution.schema.json
+++ b/docs/plans/model-hub-contracts/hop-resolution.schema.json
@@ -23,7 +23,7 @@
"request_headers": { "type": "object", "additionalProperties": { "type": "string" } },
"capabilities": {
"type": "object",
- "required": ["context_window", "input_limit", "max_output_tokens", "supports_tools", "supports_images", "supports_reasoning", "reasoning_efforts"],
+ "required": ["context_window", "input_limit", "max_output_tokens", "supports_tools", "supports_images", "supports_reasoning", "reasoning_efforts", "context_price_steps"],
"additionalProperties": false,
"properties": {
"context_window": { "type": ["integer", "null"], "minimum": 1 },
@@ -32,7 +32,12 @@
"supports_tools": { "type": ["boolean", "null"] },
"supports_images": { "type": ["boolean", "null"] },
"supports_reasoning": { "type": ["boolean", "null"] },
- "reasoning_efforts": { "type": "array", "items": { "type": "string" } }
+ "reasoning_efforts": { "type": "array", "items": { "type": "string" } },
+ "context_price_steps": {
+ "type": "array",
+ "items": { "type": "integer", "minimum": 1 },
+ "description": "Where the target model's list price rises with its context, ascending, from the price table the usage writer holds; empty when flat or unknown."
+ }
}
},
"hosted_tools": {
diff --git a/docs/plans/model-hub-contracts/vibey-consumer.md b/docs/plans/model-hub-contracts/vibey-consumer.md
index 0ac4c9471..5b06df948 100644
--- a/docs/plans/model-hub-contracts/vibey-consumer.md
+++ b/docs/plans/model-hub-contracts/vibey-consumer.md
@@ -10,6 +10,10 @@ adapter remain C-8 work.
returns the serialized `HopResolution` in `hop-resolution.schema.json`. It calls
the existing `resolve("vibey", ...)`; `ModelHubLaunch.to_hop_resolution()` projects
that launch. There is no second planner, credential store, or upstream client.
+Its `capabilities.context_price_steps` are where the target model's list price
+rises with its context (`pricing.context_price_steps`), read from the price table
+the usage writer already holds, so resolution does no I/O for them; a hop
+resolved before the first table is read reports none.
The backend id is `vibey`. It has a fixed catalog (ordinary editable model rows),
no native protocol pin, no native CLI, and no Direct mode. Until its starting
diff --git a/modules/agents/model_hub.py b/modules/agents/model_hub.py
index 0aba10704..d69316766 100644
--- a/modules/agents/model_hub.py
+++ b/modules/agents/model_hub.py
@@ -194,6 +194,8 @@ class ModelHubLaunch:
hosted_tools: Mapping[str, Mapping[str, Any]] = field(default_factory=dict)
# Vibey only: the Source's credential-free identity, from the snapshot its origin came from (C-6).
source_identity: Optional[str] = None
+ # Vibey only: where the target model's list price steps up with its context, ascending (C-6, C-9 section 1).
+ context_price_steps: tuple[int, ...] = ()
def to_hop_resolution(self) -> dict[str, Any]:
"""Project C-6 from the same launch that owns routing and credentials."""
@@ -223,6 +225,7 @@ class ModelHubLaunch:
"supports_images": self.supports_images,
"supports_reasoning": self.supports_reasoning,
"reasoning_efforts": list(self.reasoning_efforts),
+ "context_price_steps": list(self.context_price_steps),
},
"hosted_tools": copy.deepcopy({tool: dict(entry) for tool, entry in self.hosted_tools.items()}),
}
@@ -1398,6 +1401,9 @@ class ModelHubRuntimeRouter:
),
hosted_tools=hosted_tools,
source_identity=identity,
+ context_price_steps=(
+ self.service.context_price_steps(target_model) if backend == "vibey" else ()
+ ),
)
self._emit_transition(launch, config)
return launch
diff --git a/modules/agents/vibey/models.py b/modules/agents/vibey/models.py
index 452b98baf..5878efcc4 100644
--- a/modules/agents/vibey/models.py
+++ b/modules/agents/vibey/models.py
@@ -159,6 +159,11 @@ def selection_from_hop(hop: Mapping[str, Any], *, gateway_base_url: Optional[str
efforts = raw.get("reasoning_efforts") or []
if not isinstance(efforts, (list, tuple)) or not all(isinstance(item, str) for item in efforts):
raise HopResolutionError("hop capability reasoning_efforts must be a list of strings")
+ steps = raw.get("context_price_steps") or []
+ if not isinstance(steps, (list, tuple)) or not all(
+ isinstance(size, int) and not isinstance(size, bool) and size > 0 for size in steps
+ ):
+ raise HopResolutionError("hop capability context_price_steps must be a list of positive integers")
capabilities = ModelCapabilities(
context_window=_optional(raw.get("context_window"), int, "context_window"),
input_limit=_optional(raw.get("input_limit"), int, "input_limit"),
@@ -167,6 +172,7 @@ def selection_from_hop(hop: Mapping[str, Any], *, gateway_base_url: Optional[str
supports_images=_optional(raw.get("supports_images"), bool, "supports_images"),
supports_reasoning=_optional(raw.get("supports_reasoning"), bool, "supports_reasoning"),
reasoning_efforts=tuple(efforts),
+ context_price_steps=tuple(sorted(steps)),
)
base_url = hop["base_url"]
if protocol == "google":
diff --git a/tests/agent_core/agent/test_context.py b/tests/agent_core/agent/test_context.py
index 461e35d4a..1bf32b42c 100644
--- a/tests/agent_core/agent/test_context.py
+++ b/tests/agent_core/agent/test_context.py
@@ -245,6 +245,30 @@ def test_limits_follow_the_frozen_formula_from_the_route_capabilities(
assert at_limit.fits and not replace(at_limit, est=at_limit.est + 1).fits
+ "window,output,steps,threshold",
+ [
+ (1_050_000, 128_000, (), 890_500), # a flat price: the window's threshold
+ (1_050_000, 128_000, (272_000,), 244_800), # GPT-5.4 and later: a tenth below the step
+ (1_050_000, 128_000, (272_000, 600_000), 244_800), # the smallest step
+ (1_000_000, 128_000, (100_000,), 90_000), # a step of 100,000 is kept below
+ (1_000_000, 128_000, (32_000,), 842_000), # a smaller one is not
+ (1_000_000, 128_000, (32_000, 128_000), 115_200), # but a dearer step above it is
+ (128_000, 32_000, (200_000,), 88_000), # a step past the window changes nothing
+ (1_050_000, 128_000, (10**400,), 890_500), # nor does one past any float a hand-edited price may name
+ ],
+)
+def test_the_threshold_stays_below_the_context_price_step(window, output, steps, threshold):
+ capabilities = ModelCapabilities(context_window=window, max_output_tokens=output, context_price_steps=steps)
+ request = make_request(system="", max_tokens=output)
+ plan = budget(request, capabilities, transcript=())
+ flat = budget(request, replace(capabilities, context_price_steps=()), transcript=())
+ assert plan.threshold == threshold
+ # Only the threshold (and the tail it bounds) follows the step: the output, margin and limit are the window's.
+ assert (plan.output, plan.margin, plan.input_limit) == (flat.output, flat.margin, flat.input_limit)
+ assert plan.keep == min(20_000, threshold // 4)
+
+
@pytest.mark.parametrize("window", [4_000, 8_000, 12_000, 32_000, 128_000, 1_000_000])
def test_the_threshold_stays_positive_on_every_window(window):
# With the Agent's output at most a quarter of the window and the margin at most an eighth, T >= 0.625 * W.
diff --git a/tests/test_model_hub_vibey_consumer.py b/tests/test_model_hub_vibey_consumer.py
index e980fd54b..8d37c48e7 100644
--- a/tests/test_model_hub_vibey_consumer.py
+++ b/tests/test_model_hub_vibey_consumer.py
@@ -33,10 +33,12 @@ from config.v2_config import (
ModelHubSourceStateConfig,
)
from core.handlers.model_hub.adapter import RawOutcomeKind
+from core.handlers.model_hub.pricing import PriceTable
from core.handlers.model_hub.provenance import BoundedProvenanceStore, SERVED_HOP_HEADER
from core.handlers.model_hub.request import ModelHubRequest
from core.handlers.model_hub.service import ModelHubError
from core.handlers.model_hub.turn_gateway import ModelHubTurnGateway
+from core.handlers.model_hub.usage import UsageWriter
from core.run_settlement import SETTLED_BY_TERMINAL_RESULT
from modules.agents.model_hub import (
ModelHubRuntimeRouter,
@@ -46,6 +48,7 @@ from modules.agents.model_hub import (
claude_settings_for_launch,
resolve_model_hub_launch,
)
+from modules.agents.vibey.models import selection_from_hop
from tests.test_model_hub_l3 import (
InvokeHandle,
LiveInvokeHandle,
@@ -75,7 +78,7 @@ MANDATORY_FIELDS = {
),
("capabilities",): (
"context_window", "input_limit", "max_output_tokens", "supports_tools",
- "supports_images", "supports_reasoning", "reasoning_efforts",
+ "supports_images", "supports_reasoning", "reasoning_efforts", "context_price_steps",
),
},
"turn-provenance.schema.json": {
@@ -1154,6 +1157,17 @@ async def test_hop_resolution_uses_primary_protocol_and_alias_capabilities(tmp_p
input_modalities=["text", "image"], supports_tools=True, supports_reasoning=False,
reasoning_efforts=["high"],
)
+ # The target model's price, not the requested alias's: a tier no dearer than the base is no step.
+ base = {"input": 5, "output": 30, "cache_read": 0.5}
+ prices = PriceTable(
+ catalog={"openai": {"models": {"upstream-model": {"cost": {**base, "tiers": [
+ {**base, "tier": {"type": "context", "size": 128_000}},
+ {"input": 10, "output": 45, "cache_read": 1, "tier": {"type": "context", "size": 272_000}},
+ ]}}}}},
+ vendor_map={"families": [{"prefix": "upstream-", "vendor_id": "openai"}]},
+ overrides={}, price_table_date="2026-10-15",
+ )
+ service.usage_writer = UsageWriter(service.usage, price_table=lambda: prices)
gateway = ModelHubTurnGateway(service)
router = ModelHubRuntimeRouter(service=service, turn_gateway=gateway)
try:
@@ -1172,7 +1186,9 @@ async def test_hop_resolution_uses_primary_protocol_and_alias_capabilities(tmp_p
"supports_images": True if known else None,
"supports_reasoning": False if known else None,
"reasoning_efforts": [],
+ "context_price_steps": [272_000] if known else [],
}
+ assert selection_from_hop(hop).capabilities.context_price_steps == ((272_000,) if known else ())
_assert_mandatory_fields("hop-resolution.schema.json", hop)
launch = await router.resolve("vibey", "menu-alias", process_scope="vibey:test", turn_id="turn-hop")
assert hop["token"] not in repr(launch)