From 9aa570446aa590442e835e8a9cf501d3fe4da3e9 Mon Sep 17 00:00:00 2001 From: qwen-code-dev-bot Date: Fri, 14 Aug 2026 15:16:47 +0000 Subject: [PATCH] fix(integration-tests): ack the daemon tool guard in the mock ACP child (#9160) (#9162) * fix(integration-tests): ack the daemon tool guard in the mock ACP child (#9160) * fix(integration-tests): scrub the guard provider marker in the mock ACP child (#9160) * fix(integration-tests): attach mock ACP child initialize _meta once (#9160) --------- Co-authored-by: qwen-code-autofix[bot] --- .../fixtures/mock-acp-child/agent.mjs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/integration-tests/fixtures/mock-acp-child/agent.mjs b/integration-tests/fixtures/mock-acp-child/agent.mjs index 53c86a0646..5e1ad0ee21 100644 --- a/integration-tests/fixtures/mock-acp-child/agent.mjs +++ b/integration-tests/fixtures/mock-acp-child/agent.mjs @@ -24,6 +24,12 @@ import { PROTOCOL_VERSION, RequestError, } from '@agentclientprotocol/sdk'; +import { + EXTERNAL_TOOL_GUARD_READY_META_KEY, + EXTERNAL_TOOL_GUARD_REQUIRED_VALUE, + PRIVATE_EXTERNAL_TOOL_GUARD_ENV, + PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV, +} from '@qwen-code/acp-bridge/externalToolGuard'; import { Writable, Readable } from 'node:stream'; // Protect the stdout NDJSON pipe — any console method that writes to @@ -40,14 +46,37 @@ const delayMs = parseInt(process.env.MOCK_ACP_PROMPT_DELAY_MS || '100', 10); const emitChunks = parseInt(process.env.MOCK_ACP_EMIT_CHUNKS || '3', 10); let sessionCounter = 0; +// Mirror the real child (acpAgent.ts): `qwen serve` requires the guard ack +// in the initialize response, and the markers are consumed + deleted before +// anything else can inherit them. +const externalToolGuardMarker = process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV]; +delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV]; +delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV]; +const externalToolGuardRequired = + externalToolGuardMarker === EXTERNAL_TOOL_GUARD_REQUIRED_VALUE; + new AgentSideConnection( (connection) => ({ async initialize() { + // Build ONE meta record and attach `_meta` once, exactly like the + // real child (acpAgent.ts), so a future conditional meta source + // merges instead of clobbering the guard ack via duplicate keys. + const responseMeta = { + ...(externalToolGuardRequired + ? { + [EXTERNAL_TOOL_GUARD_READY_META_KEY]: + EXTERNAL_TOOL_GUARD_REQUIRED_VALUE, + } + : {}), + }; return { protocolVersion: PROTOCOL_VERSION, agentInfo: { name: 'mock-acp', version: '0.0.1' }, authMethods: [], agentCapabilities: {}, + ...(Object.keys(responseMeta).length > 0 + ? { _meta: responseMeta } + : {}), }; },