| 1 | # Model Studio reasoning evidence — #5203 |
| 2 | |
| 3 | This record is deliberately credential-free. The validation process used an |
| 4 | environment-only `MODELSTUDIO_API_KEY`; no API key, workspace id, raw HTTP |
| 5 | authorization header, or full provider reasoning trace is committed here. |
| 6 | |
| 7 | ## Scope and result |
| 8 | |
| 9 | On 2026-08-04, a real Alibaba Cloud Model Studio **Token Plan Lite** request |
| 10 | using `qwen3.8-max` completed in the local CodeWhale TUI. The model's |
| 11 | `reasoning_content` rendered in the dedicated Thinking cell, and the final |
| 12 | answer remained a separate assistant message. |
| 13 | |
| 14 | The evidence below replaces the earlier terminal stills with three artifacts |
| 15 | from that validation: a 32.9-second local Terminal recording, the Model Studio |
| 16 | subscription page, and the Model Studio usage details for the same validation |
| 17 | window. None contains an API key. |
| 18 | |
| 19 | ## Live streaming recording |
| 20 | |
| 21 | [Download the local Terminal recording (MP4, 32.9 seconds)](modelstudio-token-plan-live-streaming-5203.mp4) |
| 22 | |
| 23 | The recording identifies the active provider as **Alibaba Cloud Model Studio** |
| 24 | and the model as **qwen3.8-max**. It begins in a dedicated `reasoning` state |
| 25 | with a separate `… reasoning hidden` marker, transitions to the `working` |
| 26 | response phase, streams the Redis cache-invalidation response, and ends with a |
| 27 | completed state. This is a direct macOS Terminal capture, not a GIF or a |
| 28 | synthetic replay. |
| 29 | |
| 30 | ## Model Studio account-side evidence |
| 31 | |
| 32 |  |
| 33 | |
| 34 | The subscription page shows that the Token Plan Lite subscription was active |
| 35 | and that the five-hour quota had recorded consumption after the validation. |
| 36 | |
| 37 |  |
| 38 | |
| 39 | The usage-details page records **17.6K total tokens** in the 14:00–15:00 |
| 40 | window: **14.2K uncached input tokens** and **3.4K output tokens**. This is |
| 41 | provider-side corroboration that the live validation reached Model Studio; it |
| 42 | does not expose request contents or credentials. |
| 43 | |
| 44 | ## Endpoint and wire-contract matrix |
| 45 | |
| 46 | | Route | OpenAI-compatible Base URL | Evidence in this change | Result | |
| 47 | | --- | --- | --- | --- | |
| 48 | | Token Plan | `https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1` | Live Token Plan Lite TUI recording + account-side usage evidence | Thinking displayed | |
| 49 | | Workspace-scoped Model Studio | `https://{workspace}.{region}.maas.aliyuncs.com/compatible-mode/v1` | Route regression test | Accepted only for the documented host/path shape | |
| 50 | | Coding Plan | `https://coding-intl.dashscope.aliyuncs.com/v1` | Route regression test | Primary `modelstudio-token-plan` identity plus `mode = "coding-plan"` receives the same reasoning contract | |
| 51 | | Anthropic Messages | `https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic` | Not changed by this PR | Separate Messages adapter; no claim of Chat-Completions coverage | |
| 52 | |
| 53 | The route guard is intentionally **fail-closed**: Alibaba-specific fields are |
| 54 | sent only on these official HTTPS Chat Completions URL shapes. A custom proxy |
| 55 | such as `https://proxy.example/v1` has those fields stripped so CodeWhale does |
| 56 | not impose a Model Studio dialect on an arbitrary OpenAI-compatible service. |
| 57 | |
| 58 | The Coding Plan row matters because the Model Studio picker keeps one primary |
| 59 | provider identity and selects Coding Plan with `mode = "coding-plan"`; config |
| 60 | changes the resolved Base URL without necessarily changing the provider enum. |
| 61 | The regression test covers that exact production path. |
| 62 | |
| 63 | ## Safe local configuration |
| 64 | |
| 65 | Use an environment variable, not a literal API key in a config file: |
| 66 | |
| 67 | ```toml |
| 68 | provider = "modelstudio-token-plan" |
| 69 | |
| 70 | [providers.modelstudio_token_plan] |
| 71 | api_key_env = "MODELSTUDIO_API_KEY" |
| 72 | base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1" |
| 73 | model = "qwen3.8-max" |
| 74 | ``` |
| 75 | |
| 76 | For direct Coding Plan configuration, select `provider = |
| 77 | "modelstudio-coding-plan"` and use `[providers.modelstudio_coding_plan]` with |
| 78 | the official Coding Plan Base URL. The picker also has an internal primary |
| 79 | provider + `mode = "coding-plan"` representation; its resolved Coding Plan |
| 80 | route is explicitly covered by the regression test. The API key must belong to |
| 81 | the plan being called; Token Plan Lite credentials prove the Token Plan row |
| 82 | only. |
| 83 | |
| 84 | ```toml |
| 85 | provider = "modelstudio-coding-plan" |
| 86 | |
| 87 | [providers.modelstudio_coding_plan] |
| 88 | api_key_env = "MODELSTUDIO_API_KEY" |
| 89 | base_url = "https://coding-intl.dashscope.aliyuncs.com/v1" |
| 90 | model = "qwen3.8-max" |
| 91 | ``` |
| 92 | |
| 93 | ## Request and streaming response shape |
| 94 | |
| 95 | Alibaba documents its OpenAI-compatible extensions as **top-level JSON request |
| 96 | fields** (not OpenAI SDK `extra_body` wrappers over raw HTTP): |
| 97 | |
| 98 | ```json |
| 99 | { |
| 100 | "model": "qwen3.7-plus", |
| 101 | "messages": [{"role": "user", "content": "..."}], |
| 102 | "stream": true, |
| 103 | "enable_thinking": true, |
| 104 | "preserve_thinking": true |
| 105 | } |
| 106 | ``` |
| 107 | |
| 108 | - Hybrid Qwen and similar models receive `enable_thinking: true` by default |
| 109 | and `false` when the user selects `off`. |
| 110 | - `qwen3.8-max` and `qwen3.8-max-preview` are thinking-only: CodeWhale does |
| 111 | **not** send an unsupported enable/disable control, but still treats their |
| 112 | reasoning stream as Thinking and replays it for later turns. |
| 113 | - `preserve_thinking` is sent only for Model Studio models documented to |
| 114 | support it (Qwen 3.7/3.6 families and Kimi Code variants). For Kimi K2.7 |
| 115 | Code, which is thinking-only, it stays enabled even if a stale `off` |
| 116 | preference is present. |
| 117 | - DeepSeek-V4 and GLM Model Studio routes additionally map CodeWhale effort |
| 118 | to the documented `reasoning_effort: "high" | "max"` values. |
| 119 | |
| 120 | The relevant server-sent event has a dedicated delta field: |
| 121 | |
| 122 | ```text |
| 123 | data: {"choices":[{"delta":{"reasoning_content":"…"}}]} |
| 124 | ``` |
| 125 | |
| 126 | This change classifies that field as a `ThinkingDelta` on the exact Model |
| 127 | Studio Chat routes. It does not append the private reasoning text to the final |
| 128 | assistant message. |
| 129 | |
| 130 | ## Regression evidence |
| 131 | |
| 132 | `cargo test -p codewhale-tui modelstudio_ --locked` covers: |
| 133 | |
| 134 | 1. `reasoning_content` → `ThinkingDelta` for Token Plan `qwen3.8-max`. |
| 135 | 2. Official Token Plan, workspace-scoped, and Coding Plan Chat route |
| 136 | recognition. |
| 137 | 3. Hybrid request controls, `off` behavior, DeepSeek-V4 effort mapping, and |
| 138 | custom-gateway fail closure. |
| 139 | 4. Thinking-only Qwen 3.8 and Kimi K2.7 Code replay/preservation behavior. |
| 140 | |
| 141 | ## Sources |
| 142 | |
| 143 | - [Alibaba Cloud: Qwen API via OpenAI-compatible Chat Completions](https://www.alibabacloud.com/help/en/model-studio/qwen-api-via-openai-chat-completions) |
| 144 | - [Alibaba Cloud: Deep thinking](https://www.alibabacloud.com/help/en/model-studio/deep-thinking) |
| 145 |