Repository navigation
fix(assistant): restrict native tools to assistant-owned sessions - #6219
Conversation
Generated-by: Codex
Astro-Han
left a comment
There was a problem hiding this comment.
Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.
Reviewed 256ba274 (one commit, +86/-7, against main 9826db1b). No P0–P2 finding.
The fix closes both paths an ordinary Session had to native assistant tools:
- Discovery.
resolveRootToolsalready ranfilterTools, but the interactive surface inexecution-composition.ts:1551spreadpersonalAssistant.toolsunfiltered. Both paths now go throughfilterTools, which drops every native assistant tool name for Sessions without access before the existing per-module filters run. Ordinary core tools such asBashare untouched. - Execution. Each registered tool's
implnow rejects callers for whichhasSessionAccessis false, so a cached handle from an ordinary Session can no longer reachMatterDelegateand similar tools.
Access is derived only from Host-owned state: the Bot owner and worker bindings (AssistantBotBridge), the registered background-session readers (now kept on the runtime so they are available after recover), and Proactive Matters' authorized long-task sessions or sessions that already own a Matter. No caller-supplied label is trusted. The long-task flow still works: an authorized session can call MatterStart, and after consumeAuthorizedSession it keeps access through store.forSession. Matter-delegated workers keep the existing Matter tool filters.
The new tests cover the mixed-catalog case and the cached-handle rejection for every native tool, and they keep Bot and recovered task/index worker access.
P3 (behaviour note, no change required): ordinary child Sessions spawned from the assistant conversation (for example via Task) are not in the access set, so they no longer see assistant tools. That matches the stated intent; mention it in the release note if anyone relied on it.
I read the diff and its callers and did not rerun tests. CI test is still running on this head. A trial merge with #6220, which also edits execution-composition.ts, is clean.
jackwener
left a comment
There was a problem hiding this comment.
[kabi-sol]
Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.
Reviewed 256ba2744b32a52c5db40c428b55caa2491f1cb1: no P0–P2 findings in the reviewed scope.
The restriction matches #6217: actual assistant ownership/registration grants access; ordinary child sessions and an unregistered background session do not inherit it. I traced both execution composition and discovery filtering, the invocation guard before delegation scoping, registered memory/discovery workers, persisted matter authorization, and shutdown fencing. Keeping the check on cached tool implementations is necessary and present.
Local verification: clean dependency install/patches and prerequisite + Runtime Host builds; 50 tests pass across personal-assistant and assistant-bot. Independently removing either the execution guard or catalog restriction from compiled output makes the corresponding new regression test fail; output restored afterward. No production source changed.
Limits: no live model, packaged Desktop, Windows, or full repository suite. I saw another reviewer's summary before this review, so this was not blind. This is a COMMENT, not an approval.
…sions Generated-by: Codex
|
Pushed 6f1e0d8 to fix the CI failures introduced by the new admission boundary. The native module business fixtures now explicitly authorize their coordinator Session, rather than invoking assistant tools from an ordinary caller. Restored Matter Sessions retain access without attempting a second enrollment. Also preserved ordinary-chat original-link reads through the module-only Host resolver while all model-facing native tool handles keep the session guard. Added an ordinary-reader regression proving both sides of that boundary. Validation on Node 24.18.1: 61 native assistant/Bot/boundary tests pass; the complete module suites pass with 83 memory-network, 24 index-initiative and 82 proactive-matters tests. Build/typecheck, changed-file Biome and diff checks pass. No Chrome/WorkHub code is included in this PR. Fresh head CI is queued. Existing automated reviews had no P0–P2 finding and there are no inline threads to resolve. |
Astro-Han
left a comment
There was a problem hiding this comment.
Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.
Incremental review of 256ba274..6f1e0d8c. The first commit is unchanged, and one new commit was added. No P0–P2 finding.
AssistantRuntime now keeps two copies of each registered tool. internalTools holds the original implementation without the session-access check. tools, the model-facing list returned through the composition and filterTools, wraps that implementation with the same closing and hasSessionAccess checks as before. The model-facing gate is unchanged: tool discovery still filters native names for Sessions without access, and execution through the public handle is still rejected.
ctx.tools.resolve(...) now resolves against internalTools. In src its only caller is index-initiative/assistant.ts:32. That is the built-in assistant panel, which invokes MemoryStatus, MatterOverview and FeishuSyncStatus on the index-initiative Session from product UI code, not from a model turn. Bypassing the session gate there is correct, and it restores what the first commit had broken for that panel. Model-reachable paths do not use resolve, so this does not reopen the ordinary-session hole. Please keep it that way: if a future module hands resolve() results to a model, it would bypass the gate.
The remaining changes are test fixtures that register their business test Sessions as allowed. Our earlier P3 (child Sessions spawned from the assistant conversation lose assistant tools) still stands as a release-note item.
CI test passes on this head. A trial merge with #6220 is still clean.
jackwener
left a comment
There was a problem hiding this comment.
[kabi-sol]
Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.
Re-reviewed 6f1e0d8c406ddb1e90b98e1352b58996e85e2065. No P0–P2 findings; approving at the human requester's explicit direction.
The follow-up correctly separates Host-internal original reading from model-exposed tools. I traced assistant.original: it still resolves the selected Session and carries its identity into source reads; the model-facing implementations retain the access guard before invoking the internal wrapper. The fixture authorizations exercise admitted business flows without reopening access for ordinary callers, whose rejection tests remain present.
Rebuilt Runtime Host on this head and reran the 50 personal-assistant/Bot tests plus all 189 assistant business tests (83 memory, 24 initiative, 82 matters): 239 tests passed in total. The original scoped review remains #6219 (review) . No production source edits, live model, packaged Desktop, or Windows run. This automated approval does not replace the independent human review required by CONTRIBUTING.md.
Summary
Ordinary conversations could call native personal-assistant tools such as
MatterDelegate, create hidden background tasks, and later receive task updates as synthetic user input. Restrict the native tool catalog and execution admission to the bound assistant/Bot, registered assistant workers, and explicitly authorized long-task sessions.Fixes #6217
Verification
git diff --checkpass.Bashand excludes every native assistant tool; attempting every cached native tool handle from ordinary callers is rejected. Bot and recovered task/index worker capabilities remain available.The module-only resolver preserves the existing read-only Host API for cited originals under the requesting chat's source permissions; guarded model tool handles remain inaccessible to ordinary Sessions.
This prevents new ordinary-session use of assistant tools. Existing task records are retained; this does not cancel tasks already created by earlier versions. No installed Runtime Host or Desktop was replaced.
AI use
Tool(s) and scope: Codex inspected the implementation and live read-only evidence, authored the fix and regression tests, and ran the local checks.
Checklist
Does this PR entail a change in behavior?