qwen-code/packages
ChiGao 41bcdae7d8
Some checks are pending
Qwen Code CI / Classify PR (push) Waiting to run
Qwen Code CI / Lint (push) Blocked by required conditions
Qwen Code CI / Test (macos-latest, Node 22.x) (push) Blocked by required conditions
Qwen Code CI / Test (ubuntu-latest, Node 22.x) (push) Blocked by required conditions
Qwen Code CI / Test (windows-latest, Node 22.x) (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Blocked by required conditions
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
fix(core): refresh systemInstruction in setTools() so progressive MCP tools reach the model (#4166)
* fix(core): refresh systemInstruction in setTools() so progressive MCP tools reach the model

Under PR #3994's progressive MCP path, Config.initialize() runs
startChat() BEFORE MCP discovery starts, then kicks discovery off in the
background and re-runs setTools() once it settles. But setTools() only
updated chat.generationConfig.tools — not systemInstruction — and MCP
tools are shouldDefer=true, so they were filtered out of declarations
anyway. The prompt's "Deferred Tools" listing was frozen at the
built-in-only snapshot from the initial startChat(), and the model had
no signal that any MCP tool existed. Headless --prompt runs silently
regressed to built-ins (issue #4163); interactive mode had the same gap
but was masked by retries.

setTools() now rebuilds the system instruction with the up-to-date
deferred summary and re-binds it to the live chat. The eager-reveal
guard for "ToolSearch unavailable + deferred tools present" moves with
it so a freshly-arrived MCP tool in `--exclude-tools tool_search`
sessions still lands in declarations instead of disappearing silently.
Shared with startChat() / refreshSystemInstruction() via a new private
resolveDeferredToolsForSystemPrompt() helper so the three paths cannot
drift apart again.

The legacy synchronous path (QWEN_CODE_LEGACY_MCP_BLOCKING=1) was
incidentally correct because discovery happened before startChat(); it
remains correct.

Test plan:
- packages/core/src/core/client.test.ts — three new cases covering
  newly-arrived MCP tools, already-revealed filtering, and the
  no-ToolSearch eager-reveal path.
- Full client.test.ts (107 tests) green.
- tool-search / skill-manager / agent / mcp-client-manager / AppContainer
  test suites green (callers of setTools()).
- CI integration: integration-tests/cli/simple-mcp-server.test.ts is
  expected to pass on first try without QWEN_CODE_LEGACY_MCP_BLOCKING.

Fixes #4163

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* test(core): lock in SessionStart preservation across setTools refresh

Adds the regression test chiga0 asked for in the PR #4166 review:
proves that setTools()'s setSystemInstruction-then-reapply pattern keeps
the SessionStart hook's additionalContext intact, so progressive-MCP
refreshes (AppContainer batch flush + the trailing setTools after
waitForMcpReady) don't silently strip hook context from the system
instruction.

Generated by claude-opus-4-7

Co-authored-by: Claude <claude-opus-4-7@anthropic.com>

---------

Co-authored-by: 秦奇 <gary.gq@alibaba-inc.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Claude <claude-opus-4-7@anthropic.com>
2026-05-15 17:26:22 +08:00
..
channels chore(release): v0.15.11 [skip ci] 2026-05-14 09:51:46 +08:00
cli perf(cli): code-split lowlight to cut startup V8 parse cost (#4070) 2026-05-15 17:26:18 +08:00
core fix(core): refresh systemInstruction in setTools() so progressive MCP tools reach the model (#4166) 2026-05-15 17:26:22 +08:00
sdk-java fix(sdk-java): pass custom env to CLI process (#3543) 2026-04-24 10:37:52 +08:00
sdk-python doc[sdk-python] Expand Python SDK usage documentation (#3995) 2026-05-12 15:27:00 +08:00
sdk-typescript refactor(cli): revert dynamic slash command LLM translation (#4145) 2026-05-15 16:01:16 +08:00
vscode-ide-companion feat(hooks): add prompt hook type with LLM evaluation support (#3388) 2026-05-15 17:13:05 +08:00
web-templates chore(release): v0.15.11 [skip ci] 2026-05-14 09:51:46 +08:00
webui chore(release): v0.15.11 [skip ci] 2026-05-14 09:51:46 +08:00
zed-extension chore(deps): upgrade ink 6.2.3 → 7.0.2 + bump Node engine to 22 (#3860) 2026-05-11 17:29:50 +08:00