Skip to content

Commit 9aa5704

Browse files
qwen-code-dev-botqwen-code-autofix[bot]
andauthored
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] <qwen-code-autofix[bot]@users.noreply.github.com>
1 parent a669957 commit 9aa5704

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

  • integration-tests/fixtures/mock-acp-child

integration-tests/fixtures/mock-acp-child/agent.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ import {
2424
PROTOCOL_VERSION,
2525
RequestError,
2626
} from '@agentclientprotocol/sdk';
27+
import {
28+
EXTERNAL_TOOL_GUARD_READY_META_KEY,
29+
EXTERNAL_TOOL_GUARD_REQUIRED_VALUE,
30+
PRIVATE_EXTERNAL_TOOL_GUARD_ENV,
31+
PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV,
32+
} from '@qwen-code/acp-bridge/externalToolGuard';
2733
import { Writable, Readable } from 'node:stream';
2834

2935
// 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);
4046
const emitChunks = parseInt(process.env.MOCK_ACP_EMIT_CHUNKS || '3', 10);
4147
let sessionCounter = 0;
4248

49+
// Mirror the real child (acpAgent.ts): `qwen serve` requires the guard ack
50+
// in the initialize response, and the markers are consumed + deleted before
51+
// anything else can inherit them.
52+
const externalToolGuardMarker = process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV];
53+
delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_ENV];
54+
delete process.env[PRIVATE_EXTERNAL_TOOL_GUARD_PROVIDER_ENV];
55+
const externalToolGuardRequired =
56+
externalToolGuardMarker === EXTERNAL_TOOL_GUARD_REQUIRED_VALUE;
57+
4358
new AgentSideConnection(
4459
(connection) => ({
4560
async initialize() {
61+
// Build ONE meta record and attach `_meta` once, exactly like the
62+
// real child (acpAgent.ts), so a future conditional meta source
63+
// merges instead of clobbering the guard ack via duplicate keys.
64+
const responseMeta = {
65+
...(externalToolGuardRequired
66+
? {
67+
[EXTERNAL_TOOL_GUARD_READY_META_KEY]:
68+
EXTERNAL_TOOL_GUARD_REQUIRED_VALUE,
69+
}
70+
: {}),
71+
};
4672
return {
4773
protocolVersion: PROTOCOL_VERSION,
4874
agentInfo: { name: 'mock-acp', version: '0.0.1' },
4975
authMethods: [],
5076
agentCapabilities: {},
77+
...(Object.keys(responseMeta).length > 0
78+
? { _meta: responseMeta }
79+
: {}),
5180
};
5281
},
5382

0 commit comments

Comments
 (0)