Repository navigation
fix(cost_map): mark fireworks_ai/minimax-m3 as vision and pin capabilities verified against live calls #43390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1216bd6
e5cc50e
3131804
126f0db
1f53deb
2be59c8
00e4420
28c3a27
e4e0354
f20a86f
6d68c41
b666f9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| /model_prices_and_context_window.json @mateo-berri @ryan-crabbe-berri @kerry-berri @joshua-berri | ||
| /litellm/model_prices_and_context_window_backup.json @mateo-berri @ryan-crabbe-berri @kerry-berri @joshua-berri | ||
| /ci_cd/cost_map_pins.json @mateo-berri @ryan-crabbe-berri @kerry-berri @joshua-berri | ||
| /helm/ @yassin-berriai | ||
| /terraform/ @yassin-berriai | ||
| /.github/workflows/zizmor.yml @yuneng-berri |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| name: Cost map pins recheck | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - "litellm_**" | ||
| paths: | ||
| - model_prices_and_context_window.json | ||
| - litellm/model_prices_and_context_window_backup.json | ||
| - ci_cd/cost_map_pins.json | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| rerun-cost-map-guard: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| actions: write | ||
| contents: read | ||
| pull-requests: read | ||
| steps: | ||
| - name: Re-run the cost map guard on open pull requests the push could break | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| BASE_REF: ${{ github.ref_name }} | ||
| BEFORE_SHA: ${{ github.event.before }} | ||
| AFTER_SHA: ${{ github.event.after }} | ||
| FORCED: ${{ github.event.forced }} | ||
| COST_MAP_PATHS: '["model_prices_and_context_window.json", "litellm/model_prices_and_context_window_backup.json", "ci_cd/cost_map_pins.json"]' | ||
| PINS_PATHS: '["ci_cd/cost_map_pins.json"]' | ||
| run: | | ||
| if [[ "$BEFORE_SHA" =~ ^0+$ || "$FORCED" == true ]] \ | ||
| || ! gh api "repos/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${AFTER_SHA}?per_page=1" \ | ||
| --jq '(env.PINS_PATHS | fromjson) as $pins | (.files | length) < 300 and all(.files[]; [.filename, .previous_filename] | any(IN($pins[])) | not)' \ | ||
| | grep -qx true; then | ||
| export RECHECK_PATHS="$COST_MAP_PATHS" | ||
| else | ||
| export RECHECK_PATHS="$PINS_PATHS" | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
|
||
| fi | ||
| rerun_cutoff="$(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%SZ)" | ||
| candidates="$(gh api graphql --paginate -F owner="${GITHUB_REPOSITORY_OWNER}" -F name="${GITHUB_REPOSITORY#*/}" -F base="$BASE_REF" \ | ||
| -f query='query($owner: String!, $name: String!, $base: String!, $endCursor: String) { | ||
| repository(owner: $owner, name: $name) { | ||
| pullRequests(states: OPEN, baseRefName: $base, first: 25, after: $endCursor) { | ||
| nodes { number headRefOid changedFiles files(first: 100) { nodes { path } } } | ||
| pageInfo { hasNextPage endCursor } | ||
| } | ||
| } | ||
| }' \ | ||
| --jq '(env.RECHECK_PATHS | fromjson) as $paths | .data.repository.pullRequests.nodes[] | ||
| | {number, headRefOid, listed: any(.files.nodes[].path; IN($paths[])), unlisted: (.changedFiles > 100)} | ||
| | select(.listed or .unlisted) | "\(.number) \(.headRefOid) \(.listed)"')" | ||
| failed=0 | ||
| declare -A rerun_heads | ||
| while read -r number head_sha listed; do | ||
| [ -n "$number" ] || continue | ||
| if [ "$listed" = false ]; then | ||
| if ! changed="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/pulls/${number}/files?per_page=100" \ | ||
| --jq '(env.RECHECK_PATHS | fromjson) as $paths | .[].filename | select(IN($paths[]))')"; then | ||
| echo "::error::could not list the files of #$number" | ||
| failed=1 | ||
| continue | ||
| fi | ||
| [ -n "$changed" ] || continue | ||
| fi | ||
| [ -z "${rerun_heads[$head_sha]:-}" ] || continue | ||
| rerun_heads[$head_sha]=1 | ||
| if ! runs="$(gh run list --repo "$GITHUB_REPOSITORY" --workflow cost-map-guard.yml --commit "$head_sha" --limit 100 --json databaseId,createdAt --jq '.[] | "\(.databaseId) \(.createdAt)"')"; then | ||
| echo "::error::could not list the cost map guard runs of #$number" | ||
| failed=1 | ||
| continue | ||
| fi | ||
| if [ -z "$runs" ]; then | ||
| echo "::warning::no cost map guard run found for #$number" | ||
| continue | ||
| fi | ||
| while read -r run_id created_at; do | ||
| if [[ "$created_at" < "$rerun_cutoff" ]]; then | ||
| echo "::warning::cost map guard run $run_id for #$number is over 30 days old, so GitHub cannot re-run it; #$number gets the pin checks on its next push" | ||
| continue | ||
| fi | ||
| gh run watch "$run_id" --repo "$GITHUB_REPOSITORY" > /dev/null || true | ||
| if ! gh run rerun "$run_id" --repo "$GITHUB_REPOSITORY"; then | ||
| echo "::error::could not re-run cost map guard run $run_id for #$number" | ||
| failed=1 | ||
| fi | ||
| done <<< "$runs" | ||
| done <<< "$candidates" | ||
| exit "$failed" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,67 @@ | ||
| """Guard the cost map on pull requests. | ||
|
|
||
| Every pull request whose diff against its merge base touches one of the two cost map files gets the file | ||
| checks: the files parse and the backup copy matches the root file. A pull request that leaves both untouched | ||
| skips them, since merging it keeps the base branch's copies and its head tree only carries whatever state the | ||
| branch was cut from. Pull requests from the cost map sync bot (branches named litellm_cost_map_sync_*) always | ||
| get the file checks and additionally may only touch those two files and may only add or update models. | ||
| Every pull request whose diff against its merge base touches one of the two cost map files or the pins file gets the | ||
| file checks: the files parse, the backup copy matches the root file, and every capability pinned in | ||
| ci_cd/cost_map_pins.json (a value verified against a live provider call where the provider's model listing says | ||
| otherwise) still holds in the tree that merging the pull request into its base branch produces, so a branch cut before | ||
| a pin was added cannot lower it, and a pull request that deletes the pins file fails too. A pull request that leaves | ||
| all three untouched skips them, since merging it keeps the base branch's copies and its head tree only carries | ||
| whatever state the branch was cut from. Pull requests from the cost map sync bot (branches named | ||
| litellm_cost_map_sync_*) always get the file checks and additionally may only touch the two cost map files and may | ||
| only add or update models, so a sync can never lower a pinned capability or edit the pins. Price sync pull requests | ||
| (branches named litellm-providers/price-sync*) and pull requests a bot account opened (COST_MAP_GUARD_AUTHOR_TYPE is | ||
| Bot) get the human checks and may not touch the pins file either. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import json | ||
| import os | ||
| import subprocess | ||
| import sys | ||
| from collections.abc import Mapping, Sequence | ||
| from collections.abc import Iterator, Mapping, Sequence | ||
| from dataclasses import dataclass | ||
| from types import MappingProxyType | ||
| from typing import Final | ||
|
|
||
| COST_MAP_PATH: Final = "model_prices_and_context_window.json" | ||
| BACKUP_PATH: Final = "litellm/model_prices_and_context_window_backup.json" | ||
| PINS_PATH: Final = "ci_cd/cost_map_pins.json" | ||
| GUARDED_PATHS: Final = (COST_MAP_PATH, BACKUP_PATH) | ||
| CHECKED_PATHS: Final = (*GUARDED_PATHS, PINS_PATH) | ||
| BOT_BRANCH_PREFIX: Final = "litellm_cost_map_sync_" | ||
| PRICE_SYNC_BRANCH_PREFIX: Final = "litellm-providers/price-sync" | ||
| TARGET_ENV: Final = "COST_MAP_GUARD_TARGET" | ||
| AUTHOR_TYPE_ENV: Final = "COST_MAP_GUARD_AUTHOR_TYPE" | ||
| BOT_AUTHOR_TYPE: Final = "Bot" | ||
| MERGE_CONFLICT_EXIT_CODE: Final = 1 | ||
| SPECIAL_ROOT_KEYS: Final = frozenset({"sample_spec", "fallback_generalizations"}) | ||
| EVALUATION_OUTPUT_PRICE_SOURCES: Final[Mapping[str, str]] = MappingProxyType({}) | ||
|
|
||
| CostMap = dict[str, object] | ||
| _MISSING: Final = object() | ||
|
|
||
|
|
||
| @dataclass(frozen=True, slots=True) | ||
| class Snapshot: | ||
| cost_map: str | ||
| backup: str | ||
| pins: str | ||
|
|
||
|
|
||
| @dataclass(frozen=True, slots=True) | ||
| class MergeFailed: | ||
| stderr: str | ||
|
|
||
|
|
||
| @dataclass(frozen=True, slots=True) | ||
| class Pin: | ||
| key: str | ||
| field: str | ||
| value: object | ||
| checked: str | ||
| source: str | ||
|
|
||
|
|
||
| def _parse_object(text: str, path: str) -> CostMap | str: | ||
|
|
@@ -91,6 +121,48 @@ def _entries(cost_map: CostMap) -> dict[str, dict[str, object]]: | |
| return {key: entry for key, entry in cost_map.items() if isinstance(entry, dict)} | ||
|
|
||
|
|
||
| def _pin(key: str, field: str, spec: object) -> Pin | str: | ||
| malformed: Final = f"{PINS_PATH}: {key}.{field} needs value, checked, and source" | ||
| if not isinstance(spec, dict) or "value" not in spec: | ||
| return malformed | ||
| checked: Final = spec.get("checked") | ||
| source: Final = spec.get("source") | ||
| if not isinstance(checked, str) or not isinstance(source, str) or not checked or not source: | ||
| return malformed | ||
| return Pin(key, field, spec["value"], checked, source) | ||
|
|
||
|
|
||
| def _pins(parsed: CostMap) -> Iterator[Pin | str]: | ||
| for key, fields in parsed.items(): | ||
| if not isinstance(fields, dict): | ||
| yield f"{PINS_PATH}: {key} must map field names to pins" | ||
| continue | ||
| for field, spec in fields.items(): | ||
| yield _pin(key, field, spec) | ||
|
|
||
|
|
||
| def _pin_violations(parsed: CostMap, entries: Mapping[str, Mapping[str, object]]) -> Iterator[str]: | ||
| for pin in _pins(parsed): | ||
| if isinstance(pin, str): | ||
| yield pin | ||
| elif pin.key not in entries: | ||
| yield f"{PINS_PATH} pins {pin.key}.{pin.field} but {COST_MAP_PATH} has no {pin.key} entry" | ||
| elif entries[pin.key].get(pin.field, _MISSING) != pin.value: | ||
| yield ( | ||
| f"{COST_MAP_PATH}: {pin.key}.{pin.field} must stay {json.dumps(pin.value)} " | ||
| f"(verified {pin.checked}: {pin.source}); change {PINS_PATH} with new evidence first" | ||
| ) | ||
|
|
||
|
|
||
| def pin_failures(pins_text: str, head_map: CostMap) -> tuple[str, ...]: | ||
| if not pins_text: | ||
| return (f"{PINS_PATH} is missing; restore it, its pins were verified against live provider calls",) | ||
|
greptile-apps[bot] marked this conversation as resolved.
Resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Low · Cost map PRs branched before this merge fail the guard with a misleading "pins file is missing" error
Smallest fix: report a missing pins file only when the merge-base snapshot has one ( Evidence
This conclusion comes from reading the code. I did not reproduce it against a live PR. Latest summary by code-review · View this review · Reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 126f0db, the pin checks now skip when neither the merge base nor the head has the pins file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finding withdrawn The reply is correct, and I verified it against the current code. Evidence
GitHub does not allow this App to resolve this thread. A repository maintainer must do it manually. Reviewed |
||
| parsed: Final = _parse_object(pins_text, PINS_PATH) | ||
| if isinstance(parsed, str): | ||
| return (parsed,) | ||
| return tuple(_pin_violations(parsed, _entries(head_map))) | ||
|
|
||
|
|
||
| def _bot_failures(base: Snapshot, head_map: CostMap, changed_files: Sequence[str]) -> tuple[str, ...]: | ||
| base_map: Final = _parse_object(base.cost_map, COST_MAP_PATH) | ||
| if isinstance(base_map, str): | ||
|
|
@@ -120,8 +192,18 @@ def _bot_failures(base: Snapshot, head_map: CostMap, changed_files: Sequence[str | |
| ) | ||
|
|
||
|
|
||
| def pin_author_failures(head_ref: str, author_type: str, changed_files: Sequence[str]) -> tuple[str, ...]: | ||
| if PINS_PATH not in changed_files: | ||
| return () | ||
| if head_ref.startswith(PRICE_SYNC_BRANCH_PREFIX): | ||
| return (f"price sync PRs may not change {PINS_PATH}; a pin moves only in a human PR with new evidence",) | ||
| if author_type == BOT_AUTHOR_TYPE: | ||
| return (f"PRs opened by a bot may not change {PINS_PATH}; a pin moves only in a human PR with new evidence",) | ||
| return () | ||
|
|
||
|
|
||
| def touches_cost_map(changed_files: Sequence[str]) -> bool: | ||
| return any(path in GUARDED_PATHS for path in changed_files) | ||
| return any(path in CHECKED_PATHS for path in changed_files) | ||
|
|
||
|
|
||
| def contract_for(bot: bool, changed_files: Sequence[str]) -> str: | ||
|
|
@@ -130,9 +212,21 @@ def contract_for(bot: bool, changed_files: Sequence[str]) -> str: | |
| return "human PR, file checks only" if touches_cost_map(changed_files) else "human PR, cost map untouched" | ||
|
|
||
|
|
||
| def _merged_pin_failures(base: Snapshot, merged: Snapshot | None) -> tuple[str, ...]: | ||
| if merged is None: | ||
| return ("the pull request does not merge cleanly into its base branch; merge the base branch in first",) | ||
| if not merged.pins and not base.pins: | ||
| return () | ||
| merged_map: Final = _parse_object(merged.cost_map, COST_MAP_PATH) | ||
| if isinstance(merged_map, str): | ||
| return (f"after merging into the base branch, {merged_map}",) | ||
| return pin_failures(merged.pins, merged_map) | ||
|
|
||
|
|
||
| def guard_failures( | ||
| base: Snapshot, | ||
| head: Snapshot, | ||
| merged: Snapshot | None, | ||
| changed_files: Sequence[str], | ||
| bot: bool, | ||
| *, | ||
|
|
@@ -147,6 +241,7 @@ def guard_failures( | |
| *_file_failures( | ||
| head, head_map, evaluation_output_price_sources=evaluation_output_price_sources | ||
| ), | ||
| *_merged_pin_failures(base, merged), | ||
| *(_bot_failures(base, head_map, changed_files) if bot else ()), | ||
| ) | ||
|
|
||
|
|
@@ -157,7 +252,22 @@ def _git(*args: str) -> str | None: | |
|
|
||
|
|
||
| def snapshot(revision: str) -> Snapshot: | ||
| return Snapshot(*(_git("show", f"{revision}:{path}") or "" for path in GUARDED_PATHS)) | ||
| return Snapshot(*(_git("show", f"{revision}:{path}") or "" for path in CHECKED_PATHS)) | ||
|
|
||
|
|
||
| def merged_tree(merge_base: str, target: str, head: str) -> str | MergeFailed | None: | ||
| result: Final = subprocess.run( | ||
| ("git", "merge-tree", "--write-tree", f"--merge-base={merge_base}", target, head), | ||
| check=False, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| tree: Final = result.stdout.split("\n", 1)[0] | ||
| if result.returncode == 0: | ||
| return tree | ||
| if result.returncode == MERGE_CONFLICT_EXIT_CODE and tree: | ||
| return None | ||
| return MergeFailed(result.stderr.strip()) | ||
|
|
||
|
|
||
| def changed_files(base: str, head: str) -> tuple[str, ...] | None: | ||
|
|
@@ -169,14 +279,33 @@ def main(argv: Sequence[str]) -> int: | |
| parser: Final = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument("--base", required=True, help="merge base of the pull request") | ||
| parser.add_argument("--head", required=True, help="head commit of the pull request") | ||
| env_target: Final = os.environ.get(TARGET_ENV) | ||
| parser.add_argument( | ||
| "--target", | ||
| default=env_target, | ||
| required=env_target is None, | ||
| help=f"tip of the base branch the pull request merges into, defaulting to ${TARGET_ENV}", | ||
| ) | ||
| parser.add_argument("--head-ref", required=True, help="head branch name of the pull request") | ||
| args: Final = parser.parse_args(argv) | ||
| bot: Final = args.head_ref.startswith(BOT_BRANCH_PREFIX) | ||
| changed: Final = changed_files(args.base, args.head) | ||
| if changed is None: | ||
| print(f"cost map guard failed: git diff {args.base} {args.head} failed, so the changed files are unknown") | ||
| return 1 | ||
| failures: Final = guard_failures(snapshot(args.base), snapshot(args.head), changed, bot) | ||
| if not bot and not touches_cost_map(changed): | ||
| print(f"cost map guard passed ({contract_for(bot, changed)})") | ||
| return 0 | ||
| merged: Final = merged_tree(args.base, args.target, args.head) | ||
| if isinstance(merged, MergeFailed): | ||
| print(f"cost map guard failed: git merge-tree into {args.target} failed: {merged.stderr}") | ||
| return 1 | ||
| failures: Final = ( | ||
| *guard_failures( | ||
| snapshot(args.base), snapshot(args.head), None if merged is None else snapshot(merged), changed, bot | ||
| ), | ||
| *pin_author_failures(args.head_ref, os.environ.get(AUTHOR_TYPE_ENV, ""), changed), | ||
| ) | ||
| contract: Final = contract_for(bot, changed) | ||
| if failures: | ||
| print(f"cost map guard failed ({contract}):") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "fireworks_ai/accounts/fireworks/models/minimax-m3": { | ||
| "supports_vision": { | ||
| "value": true, | ||
| "checked": "2026-09-26", | ||
| "source": "POST https://api.fireworks.ai/inference/v1/chat/completions read a 512x512 PNG back as digit=7, shape=circle, color=red while GET https://api.fireworks.ai/inference/v1/models still said supports_image_input false and GET https://api.fireworks.ai/v1/serverless/models?format=nested carried no supportsImageInput on the row" | ||
| } | ||
| }, | ||
| "fireworks_ai/minimax-m3": { | ||
| "supports_vision": { | ||
| "value": true, | ||
| "checked": "2026-09-26", | ||
| "source": "POST https://api.fireworks.ai/inference/v1/chat/completions read a 512x512 PNG back as digit=7, shape=circle, color=red while GET https://api.fireworks.ai/inference/v1/models still said supports_image_input false and GET https://api.fireworks.ai/v1/serverless/models?format=nested carried no supportsImageInput on the row" | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-runs replay the original workflow and base SHA, so this PR cannot change pre-merge runs. After 30 days their re-runs error out, noted in Caveats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that a rerun replays the original workflow and event context, including the original
pull_request.base.sha. That is precisely why the recheck does not protect an already-open PR whose earlier run predates pin enforcement:cost-map-pins-recheck.ymlcallsgh run rerun, and that run checks out the old base SHA incost-map-guard.yml:22, so it cannot pick up this PR's updated guard. The 30-day caveat covers when reruns stop being available; it doesn't address reruns that are available but still execute the old guard. To enforce the new pins on those PRs, the recheck needs to start a fresh evaluation using the updated guard/current base tip, rather than rerun the old run. GitHub documents reruns as using the originalGITHUB_SHA/GITHUB_REFand event context: rerunning workflows.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GITHUB_TOKEN events start no pull_request run, and a dispatched run reports on main's SHA, not the PR head. Only pre-merge runs replay, noted in Caveats
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. The recheck reruns existing PR guard runs, so those runs retain their original base SHA; a dispatch on
mainwould report againstmain, not the PR head, and a token-triggered event would not create a newpull_requestrun. The caveat already calls out that open PRs can keep a green pre-merge guard result. I shouldn’t have presented “start a fresh evaluation” as a straightforward fix; I’m withdrawing that concern as actionable feedback for this change.