Skip to content

fix(assistant): restrict native tools to assistant-owned sessions - #6219

Merged
me2seeks merged 2 commits into
apache:mainfrom
me2seeks:fix/assistant-tool-boundary
Oct 22, 2026
Merged

me2seeks merged 2 commits into
apache:mainfrom
me2seeks:fix/assistant-tool-boundary

Conversation

@me2seeks

@me2seeks me2seeks commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • Apply the same session filter to tool-name discovery and execution composition, preserving ordinary core tools.
  • Reject cached native tool handles from ordinary sessions before invoking their implementations. Determine access from Host-owned bindings/stores, rather than caller-supplied labels. Preserve recovered workers and existing Matter worker tool filters.

Fixes #6217

Verification

  • Runtime Host build and typecheck pass; prerequisite workspace builds pass.
  • 61 tests pass across native assistant, Bot, initiative boundary, background-session recovery and memory-feedback suites.
  • Full assistant module suites: 83 memory-network, 24 index-initiative, and 82 proactive-matters tests pass on Node 24.18.1. Business fixtures explicitly admit their coordinator Sessions. A regression verifies ordinary-chat original links still work through the read-only Host API while ordinary model-tool invocation is denied.
  • Removing the catalog and invocation gates makes both new ordinary-session regression subtests fail; restoring them passes.
  • Biome check on the changed TypeScript files and git diff --check pass.
  • A broad local Runtime Host run encountered an unrelated WorkHub profile test failure; no changes were made to that area and that full run is not claimed green.
  • User-visible evidence: an ordinary session's mixed catalog retains Bash and 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

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

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

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/S Under 100 readable lines label Oct 21, 2026

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. resolveRootTools already ran filterTools, but the interactive surface in execution-composition.ts:1551 spread personalAssistant.tools unfiltered. Both paths now go through filterTools, which drops every native assistant tool name for Sessions without access before the existing per-module filters run. Ordinary core tools such as Bash are untouched.
  • Execution. Each registered tool's impl now rejects callers for which hasSessionAccess is false, so a cached handle from an ordinary Session can no longer reach MatterDelegate and 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 jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@me2seeks
me2seeks requested a review from xxhZs October 21, 2026 10:22
@me2seeks

Copy link
Copy Markdown
Contributor Author

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 Astro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added effort/M Under 500 readable lines and removed effort/S Under 100 readable lines labels Oct 22, 2026

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

@me2seeks
me2seeks merged commit dcd1d4d into apache:main Oct 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(assistant): restrict native assistant tools to owned sessions

3 participants