Skip to content

Commit ccce53b

Browse files
CL-8905: lock MCP promotion schema fidelity for optional and required arguments (#1181)
* test(mcp): preserve optional arguments through promotion * test(mcp): lock required and optional arguments through promotion * test(mcp): harden late-dispatch guards for loud failure and fidelity * test(mcp): restore omitted-optional lock and name unknown-tool
1 parent f3f9a69 commit ccce53b

2 files changed

Lines changed: 376 additions & 20 deletions

File tree

‎tests/integration/harness.ts‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ import type {
2727
ContextTransform,
2828
ContextStore,
2929
InferenceSource,
30+
ToolDefinition,
3031
} from "@intx/types/runtime";
3132
import { type } from "arktype";
3233

3334
import { createAgentWithLiveToolDispatch } from "../../src/agent/live-tool-dispatch.js";
34-
import { createChatDirector } from "../../src/agent/director.js";
35+
import {
36+
createChatDirector,
37+
type ChatDirector,
38+
} from "../../src/agent/director.js";
3539
import { OPERATOR_ORIGINATED_FLAG } from "../../src/agent/message-provenance.js";
3640
import {
3741
readSourceCredentialMaterial,
@@ -83,6 +87,7 @@ export interface IntegrationSession {
8387
workdir: string;
8488
agent: Agent;
8589
toolset: Awaited<ReturnType<typeof createAgentToolset>>;
90+
updateToolDefinitions: (definitions: ToolDefinition[]) => void;
8691
}
8792

8893
export interface OpenIntegrationSessionOpts {
@@ -121,6 +126,9 @@ export async function openIntegrationSession(
121126
const storageHolder: { current: ContextStore | undefined } = {
122127
current: undefined,
123128
};
129+
const directorHolder: { current: ChatDirector | undefined } = {
130+
current: undefined,
131+
};
124132

125133
const toolset = await createAgentToolset({
126134
cwd,
@@ -147,6 +155,7 @@ export async function openIntegrationSession(
147155
},
148156
);
149157
d.setClearDenials(() => opts.permissionGate.clearDenials());
158+
directorHolder.current = d;
150159
return d;
151160
},
152161
});
@@ -274,7 +283,22 @@ export async function openIntegrationSession(
274283
? innerAgent
275284
: createPrimaryDeliveryAdmission(innerAgent, primaryArchive);
276285

277-
return { harness, cwd, workdir, agent, toolset, storage: storageForAgent };
286+
const updateToolDefinitions = (definitions: ToolDefinition[]): void => {
287+
const director = directorHolder.current;
288+
if (director === undefined)
289+
throw new Error("chat director is not available");
290+
director.updateToolDefinitions(definitions);
291+
};
292+
293+
return {
294+
harness,
295+
cwd,
296+
workdir,
297+
agent,
298+
toolset,
299+
storage: storageForAgent,
300+
updateToolDefinitions,
301+
};
278302
}
279303

280304
export async function closeIntegrationSession(

0 commit comments

Comments
 (0)