fix(gsd): restore full tool set after discuss flow scoping

dispatchWorkflow scoped tools down for discuss-* flows but never
restored them. The narrowed set persisted into subsequent dispatches,
making GSD execution tools permanently unavailable for the session.

Now saves the full tool list before scoping and restores it immediately
after sendMessage queues the turn. The LLM turn has already captured
the scoped set so it's unaffected.

Closes #3628

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tibsfox 2026-04-06 19:06:59 -07:00
parent b4c6229360
commit 69eb369675

View file

@ -295,8 +295,10 @@ async function dispatchWorkflow(
// "Grammar is too complex" when the combined tool schema is too large.
// Discuss flows only need a small subset of GSD tools — strip the heavy
// planning/execution/completion tools to keep the grammar within limits.
let savedTools: string[] | null = null;
if (unitType?.startsWith("discuss-")) {
const currentTools = pi.getActiveTools();
savedTools = currentTools;
// Keep all non-GSD tools (builtins, other extensions) and only the
// GSD tools on the discuss allowlist.
const scopedTools = currentTools.filter(
@ -322,6 +324,13 @@ async function dispatchWorkflow(
},
{ triggerTurn: true },
);
// Restore full tool set after the message is queued. The LLM turn has
// already captured the scoped set — restoring prevents the narrowed
// tools from leaking into subsequent dispatches (#3628).
if (savedTools) {
pi.setActiveTools(savedTools);
}
}
/**