Skip to content

fix: allow bailian provider in resolveThinkingProfile#96819

Open
andreacasini wants to merge 1 commit into
openclaw:mainfrom
andreacasini:fix/bailian-thinking-provider
Open

fix: allow bailian provider in resolveThinkingProfile#96819
andreacasini wants to merge 1 commit into
openclaw:mainfrom
andreacasini:fix/bailian-thinking-provider

Conversation

@andreacasini

@andreacasini andreacasini commented Jun 25, 2026

Copy link
Copy Markdown

What Problem This Solves

The configured-model reasoning inference checks hardcode provider === "vllm", excluding bailian (Alibaba Cloud Coding Plan) even when compat.thinkingFormat is correctly configured. This prevents Bailian-hosted Qwen/GLM models from being recognized as reasoning-capable, breaking /thinking commands and reasoning token tracking.

Root Cause

Two locations check for vllm provider without considering that other providers (like bailian) may also serve Qwen-format models:

  1. src/agents/model-selection-shared.tsisVllmQwenThinkingCompat()
  2. src/agents/embedded-agent-runner/model.tsreadCompatThinkingFormat()

Fix

Extend each check to accept both vllm and bailian providers.

Note: The original PR also modified extensions/vllm/thinking-policy.ts, but this was reverted because production resolves thinking policy by provider ownership/manifest — the vLLM manifest owns only vllm, so bailian never loads this path. The change was dead code in production.

Verified Configurations

Tested with Bailian provider using both thinking formats:

Model thinkingFormat Status
qwen3.7-plus openai ✅ working
qwen3.6-plus qwen ✅ working
qwen3-max-2026-01-23 openai ✅ working
glm-5 openai ✅ working

Evidence

Gateway logs showing thinking recognized:

agent model: bailian/qwen3.6-plus (thinking=medium, fast=off)
agent model: bailian/qwen3.7-plus (thinking=medium, fast=off)

Session transcript showing thinking payloads received:

{
  "role": "assistant",
  "content": [
    {
      "type": "thinking",
      "thinking": "The user wants me to run a cleanup script...",
      "thinkingSignature": "reasoning_content"
    },
    {
      "type": "text",
      "text": "🎩 **Session cleanup complete**..."
    }
  ],
  "usage": {
    "input": 4258,
    "output": 2240,
    "reasoningTokens": 1662,
    "totalTokens": 42594
  }
}

Provider config (redacted):

{
  "baseUrl": "https://coding-intl.dashscope.aliyuncs.com/v1",
  "api": "openai-completions",
  "models": [
    {
      "id": "qwen3.7-plus",
      "reasoning": true,
      "compat": {
        "thinkingFormat": "openai",
        "supportsUsageInStreaming": true
      }
    },
    {
      "id": "qwen3.6-plus",
      "reasoning": true,
      "compat": {
        "thinkingFormat": "qwen",
        "supportsUsageInStreaming": true
      }
    }
  ]
}

Scope

This PR fixes the custom provider bailian path. The broader Coding Plan bundled catalog work (where models are marked non-reasoning in the bundled catalog) remains tracked in #26037.

Closes #26037

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: vllm size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 19, 2026, 6:14 AM ET / 10:14 UTC.

Summary
The branch changes two configured-model reasoning inference checks so explicitly configured bailian models with Qwen thinking formats are handled like vllm models.

PR surface: Source +1. Total +1 across 2 files.

Reproducibility: no. reviewer-established current-main run is available, but the source-level gate and the contributor’s redacted after-fix gateway/session transcript give a concrete, medium-confidence reproduction path for explicitly configured bailian Qwen-format models.

Review metrics: none identified.

Root-cause cluster
Relationship: partial_overlap
Canonical: #26037
Summary: This PR targets the custom configured-provider inference subset of the broader Bailian reasoning request; it does not implement the official catalog and onboarding scope still tracked there.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Confirm the intended narrow bailian compatibility contract and retain the broader official-provider issue as non-closing context.

Risk before merge

  • [P1] Merging changes behavior for existing custom bailian rows that explicitly opt into a Qwen thinking format; that is likely desired, but maintainers should confirm this is a supported narrow custom-provider contract rather than implicitly closing the broader official-provider/onboarding request.

Maintainer options:

  1. Confirm narrow support and preserve issue scope (recommended)
    Approve the bailian exception for explicit Qwen compatibility rows, but change the broader issue reference to non-closing context before merge.
  2. Adopt a provider-neutral rule instead
    If explicit provider-name allowlists are not the intended contract, pause this PR and design a generic compatibility inference path with tests for the supported backends.

Next step before merge

  • [P2] A maintainer must select the permanent custom-provider support boundary and ensure the broader linked issue is not closed by this narrower fix.

Maintainer decision needed

  • Question: Should core explicitly treat custom provider ID bailian as Qwen-thinking-compatible when its model row opts into compat.thinkingFormat, while leaving official Bailian catalog and onboarding work outside this PR?
  • Rationale: The implementation is narrow and has real-run evidence, but the linked issue requests broader first-class provider support, so only maintainers can define whether this core allowlist is the intended long-term support boundary.
  • Likely owner: indulgeback — They introduced the prior merged configured-Qwen compatibility surface most directly related to this boundary.
  • Options:
    • Approve the narrow custom-provider contract (recommended): Keep the two inference changes, update the issue reference to non-closing context, and leave official catalog/onboarding scope in the linked issue.
    • Keep inference provider-neutral: Replace the explicit provider allowlist with a generic configured-model compatibility rule only if maintainers want every explicitly opted-in OpenAI-compatible Qwen backend to receive this behavior.

Security
Cleared: The two-line provider compatibility change adds no dependency, secret, network, permission, or code-execution mechanism.

Review details

Best possible solution:

Confirm bailian as an explicit supported custom-provider exception for configured Qwen thinking formats, merge the two-path fix if approved, and retain the broader catalog/onboarding work in #26037.

Do we have a high-confidence way to reproduce the issue?

No reviewer-established current-main run is available, but the source-level gate and the contributor’s redacted after-fix gateway/session transcript give a concrete, medium-confidence reproduction path for explicitly configured bailian Qwen-format models.

Is this the best way to solve the issue?

Unclear until maintainers choose the supported boundary: the two matching changes are the smallest fix for a narrow bailian exception, while a provider-neutral rule would be safer only if that broader contract is intentional.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8178b3cc140d.

Label changes

Label changes:

  • remove merge-risk: 🚨 other: Current PR review merge-risk labels are merge-risk: 🚨 compatibility, merge-risk: 🚨 auth-provider.

Label justifications:

  • P2: This corrects reasoning handling for explicitly configured Bailian models without evidence of an emergency-wide runtime outage.
  • merge-risk: 🚨 compatibility: Existing custom bailian configurations that opt into Qwen formats will begin receiving the corresponding thinking-mode behavior after upgrade.
  • merge-risk: 🚨 auth-provider: The provider-ID gate participates in model/provider capability resolution for configured Bailian credentials and models.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body and follow-up comment provide redacted live gateway and session output showing bailian receives custom thinking policy and produces a thinking block after the fix.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body and follow-up comment provide redacted live gateway and session output showing bailian receives custom thinking policy and produces a thinking block after the fix.
Evidence reviewed

PR surface:

Source +1. Total +1 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 2 +1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 3 2 +1

What I checked:

  • Current-main gap: The base behavior checks only vllm before inferring Qwen-format thinking compatibility; the PR adds bailian at both relevant configured-model resolution paths. (src/agents/embedded-agent-runner/model.compat.ts:71, 8178b3cc140d)
  • Paired runtime path: The same provider gate exists in the shared model-selection path, so changing only one site would leave CLI/runtime selection behavior inconsistent. (src/agents/model-selection-shared.ts:1441, 8178b3cc140d)
  • Branch implementation: The proposed head applies the same narrow bailian allowance in both paths and does not retain the earlier vLLM-extension change that the discussion identified as unreachable for this provider. (src/agents/embedded-agent-runner/model.compat.ts:71, f0d0cb18bc22)
  • Existing compatibility foundation: Merged commit c91fffd added the generic configured-model qwen and qwen-chat-template compatibility formats; this PR addresses the remaining provider inference gate rather than adding a new config shape. (src/agents/model-selection-shared.ts:1441, c91fffdd67d6)
  • Real behavior proof: The contributor supplied redacted gateway output showing provider=bailian with policy=custom plus a resulting assistant thinking block after removing reasoning: true from the tested model row. (f0d0cb18bc22)
  • Related-provider boundary: The discussion explains that merged Token Plan support uses the Qwen plugin’s separate provider stream wrapper, so this branch is complementary custom-provider behavior rather than a replacement for that implementation. (ae11ea5ba9a0)

Likely related people:

  • indulgeback: The merged Qwen thinking-format work established the configured-model compatibility contract that this PR extends at its remaining provider gate. (role: introduced the merged configured-Qwen compatibility surface; confidence: high; commits: c91fffdd67d6; files: src/agents/model-selection-shared.ts, src/agents/embedded-agent-runner/model.compat.ts)
  • oliver-mee: Recent merged Qwen Token Plan work and the PR discussion distinguish its plugin-owned thinking stream from this custom-provider core path. (role: adjacent provider-runtime contributor; confidence: medium; commits: ae11ea5ba9a0; files: extensions/qwen/, src/agents/embedded-agent-runner/model.compat.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-06-26T07:27:24.026Z sha 89acc09 :: needs real behavior proof before merge. :: [P2] Remove Bailian from the vLLM policy gate
  • reviewed 2026-07-09T23:14:16.768Z sha 6de60ac :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 25, 2026
@oliver-mee

Copy link
Copy Markdown
Contributor

Useful fix. One data point that might help scope it: the bundled qwen-token-plan provider being added in #94419 does not go through resolveThinkingProfile for its thinking at all. It rides the qwen plugin's own wrapQwenProviderStream (gated by isQwenProviderId), so its Alibaba-hosted Qwen/GLM/Kimi models get reasoning handling without touching the provider === "vllm" checks this PR widens.

So this looks complementary rather than overlapping: your change fixes the generic user-configured bailian provider path, and the bundled provider covers the Token Plan path through a different route. Flagging it so the two do not get treated as competing.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 26, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jun 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@andreacasini thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@andreacasini

Copy link
Copy Markdown
Author

Proof: Bailian provider generates thinking blocks without reasoning: true

As requested by ClawSweeper, here is the proof that the bailian provider (Alibaba Cloud Coding Plan) generates thinking blocks purely through the code changes in this PR — without relying on reasoning: true in the model config.

Test Setup

  1. Removed reasoning: true from the bailian qwen3.6-plus model config in openclaw.json
  2. Restarted the gateway to pick up the config change
  3. Spawned a subagent with model=bailian/qwen3.6-plus and thinking=low

Evidence 1: Gateway Log (redacted)

2026-07-09T20:53:31.830+00:00 [provider-transport-fetch] |
[model-fetch] start provider=bailian api=openai-completions model=qwen3.6-plus
method=POST url=https://coding-intl.dashscope.aliyuncs.com/v1/chat/completions
timeoutMs=500000 proxy=none policy=custom

Key: policy=custom — without this PR's changes, resolveThinkingProfile returns null for non-vllm providers, so no custom thinking policy would be applied. The fact that policy=custom appears proves the code path in model-selection-shared.ts and embedded-agent-runner/model.ts correctly recognizes bailian as a reasoning-capable provider.

Evidence 2: Subagent Session Transcript

{
  "role": "assistant",
  "content": [
    {
      "type": "thinking",
      "thinking": "This is a simple test task. I just need to reply with a greeting message."
    },
    {
      "type": "text",
      "text": "Hello, test message for bailian reasoning proof."
    }
  ],
  "api": "openai-completions",
  "provider": "bailian",
  "model": "qwen3.6-plus",
  "stopReason": "stop"
}

The "type": "thinking" block was generated by the model — proving that the bailian provider supports reasoning output when the thinking profile is correctly resolved.

Evidence 3: Model Config Used for Test (no reasoning: true)

{
  "id": "qwen3.6-plus",
  "name": "qwen3.6-plus",
  "input": ["text", "image"],
  "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0},
  "contextWindow": 1000000,
  "maxTokens": 65536,
  "compat": {
    "thinkingFormat": "qwen",
    "supportsUsageInStreaming": true
  },
  "api": "openai-completions"
}

Note: NO reasoning: true field — the model was recognized as reasoning-capable purely through the PR's code changes in isVllmQwenThinkingCompat().

PR Changes (after ClawSweeper feedback)

  • thinking-policy.ts change reverted — that code path is dead in production (bailian doesn't go through the vllm extension)
  • bailian-thinking-provider.test.ts removed — tests were targeting the wrong code path
  • ✅ Only 2 files changed: model-selection-shared.ts and embedded-agent-runner/model.ts — both replace === "vllm" with (=== "vllm" || === "bailian")

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 9, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jul 9, 2026
The thinking policy resolver only checked for 'vllm' provider,
excluding 'bailian' (Alibaba Cloud) even when thinkingFormat was
correctly set in compat. This prevented Bailian/Qwen models from
using reasoning/thinking features.

Adds bailian to isVllmQwenThinkingCompat in both:
- src/agents/embedded-agent-runner/model.compat.ts
- src/agents/model-selection-shared.ts

Fixes openclaw#26037
@andreacasini
andreacasini force-pushed the fix/bailian-thinking-provider branch from 6de60ac to f0d0cb1 Compare July 19, 2026 10:09
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Ali bailian coding plan support ( thinking/reasoning enabled )

2 participants