Skip to content

Commit 3b7993e

Browse files
Merge pull request #126 from modelstudioai/fix/web-search-and-thinking
fix(mcp,text): MCP activation hints and fix error caused by enable_thinking
2 parents 81fa5b5 + be6ddb6 commit 3b7993e

21 files changed

Lines changed: 299 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
66

77
[中文版](CHANGELOG.zh.md) · [README](README.md) · [Contributing](CONTRIBUTING.md)
88

9+
## [1.11.2] - 2026-07-28
10+
11+
### Changed
12+
13+
- MCP tools and WebSearch now provide activation guidance and direct marketplace links when Bailian reports that the corresponding service is not activated. WebSearch also guides users with legacy SSE connections to reactivate the service using Streamable HTTP.
14+
15+
### Fixed
16+
17+
- Fixed text chat and API Key validation compatibility failures caused by sending unsupported `enable_thinking` values. Text chat now sends the parameter only when thinking is explicitly enabled, while validation uses a compatible model without sending it.
18+
919
## [1.11.1] - 2026-07-28
1020

1121
### Added

CHANGELOG.zh.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66

77
[English](CHANGELOG.md) · [README](README.zh.md) · [参与贡献](CONTRIBUTING.zh.md)
88

9+
## [1.11.2] - 2026-07-28
10+
11+
### 变更
12+
13+
- MCP 工具或 WebSearch 因对应服务未开通而不可用时,CLI 现在会提供开通指引和市场直达链接;对于使用旧版 SSE 连接的 WebSearch,还会提示重新开通以切换至 Streamable HTTP。
14+
15+
### 修复
16+
17+
- 修复文本对话与 API Key 登录校验因传递不受支持的 `enable_thinking` 参数值而产生的兼容性错误。文本对话仅在用户明确开启思考模式时传递该参数,登录校验则改用兼容模型且不再传递该参数。
18+
919
## [1.11.1] - 2026-07-28
1020

1121
### 新增

docs/agents/url-change.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ runtime/src/urls.ts ← 用户面控制台 URL(cn-only)
2020
BAILIAN_CONSOLE BAILIAN_CONSOLE_ROOT/cn-beijing
2121
API_KEY_PAGE BAILIAN_CONSOLE/?tab=app#/api-key
2222
TOKEN_PLAN_PAGE BAILIAN_CONSOLE_ROOT/cn-beijing?tab=plan#/efm/subscription/overview
23+
MCP_WEBSEARCH_PAGE mcpMarketplaceDetailPage("WebSearch")
24+
mcpMarketplaceDetailPage BAILIAN_CONSOLE?tab=mcp#/mcp-market/detail/<serverCode>
2325
2426
core/files/upload.ts ← 文件上传 endpoint(cn-pinned)
2527
UPLOAD_API ${REGIONS.cn}/api/v1/uploads

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-cli",
3-
"version": "1.11.1",
3+
"version": "1.11.2",
44
"description": "CLI for Aliyun Model Studio (DashScope) AI Platform.",
55
"keywords": [
66
"agent",

packages/commands/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bailian-cli-commands",
3-
"version": "1.11.1",
3+
"version": "1.11.2",
44
"description": "Command library for bailian-cli products (knowledge, memory, media, …). See https://www.npmjs.com/package/bailian-cli for usage.",
55
"homepage": "https://bailian.console.aliyun.com/cli",
66
"bugs": {

packages/commands/src/commands/auth/login-api-key.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export async function validateAndPersistApiKey(
5757
const persistBaseUrl = profile.persistBaseUrl
5858
? normalizeModelBaseUrl(profile.persistBaseUrl)
5959
: undefined;
60-
const validationModel = profile.defaultTextModel || "qwen3.7-max";
60+
const validationModel = "qwen3.7-max";
6161
const requestOpts = {
6262
url: baseUrl + chatPath(),
6363
method: "POST",
@@ -68,7 +68,6 @@ export async function validateAndPersistApiKey(
6868
messages: [{ role: "user", content: "hi" }],
6969
max_tokens: 1,
7070
stream: false,
71-
enable_thinking: validationModel === "qwen3.8-max-preview",
7271
},
7372
};
7473

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { BailianError } from "bailian-cli-core";
2+
import { mcpMarketplaceDetailPage } from "bailian-cli-runtime";
3+
4+
/** Detect MCP-not-activated / invalid 404 errors (CLI-wrapped server message). */
5+
export function isMcpNotActivated(error: unknown): boolean {
6+
if (!(error instanceof BailianError)) return false;
7+
const message = error.message;
8+
if (!/MCP request failed:\s*404\b/i.test(message)) return false;
9+
return /|MCP|MCP_IS_INVALID/i.test(message);
10+
}
11+
12+
/** Activation hint; URL from runtime/urls.ts. */
13+
export function mcpActivateHint(serverCode: string): string {
14+
const lines = [
15+
`Activate (or re-activate) the ${serverCode} MCP in the Bailian MCP marketplace, then retry.`,
16+
];
17+
if (serverCode === "WebSearch") {
18+
lines.push(
19+
"If it was previously on SSE, cancel and activate again to upgrade to Streamable HTTP.",
20+
);
21+
}
22+
lines.push(`Open: ${mcpMarketplaceDetailPage(serverCode)}`);
23+
return lines.join("\n");
24+
}
25+
26+
/**
27+
* For not-activated errors, keep the original message / exitCode and append a hint only.
28+
* Do not replace the server error message.
29+
*/
30+
export function rethrowWithMcpActivateHint(error: unknown, serverCode: string): never {
31+
if (isMcpNotActivated(error) && error instanceof BailianError && !error.hint) {
32+
throw new BailianError(error.message, error.exitCode, mcpActivateHint(serverCode), {
33+
cause: error,
34+
api: error.api,
35+
rawResponse: error.rawResponse,
36+
});
37+
}
38+
throw error;
39+
}

packages/commands/src/commands/mcp/call.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type ParsedFlags,
99
} from "bailian-cli-core";
1010
import { emitResult } from "bailian-cli-runtime";
11+
import { rethrowWithMcpActivateHint } from "./activate-hint.ts";
1112

1213
const CALL_FLAGS = {
1314
target: {
@@ -130,14 +131,21 @@ export default defineCommand({
130131
}
131132

132133
const client = ctx.client.mcp(url);
133-
await client.initialize();
134-
const result = await client.callTool(toolName, toolArgs);
134+
try {
135+
await client.initialize();
136+
const result = await client.callTool(toolName, toolArgs);
135137

136-
if (result.isError) {
137-
const errText = result.content.map((c) => c.text || "").join("\n");
138-
throw new BailianError(`Tool error: ${errText}`);
139-
}
138+
if (result.isError) {
139+
const errText = result.content.map((c) => c.text || "").join("\n");
140+
throw new BailianError(`Tool error: ${errText}`);
141+
}
140142

141-
emitResult(result, format);
143+
emitResult(result, format);
144+
} catch (error) {
145+
if (!flags.url) {
146+
rethrowWithMcpActivateHint(error, serverCode);
147+
}
148+
throw error;
149+
}
142150
},
143151
});

packages/commands/src/commands/mcp/tools.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineCommand, bailianMcpPath, detectOutputFormat } from "bailian-cli-core";
22
import { emitResult } from "bailian-cli-runtime";
3+
import { rethrowWithMcpActivateHint } from "./activate-hint.ts";
34

45
export default defineCommand({
56
description: "List tools exposed by an MCP server (tools/list)",
@@ -36,8 +37,15 @@ export default defineCommand({
3637
}
3738

3839
const client = ctx.client.mcp(url);
39-
await client.initialize();
40-
const tools = await client.listTools();
41-
emitResult({ server: code, url, tools }, format);
40+
try {
41+
await client.initialize();
42+
const tools = await client.listTools();
43+
emitResult({ server: code, url, tools }, format);
44+
} catch (error) {
45+
if (!flags.url) {
46+
rethrowWithMcpActivateHint(error, code);
47+
}
48+
throw error;
49+
}
4250
},
4351
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
isMcpNotActivated,
3+
mcpActivateHint,
4+
rethrowWithMcpActivateHint,
5+
} from "../mcp/activate-hint.ts";
6+
7+
/** Detect WebSearch MCP not-activated / invalid 404 errors. */
8+
export const isWebSearchMcpNotActivated = isMcpNotActivated;
9+
10+
/** WebSearch activation hint. */
11+
export function webSearchActivateHint(): string {
12+
return mcpActivateHint("WebSearch");
13+
}
14+
15+
/** Keep the original message; append a hint for WebSearch not-activated errors. */
16+
export function rethrowWithWebSearchActivateHint(error: unknown): never {
17+
rethrowWithMcpActivateHint(error, "WebSearch");
18+
}

0 commit comments

Comments
 (0)