mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 03:30:40 +00:00
* fix(cli): inject plan/subagent/arena system reminders in ACP (#1151) The ACP Session sends user messages via chat.sendMessageStream() directly, bypassing GeminiClient.sendMessageStream() where the CLI/TUI path injects its per-turn system reminders. As a result: - Plan mode is silently inert in ACP: the model never sees the reminder that tells it to avoid edits and call exit_plan_mode, so it tries to run edit tools and triggers the plan-mode block-check only as a fallback. - User-level subagents registered in the workspace are invisible to the model for the same reason. - Arena sessions started via the ACP path lose their session-dir context. Mirror the subagent / plan / arena branches from client.ts:848-878 in a new private helper #buildInitialSystemReminders, and prepend its output to the initial user-query message in #executePrompt as well as the cron path in #executeCronPrompt. The helper intentionally skips the managed auto-memory reminder — that one needs the GeminiClient prefetch pipeline and will be tackled as part of broader middleware alignment. Tests cover plan-mode on/off and non-builtin subagent filtering on the first-turn message fed into chat.sendMessageStream. * test(acp): add ensureTool + getSubagentManager to default mockConfig The system-reminder fix added an unconditional `config.getToolRegistry().ensureTool(ToolNames.AGENT)` call inside `#buildInitialSystemReminders`, which now runs on every `session.prompt()` and every cron fire. The new system-reminder tests stub `ensureTool` via their own `stubEmptySubagents` helper, but the default `mockToolRegistry` at the top of the file still only carries `getTool`. As a result all 13 pre-existing tests that exercise `session.prompt()` blow up with `TypeError: this.config.getToolRegistry(...).ensureTool is not a function`, and the cascaded `StopFailure` assertion fails because the test never reaches the assertion point. Move both `ensureTool` (on the tool registry) and `getSubagentManager` (on the config) into the default beforeEach mocks so every test that calls `session.prompt()` can traverse `#buildInitialSystemReminders` without the caller having to know about it. Defaulting `listSubagents` to an empty array is the harmless zero case — tests that care about subagent reminders already override it. The existing `stubEmptySubagents` helper still works unchanged (its explicit overrides take precedence over the defaults), so the new system-reminder tests in this PR keep expressing intent locally. * test(acp): update afterEach cast to match new mockToolRegistry type The previous commit added `ensureTool` to the `mockToolRegistry` declaration but left the `afterEach` reset casting to the old `{ getTool: ReturnType<typeof vi.fn> }` shape, which TS 5 now rejects under strict mode: error TS2741: Property 'ensureTool' is missing in type '{ getTool: Mock<Procedure>; }' but required in type '{ getTool: Mock<Procedure>; ensureTool: Mock<Procedure>; }'. Use `typeof mockToolRegistry` so the cast tracks the declaration automatically and future additions don't need a second edit. * test(acp): add getApprovalMode to default mockConfig The previous commits wired `#buildInitialSystemReminders` into every `session.prompt()` entry, which also reads `this.config.getApprovalMode()` to decide whether to prepend the plan-mode reminder. The default `mockConfig` never provided `getApprovalMode`, so the five pre-existing prompt-level tests that don't set it locally (passes resolved paths, runtime output dir context, UserPromptSubmit/Stop/StopFailure hooks) crash with `TypeError: this.config.getApprovalMode is not a function` on every platform + node version. Default to `ApprovalMode.DEFAULT` so tests that don't care about approval mode still traverse the helper. The ~10 tests that exercise plan/yolo/auto-edit already reassign `mockConfig.getApprovalMode` locally, and the reassignment wins over the default. |
||
|---|---|---|
| .. | ||
| channels | ||
| cli | ||
| core | ||
| sdk-java | ||
| sdk-typescript | ||
| vscode-ide-companion | ||
| web-templates | ||
| webui | ||
| zed-extension | ||