Draft

Review a Checkable Python Fixture with Open Code Review and Qwen4-Max

  • Not yet verified
  • Versions not pinned
  • 17 min read

Task

What you will complete

Install the official Open Code Review CLI (ocr), point it at qwen4-max on a regular Beijing Model Studio key with 免费额度用完即停 / Free Quota Only turned on, review the original ploverfield_oven.py fixture, and compare the JSON report with a planted-issue checklist without trusting a fluent comment.

Success criteria

  • ocr is installed and aimed at qwen4-max on the workspace Beijing host, not at Token Plan or qwen4-max-preview.
  • A live ocr review of the Ploverfield fixture can be saved as review.json, with llm.model, token counts, and comments.
  • inspect_review.py is run against that file and reports whether any comment overlaps the planted line ranges, without editing the report to make the checklist look better. The contract checks in check_allot.py remain the source of truth for whether the bugs are in the file.

What this is not

Not a paid review-plan walkthrough, not a guaranteed finding list, and not a delegation path through another coding agent. The CLI itself has no documented seat fee; the model is what spends tokens. Skip this path if the code cannot be sent to a third-party model endpoint, if you only hold a Token Plan key for qwen4-max-preview, or if you wanted a test runner rather than a reviewer.

Prerequisites

  • A China-site (aliyun.com) Beijing Model Studio account with a remaining qwen4-max grant, and 免费额度用完即停 turned on for that model.
  • Node.js / npm, to install the official @alibaba-group/open-code-review package (command ocr).
  • Git 2.41 or newer. The CLI expects a git work tree; workspace mode will not review a loose folder.
  • The original fixture files shipped with this tutorial (ploverfield_oven.py, CONTRACT.md, check_allot.py, inspect_review.py, run_review.sh).

Environment

DASHSCOPE_API_KEY
Beijing Model Studio API key for the built-in dashscope provider
Host / base URL
https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1 (preferred over the preset https://dashscope.aliyuncs.com/compatible-mode/v1). Avoid the Token Plan host.

Open Code Review is Alibaba’s open-source review CLI. The CLI is not a paid review plan. The model you point it at is what spends tokens. This walkthrough installs the official ocr command, aims it at qwen4-max on Alibaba Cloud Model Studio in China (Beijing) / 华北2, stays on that model’s own 90-day 1,000,000-token grant, and reviews a small original allocator whose bugs you can check without trusting a fluent comment.

Decision What this page uses
Tool Open Code Review (ocr from @alibaba-group/open-code-review, Apache License 2.0)
Model qwen4-max on a regular Beijing Model Studio key, not qwen4-max-preview and not Token Plan
Host https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1
Spend That model’s 1,000,000-token Beijing grant only, with 免费额度用完即停 / Free Quota Only turned on
Job Review ploverfield_oven.py, then compare the JSON report with a planted-issue checklist

Official model, billing, and CLI pages were read on 2026-11-17 (Asia/Shanghai). Nobody at Actually Ran has installed ocr against a Beijing key, and nobody has captured a review report for this fixture. The local contract checks for the fixture were run. The ocr commands below are planned, not executed.

This review has not been run on a live Beijing key

The fixture and the inspector live next to this tutorial in examples/. python -m py_compile accepts the Python files, and bash -n accepts run_review.sh. check_allot.py was executed on 2026-11-17 (Asia/Shanghai). All seven contract checks failed on the stock fixture, which is what they were written to do. That run is not an Open Code Review report, and it is not a token count.

Where this page describes CLI flags, JSON fields, endpoints, or prices, it is repeating official documentation, not an observed review. When a live ocr review exists, this note should be replaced with the CLI version, the model ID returned in the JSON, the token summary, and the inspector output.

Does Open Code Review itself have a fee, or only the model?

The review tool is the open-source project alibaba/open-code-review, also documented from the homepage open-codereview.ai. The npm package is @alibaba-group/open-code-review. Both the repository and the package are licensed under Apache License 2.0. The license appendix names the copyright as “Copyright 2026 alibaba/open-code-review Contributors.” There is no NOTICE file in the repository root.

This page describes how to use that CLI, points at official pages, and ships an original fixture. It does not redistribute the CLI, its prompts, or its official sample programs. The Apache license allows this kind of use, including commercial documentation, as long as you do not treat the product name as a trademark license beyond describing the origin of the tool.

The README, configuration guide, FAQ, npm registry entry, and package manifest were checked on 2026-11-17. None of them describe a separate subscription, seat fee, or token meter for the CLI itself. Token use comes from the LLM endpoint you configure. Session logs stay under ~/.opencodereview/ on your machine. Official FAQ wording is that OCR sends your diffs, and any optional read-tool snippets, to that endpoint and that nothing else leaves the machine.

That is why this tutorial uses native ocr review, not delegation through another coding agent. Delegation would depend on whatever host-agent login or subscription you already have. You do not need a Cursor or Claude Code account for the path below. If you already use Codex, you can still call the same ocr binary from there; the commands on this page are the CLI itself.

Which host should you give the CLI — and which one should you avoid?

Use a regular Model Studio API key created on the Alibaba Cloud China site (aliyun.com), after 实名认证, in China (Beijing) / 华北2. Official new-user grant rules say free tokens exist only for Beijing models on the China site. Other regions do not get that grant.

Open Code Review ships a built-in provider named dashscope. Its preset Base URL, from the configuration docs and from internal/llm/providers.go on the project’s main branch, both fetched on 2026-11-17, is https://dashscope.aliyuncs.com/compatible-mode/v1. Official Model Studio compatibility docs still list that host as usable. The same pages recommend the workspace-specific Beijing host for better performance and stability:

https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1

This tutorial overrides the preset and uses the workspace host, with a Beijing key. Official compatibility docs, including the English page last updated 16 November 2026 and re-fetched on 2026-11-17, say a key is bound to the region where it was created. Calling another region’s endpoint with a Beijing key is rejected with HTTP 401, the message Incorrect API key provided, and the code invalid_api_key.

The English compatibility page still prints the Beijing workspace Base URL as https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1 in its endpoint tables. That is the Singapore region code. The same page’s Important note, and the Chinese page, both give Beijing as cn-beijing. If you copy the English table for a Beijing key, the official troubleshooting note is a 401.

Do not use the built-in dashscope-tokenplan provider for this walkthrough. Its preset Base URL is https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1. Official model pages list qwen4-max-preview as Token Plan only. The production ID qwen4-max is what carries the regular Beijing free grant. A Token Plan key, a preview model ID, or that token-plan host is a different product path, and it is not how this grant is documented to be spent.

The older DashScope host can still work with a China-site key. Prefer the workspace Beijing URL anyway, so the region in the hostname matches the key.

Why is qwen4-max missing from the DashScope model menu?

Because the suggested list has not caught up with the model card, not because the ID is invalid.

The built-in dashscope model list in internal/llm/providers.go on main, fetched on 2026-11-17, starts at qwen3.8-max and does not include qwen4-max. Official configuration docs say that list is a suggestion for ocr config model, not a restriction on --model or on a value you set with ocr config set model. A name that is not on that suggestion list is still accepted. Official configuration docs say OCR prints a warning on stderr and lets the provider accept or reject the ID when the request is sent. Set the model to qwen4-max anyway.

The latest npm tag on 2026-11-17 was 1.13.10, published 15 November 2026. This site has not unpacked that tarball, so treat the missing menu entry as confirmed in the public main tree, not as a byte-level audit of the exact package you install. After install, ocr version is the number to record.

Do not “fix” the missing menu item by switching to qwen3.8-max or to qwen4-max-preview. Those are different models and, in the preview case, a different access path.

How do you keep a review inside the 1,000,000-token grant?

The grant is real, but a review is not one short chat turn. Official CLI docs describe workspace review as grouping files, optionally planning, and then running one or more review rounds per group. Semantic grouping itself is documented as one extra, metadata-only model call. Default --effort is medium, which is two review rounds. low is one round; high is three. The official cost FAQ calls --effort low the largest single lever when you want a cheaper run.

qwen4-max also thinks by default. The China-site model page and the OpenAI-compatible Chat Completions guide, both re-read on 2026-11-17 (Asia/Shanghai), say that if you omit the thinking controls, the model uses reasoning_effort=high and thinking_budget=131072. Thinking tokens are billed as output, and they share this model’s grant with the visible answer. The same Chat Completions page says reasoning_effort=none turns thinking off, and that qwen4-max cannot be given reasoning_effort and thinking_budget on the same request.

Official OCR docs also cap a subtask’s output with MAX_COMPLETION_TOKENS at 16,384. That documented cap is far smaller than the model’s default thinking budget. This site has not watched a live review hit that cap, but the two numbers are a reason not to leave thinking at the default for a first grant-safe pass.

Do this before any review command that calls the model:

  1. In the Beijing console, confirm the qwen4-max grant is still visible. Official pricing and the new-user quota page give 1,000,000 tokens, input and output shared, valid for 90 days from the later of activating Model Studio, the model listing, or approval. The listing date for qwen4-max in 华北2 (Beijing) is 2026-11-16. Ninety days after that date is 2027-02-14 if your clock started on listing day. The date on the free-quota console wins.
  2. In the Beijing console, enable the per-model stop switch labeled 免费额度用完即停. The English documentation uses the name Free Quota Only. Official quota pages say the switch starts off. If you leave it off and the grant runs out, later calls are billed at the published Beijing list price for qwen4-max: CNY 10 per million input tokens and CNY 30 per million output tokens, with output counted as chain of thought plus the answer. If you enable the switch, a call after the grant is gone is documented to fail with HTTP 403 and the error code AllocationQuota.FreeTierOnly.
  3. Configure OCR with --effort low for this fixture.
  4. Set only providers.dashscope.extra_body to {"reasoning_effort":"none"}. Do not also set thinking_budget.
  5. Run ocr review --preview first. Official docs say preview runs the filter pipeline and skips the LLM.
  6. Optionally set --max-tokens-budget to a ceiling you are willing to spend from the grant. Official docs say the default is 0, which means unlimited, and that a run over the budget stops dispatching further subtasks after a final chance to submit findings. This page does not recommend a specific number, because no live review has been measured.

The fixture is one short Python file, so a preview should show a small review set. That still does not make the later token use knowable in advance.

What fixture should the report be checked against?

A fictional neighborhood bakehouse, Ploverfield Community Oven, needs to allot trays for one baking slot. The source is examples/ploverfield-community-oven/ploverfield_oven.py. It is original to this draft. It is not an official Open Code Review example.

The contract, also written in CONTRACT.md for the --background-file flag, is:

  • A slot holds at most 4 trays.
  • A booking is eligible only when requested_at is strictly earlier than cutoff. The cutoff instant is refused.
  • trays must be an integer >= 1. Zero is invalid.
  • Eligible bookings are considered in requested_at order, then by booking_id.
  • A booking is prepaid only when deposit_cents is exactly 150. 149 cents is not prepaid.
  • allot() returns a new list and does not mutate the input sequence.
  • If a booking’s tray count would pass capacity, refuse it; a later, smaller booking may still fit.

Seven local contract checks in check_allot.py were run on 2026-11-17 (Asia/Shanghai). All seven failed on the stock file:

Planted issue Lines in ploverfield_oven.py What the local check saw
149 cents is treated as prepaid 41–43 is_prepaid was true for 149 cents, and the booking was accepted
allot() shares a default accepted list 46–49 A second call still contained the first call’s booking
Bookings are sorted by name, and a list input is sorted in place 51–57 The later “Ada” booking won a full slot over an earlier “Zed” booking; the input list order changed
A booking at the cutoff instant is accepted 60–62 The cutoff booking was accepted
A zero-tray booking is not rejected 63–65 The zero-tray booking was accepted
Capacity is checked before adding trays 68–72 Bookings of 3 and 2 trays were both accepted, for a total of 5

Those failures are the checklist. They are not evidence that Open Code Review will mention every row. After you have a real review.json, examples/inspect_review.py only asks whether any comment overlaps those line ranges. A miss is about the report, not about whether the bug is still in the file.

How do you install the CLI and point it at Beijing qwen4-max?

Official quickstart docs ask for Git ≥ 2.41 and, for the npm install path, Node.js ≥ 18. The CLI is what talks to Model Studio, so you also need a Beijing key and a workspace ID from the China-site console.

The commands in this section are planned. This site has not run them.

Install the CLI, then pin or record the version you actually got:

npm install -g @alibaba-group/open-code-review
ocr version

As of the npm registry lookup on 2026-11-17, the latest tag was 1.13.10. Official install docs also describe a Homebrew formula, GitHub Release binaries, an install script, and building from source. In regions where GitHub is slow, the install script supports OCR_GITHUB_MIRROR. Official docs warn that in mirror mode both the binary and its checksum are fetched from the mirror, so the usual integrity check does not protect you. Prefer npm unless you have a reason not to.

Create a throwaway git repository around the fixture. Open Code Review’s default workspace mode reviews staged, unstaged, and untracked changes, and it will refuse to start outside a git repo:

mkdir -p /tmp/ploverfield-oven && cd /tmp/ploverfield-oven
git init
# Git ≥ 2.41 is required; this name is only to satisfy a fresh repo.
git commit --allow-empty -m "Start the Ploverfield fixture repo"
cp /path/to/examples/ploverfield-community-oven/ploverfield_oven.py .
cp /path/to/examples/ploverfield-community-oven/CONTRACT.md .
# Leave the file uncommitted if you want workspace mode to see it as a new file.

Point the built-in dashscope provider at your Beijing workspace host and at qwen4-max. Put the key in DASHSCOPE_API_KEY or in the provider field; do not commit it.

# Planned; not run.
ocr config set provider dashscope
ocr config set providers.dashscope.api_key "$DASHSCOPE_API_KEY"
ocr config set providers.dashscope.url \
  "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
ocr config set model qwen4-max
ocr config set providers.dashscope.extra_body '{"reasoning_effort":"none"}'
ocr config set effort low

Replace {WorkspaceId} with the workspace ID from the Beijing console. Official configuration docs say providers.<name>.url overrides the preset Base URL. The extra_body value is merged into every request. It sets only reasoning_effort. If a stderr warning says qwen4-max is not in the suggested model list, that matches the main tree described above. It is not, by itself, a failed config.

Then test the endpoint, preview the review set, and only after that spend grant tokens:

# Planned; not run.
ocr llm test
ocr review --preview --format json --audience agent
ocr review --effort low \
  --format json \
  --audience agent \
  --background-file CONTRACT.md \
  --output review.json \
  --provider dashscope \
  --model qwen4-max
python3 /path/to/examples/inspect_review.py review.json

--audience agent keeps progress lines off stdout so the file written by --output stays one JSON object. Official CLI docs also say that in JSON mode, human-audience progress goes to stderr. Either form is documented to be parseable on stdout.

A documented JSON object includes status, an llm object with at least model, a comments array, and, when the run reviewed files, a summary with files_reviewed, comments, total_tokens, input_tokens, output_tokens, and elapsed. Each comment is documented to carry path, content, start_line, end_line, and optional existing_code, suggestion_code, and thinking. This page does not fill those fields with a made-up report.

If no files were eligible, official docs describe a skipped object with an empty comments array. That is different from a completed review that found nothing. The inspector will still run, and every planted range will show as not mentioned.

How do you read the JSON without trusting a fluent comment?

Start with the local contract, not with the model’s wording. You already know the seven failures. inspect_review.py only checks line overlap. It does not score comment quality, and it will ignore comments whose start_line and end_line are both 0. Official FAQ material says those zero line numbers are a known failure mode.

Then read the comments it did match. A comment can sit on the right lines and still be wrong. The checklist is a location test, not a verdict on the explanation. If the report mentions the mutable default but misses the inclusive cutoff, that is useful information about the review, not a reason to delete the cutoff check from check_allot.py.

Watch the token summary in the same JSON. Official review output includes input_tokens and output_tokens when a summary is present. If thinking was not actually turned off, output tokens can dwarf the size of the comments. That would be a reason to inspect the request config before spending another grant slice, not a reason to raise --effort.

Do not paste the JSON, the API key, or the fixture from a private repo into a ticket or a chat until you have looked at it. Official FAQ text is that diffs go to the configured endpoint. This fixture is fictional and has no secrets. Real application code may.

What usually breaks on this path?

  • 401 with invalid_api_key. The host and the key are not in the same region. The English endpoint table that labels Beijing with ap-southeast-1 is the usual way to get here. Switch the URL to cn-beijing and use a Beijing key.
  • A warning that qwen4-max is not in the model list, followed by a provider error. The warning alone is expected on the main tree fetched for this page. A later provider error means the Beijing account cannot serve that ID — wrong key type, preview ID, or a typo — not that you should silently fall back to qwen3.8-max.
  • HTTP 403 with AllocationQuota.FreeTierOnly. Free Quota Only is doing what you turned it on for. The grant is exhausted or not present. Do not toggle it off to “just finish the review” unless you have decided to pay list price.
  • not a git repository. The CLI expects a git work tree. Workspace mode will not review a loose folder.
  • skipped JSON with no comments. Preview probably showed the file as excluded, untracked in a way the repo ignores, or outside the selected path. Fix the git state before spending tokens again.
  • Comments with start_line: 0. Official FAQ documents this. The inspector treats those as not overlapping any planted range.
  • A huge output-token count on a tiny file. Thinking may still be on. Confirm that extra_body contains only reasoning_effort set to none, and that you did not also send thinking_budget.
  • The review is much more expensive than one chat completion. Default effort is two rounds, and grouping or planning can add calls. --effort low and --preview are the documented ways to see the file set and cut rounds before you scale up.

When is this the wrong review setup?

Skip this path if you do not have a China-site Beijing Model Studio account, or if the qwen4-max grant on that account has already expired. Skip it if the code you want reviewed cannot be sent to a third-party model endpoint. Skip it if you needed a guaranteed finding list — this CLI is a reviewer, not a test runner, and the contract checks in check_allot.py are still the source of truth for this fixture.

Use a different setup if you already pay for a host-agent subscription and you wanted delegation mode, or if you only hold a Token Plan key for qwen4-max-preview. Those are documented paths. They are not this grant.

A large diff on high effort, with thinking left at the default, is a poor first experiment on a 1,000,000-token pool. Start with this fixture, or with another short, secret-free change, and read the token summary before you point ocr review at a real branch.

What a verified revision still has to capture

  • The installed ocr version and, if it differs from npm 1.13.10, whether qwen4-max is still missing from the suggested DashScope list.
  • The exact ocr llm test result on the workspace Beijing host, including any model-list warning.
  • A --preview JSON document for this fixture.
  • A live ocr review JSON saved as review.json, with llm.model, token counts, elapsed time, and comments.
  • The inspect_review.py output against that file, without editing the report to make the checklist look better.
  • Whether reasoning_effort=none in extra_body was accepted by the Beijing endpoint, and whether output tokens stayed in line with a non-thinking pass.
  • Whether Free Quota Only was on, and the remaining grant after the run, from the Beijing console.

Until those exist, this page stays unverified.

Files in this tutorial

  • examples/ploverfield-community-oven/ploverfield_oven.py — original fixture with planted issues
  • examples/ploverfield-community-oven/CONTRACT.md — review background for --background-file
  • examples/ploverfield-community-oven/check_allot.py — local contract checks (run on 2026-11-17; all seven failed, as designed)
  • examples/inspect_review.py — compares a real review.json to planted line ranges
  • examples/run_review.sh — planned preview and review commands; the model-calling lines are commented out

Sources

Official Open Code Review material, read on 2026-11-17 (Asia/Shanghai):

The project README links to https://open-codereview.ai/docs/.... Those documentation paths returned HTTP 404 when fetched as plain HTTP on 2026-11-17. The same text was read from the repository paths above.

Official Model Studio pages, also read on 2026-11-17 (Asia/Shanghai):

  • qwen4-max: model ID, Beijing list prices, default thinking settings, 1,000,000-token grant
  • 新人免费额度: Beijing-only grants, 90-day window, 用完即停 default, 403 / AllocationQuota.FreeTierOnly
  • 模型上架与更新: qwen4-max listed on 2026-11-16 in 华北2 (Beijing)
  • OpenAI 兼容 and the English compatibility page (English page last updated 16 November 2026): workspace Beijing host, DashScope host, 401 on a cross-region key, and the English table that still labels Beijing as ap-southeast-1
  • OpenAI Chat Completions: qwen4-max default reasoning_effort=high, none turns thinking off, and reasoning_effort must not be set with thinking_budget
  • 错误码 and 获取 API Key

These pages were read only to see how the topic already appears in search results. Their setup advice was not copied, and unverified claims about Coding Plan policy were not reused:

Earlier tutorials in this series cover a first tool-calling job, a hosted 27B call, Qwen Image 3.0 generation, a three-model quota comparison, switching an existing OpenAI client, image plus short-video understanding, and reasoning_effort on a yard invoice. This review fixture is self-contained and does not reuse those examples.


Title tag: Review a Checkable Python Fixture with Open Code Review and Qwen4-Max

Meta description: Use Alibaba’s Open Code Review CLI with qwen4-max on Beijing Model Studio’s 1,000,000-token grant. A small original fixture and a checklist; the review itself has not been run.

Slug: open-code-review-qwen4-max-ploverfield-fixture

Evidence it actually ran

This is the shape of the stamp. It has not been earned, and the example date that follows is a placeholder, not a run: Ran on YYYY-MM-DD (Asia/Shanghai) with the pinned versions.

Command output
None recorded. A verified revision will quote the output from the run, not a sample written in advance.
Tests, CI, or Inspector
Not run for this draft.
Repository or config
No link recorded.

Failure modes

Anticipated only. None of these has been checked against a run of this tutorial.

  • Unchecked

    401 with invalid_api_key

    The host and the key are not in the same region. The English endpoint table that labels Beijing with ap-southeast-1 is the usual way to get here. Switch the URL to cn-beijing and use a Beijing key.

  • Unchecked

    A warning that qwen4-max is not in the model list, followed by a provider error

    The warning alone is expected on the main tree fetched for this page. A later provider error means the Beijing account cannot serve that ID — wrong key type, preview ID, or a typo — not that you should silently fall back to qwen3.8-max.

  • Unchecked

    HTTP 403 with AllocationQuota.FreeTierOnly

    Free Quota Only is doing what you turned it on for. The grant is exhausted or not present. Do not toggle it off to "just finish the review" unless you have decided to pay list price.

  • Unchecked

    not a git repository

    The CLI expects a git work tree. Workspace mode will not review a loose folder.

  • Unchecked

    skipped JSON with no comments

    Preview probably showed the file as excluded, untracked in a way the repo ignores, or outside the selected path. Fix the git state before spending tokens again.

  • Unchecked

    Comments with start_line: 0

    Official FAQ documents this. The inspector treats those as not overlapping any planted range.

  • Unchecked

    A huge output-token count on a tiny file

    Thinking may still be on. Confirm that extra_body contains only reasoning_effort set to none, and that you did not also send thinking_budget.

  • Unchecked

    The review is much more expensive than one chat completion

    Default effort is two rounds, and grouping or planning can add calls. --effort low and --preview are the documented ways to see the file set and cut rounds before you scale up.

Other tutorials in Tasks.