Skip to content

Commit e651b1d

Browse files
committed
fix(tools): commit director tool activations onto the infer wire
LSP/onToolsActivate was only calling activate() so those names stayed off the provider tools array too.
1 parent 05522d2 commit e651b1d

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

‎src/exec/runner.ts‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -903,20 +903,21 @@ export async function runExec(config: Config): Promise<ExecResult> {
903903
// refuses MCP/present/plugin names the result just told the model to
904904
// invoke. Under a closed overlay the promoter only activates allowed
905905
// names, so outside-allow tools can never become advertised or callable.
906+
const commitPromotedWire = (): void => {
907+
if (flushPromotions()) {
908+
directorHolder.instance?.updateToolDefinitions(
909+
computeAdvertised(agentToolset.dynamicRunner.currentDefinitions()),
910+
);
911+
}
912+
};
906913
agentToolset.setToolPromoter(
907914
createExecToolPromoter({
908915
activate: (names) => activatedToolNames.activate(names),
909916
isAllowed: (name) => isExecOverlayToolAllowed(overlay, name),
910917
persist: () => {
911918
void persist("running");
912919
},
913-
commitWire: () => {
914-
if (flushPromotions()) {
915-
directorHolder.instance?.updateToolDefinitions(
916-
computeAdvertised(agentToolset.dynamicRunner.currentDefinitions()),
917-
);
918-
}
919-
},
920+
commitWire: commitPromotedWire,
920921
}),
921922
);
922923

@@ -1010,7 +1011,10 @@ export async function runExec(config: Config): Promise<ExecResult> {
10101011
tasks: tasks.map((t) => `${t.status}:${t.title}`).join(", "),
10111012
});
10121013
},
1013-
onToolsActivate: (names) => activatedToolNames.activate(names),
1014+
onToolsActivate: (names) => {
1015+
if (!activatedToolNames.activate(names)) return;
1016+
commitPromotedWire();
1017+
},
10141018
},
10151019
(message, fields) => logger.debug(message, fields),
10161020
);

‎src/tui/runner/exit.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ export async function createRunLifecycle(
277277
}> {
278278
const { persistRunSnapshot } = createRunPersistence(state, services);
279279
state.persistRunSnapshot = persistRunSnapshot;
280+
const activateAndCommitWire = (names: string[]): void => {
281+
if (!services.activatedToolNames.activate(names)) return;
282+
if (services.flushPromotions()) {
283+
services.directorHolder.instance?.updateToolDefinitions(
284+
services.computeAdvertised(
285+
services.toolset.dynamicRunner.currentDefinitions(),
286+
),
287+
);
288+
}
289+
void persistRunSnapshot("running");
290+
};
280291
const stopHeartbeat = startRunHeartbeat({
281292
shouldTick: () => !services.crashGuard.isFinalized(),
282293
tick: () => persistRunSnapshot("running"),
@@ -340,7 +351,7 @@ export async function createRunLifecycle(
340351
event,
341352
{
342353
onTasksChanged: (tasks) => services.emitter.emit("tasks", tasks),
343-
onToolsActivate: (names) => services.activatedToolNames.activate(names),
354+
onToolsActivate: (names) => activateAndCommitWire(names),
344355
},
345356
(message, fields) => tuiLogger.debug(message, fields),
346357
);
@@ -412,18 +423,7 @@ export async function createRunLifecycle(
412423
// could not emit those calls. Cache prefix growth on discovery is the cost
413424
// of making promotion actually work.
414425
const promoteTools = (names: string[]): void => {
415-
if (!services.activatedToolNames.activate(names)) return;
416-
if (services.flushPromotions()) {
417-
services.directorHolder.instance?.updateToolDefinitions(
418-
services.computeAdvertised(
419-
services.toolset.dynamicRunner.currentDefinitions(),
420-
),
421-
);
422-
}
423-
// Activation is model-visible contract — persist it now so a crash or
424-
// restart before the next turn boundary does not strand the transcript's
425-
// "these tools are available" record.
426-
void persistRunSnapshot("running");
426+
activateAndCommitWire(names);
427427
};
428428
services.toolset.setToolPromoter(promoteTools);
429429

0 commit comments

Comments
 (0)