Skip to content

Recompute plugin tool masks when a turn starts - #598

Merged
Birfy merged 2 commits into
ThinkFlowLab:mainfrom
HugoXK:fix/594-tree-tools-after-startup
Oct 21, 2026
Merged

Birfy merged 2 commits into
ThinkFlowLab:mainfrom
HugoXK:fix/594-tree-tools-after-startup

Conversation

@HugoXK

@HugoXK HugoXK commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Recompute plugin tool masks when a turn starts
Fixes #594
A Main Bot that onboarding creates while dsh web runs had no create_team / create_child_bot: its Agent resolved before @flybot/tree adopted it, so hidePluginTools computed its deny mask with the Bot outside the tree, and a direct user turn resolves no Agent, so nothing recomputed it (only agent/created and Bot-to-Bot delivery did). The mask is now also recomputed when a turn starts in the Session (session/event turn/start, before the model sees the message), the same seam the connector mask uses; an unchanged mask is left alone, so a masked tool still never flips (#276).
core/test/flybot.test.js resolves the Agent before adoption, adopts the Bot, starts a turn and asserts the mask lifts — it fails without the change. core/test/install.test.js's fixed listener list gains the new on session/event.
Ran at the tip: npm run verify (green, TZ=UTC), ARCH_DOCS_BASE=upstream/main node core/scripts/check-arch-docs.mjs, node .github/scripts/changelog.mjs check. Not run: smoke (this macOS box has no setsid, so dev/bench.sh cannot start dsh web), Desktop, real-model steward.

HugoXK and others added 2 commits October 21, 2026 15:52
A Main Bot created after the server started misses the tree's gated tools
(create_team, create_child_bot): its Agent resolved before the tree adopted
it, so the deny mask was computed with the Bot outside the tree and nothing
recomputed it, since a direct user turn resolves no Agent. Refresh the mask
on session/event turn/start (idempotent, as on a resolve, ThinkFlowLab#276) so an adopted
Bot gets its tools on its next turn with no restart.

Fixes ThinkFlowLab#594
@Birfy

Birfy commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

PASS at b700a74c5ac9f4d84385f09049e1ed9ec81ec2d4 (maintenance self-review, Birfy; self-PASS counts under the 2026-10-21 owner decision).

Tier T2 (core/src/host/hooks.js; the tests, the patch files and the changelog fragment are lower). The branch was first updated with main 167ce83a (it still sat on dad73d63); the review and every run below are on the merged tip b700a74c, not on the old base.

Reviewed the diff at the tip: a session/event turn/start now recomputes the plugin-tool mask for the Session's Agents, through the same hidePluginTools the connector mask already uses on turn start (rt.connectorTurnChanged) — a Main Bot the tree adopts while the server runs gets create_team / create_child_bot on its first turn, with no restart. hidePluginTools keeps its "unchanged mask is left alone" guard (the key compare), so #276 still holds: a masked tool never flips and no Tool added / Tool removed row appears; its test still passes. Agents are tracked with WeakRefs and dead ones are dropped on the next visit; a turn that changes nothing makes no restrict call. Nothing here widens who may see a tool — the same visibleTo predicate decides, it is only recomputed at one more seam.

Ran at this content (TZ=UTC; proven to be this tree: all 871 blobs of b700a74c were recomputed locally byte-for-byte, modes included, and match):

CI at the tip: tests-ok green (test, plugins tree/social/timeline, package), mergeable: clean.

Not run: one-shot npm run verify (2 GiB OOM here), smoke (this box has no setsid), Desktop, real-model steward.

@Birfy Birfy added agent-pr Pull request opened by an agent area:automation Scheduled tasks and automation bug Something isn't working labels Oct 21, 2026
@Birfy
Birfy added this pull request to the merge queue Oct 21, 2026
Merged via the queue into ThinkFlowLab:main with commit 2a063f3 Oct 21, 2026
8 checks passed
@Birfy Birfy removed the agent-pr Pull request opened by an agent label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:automation Scheduled tasks and automation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A Main Bot created after the server starts has no create_team / create_child_bot until dsh web restarts

2 participants