Skip to content

fix(runtime): keep request_sandbox_boundary visible in sandboxed Sessions - #6029

Merged
Colafornia merged 2 commits into
apache:mainfrom
Master-Frank:cursor/sandbox-boundary-required-tool-6adb
Oct 10, 2026
Merged

Colafornia merged 2 commits into
apache:mainfrom
Master-Frank:cursor/sandbox-boundary-required-tool-6adb

Conversation

@Master-Frank

Copy link
Copy Markdown
Contributor

Summary

Host binds request_sandbox_boundary only when the Session is not Full access, but tool_search still deferred it. Models then searched for that name, activated MiniSearch neighbors, and missed the prompt cache.

This PR passes the bound widening tool through the existing requiredToolNames hook. The set follows Host binding for the whole Session and does not depend on a live boundary prompt, which would change the provider prefix per Turn.

Full access Sessions still omit the tool. Direction 2 stays with #1382.

Refs #5879

Verification

  • The backend test fails when prepare() does not receive the required name, and passes with it.
  • node --test on tool-availability, deferred-tools-backend, and the new sandbox-boundary helper cases passed.
  • npm --workspace @maka/runtime run test:dist: 3752 passed, 13 skipped, 0 failed.
  • Hosted composition test production Host executes a canonical ai-sdk Session against a real provider wire passed with request_sandbox_boundary on the step-0 list.
  • biome format / biome lint clean for the changed files.
  • npm --workspace @maka/runtime run typecheck passed.
  • Did not run root npm test, knip, or the Desktop app.

AI use

Select exactly one:

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

Tool(s) and scope: A coding assistant implemented the Session-stable requiredToolNames wiring and wrote the regression tests.

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

@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 range: 560a27c1f..594329d5 (one commit, first review, no prior findings).

The PR adds requiredSandboxBoundaryToolNames(hostTools) and merges its result into the requiredToolNames passed to prepare(). When the Host binds request_sandbox_boundary (Sessions that are not Full access), it is now on the provider tool list from step 0 without a tool_search hop. Full access Sessions, where the tool is unbound, see no change. I checked the parts that could interact:

  • Required names are filtered by knownNames, are added to step.active, and never write to the activation map. The tool is therefore callable through gating.
  • Turn-level denial and finalization still remove the tool. boundaryAwareToolNames() and the code-mode catalog filter run after prepare(), so a required name does not override the "denied for this Turn" or finalization-step removal.
  • The set is computed from the step's Host snapshot, not from a live prompt, so it stays fixed for the Session unless the Host binding changes. A permission-mode change alters the tool set anyway.
  • The composition test now expects the tool on the step-0 list.

No P0-P2 findings.

P3 - the tool is still listed in the tool_search inventory. request_sandbox_boundary stays searchable, so it remains in the tool_search description, and an exact-name search still "activates" a tool that is already visible. The required orchestration tools behave the same way and this is harmless, but excluding required names from the inventory would save a few tokens and avoid a redundant search. This is optional.

P3 - possible conflict with #6028. Both PRs edit packages/runtime/src/__tests__/deferred-tools-backend.test.ts in the same hunks: this PR adds extraTools to the backend() helper input, #6028 adds loadTurnRuntimeEvents at the same spot, and both insert tests after the same test. A git merge-tree of the two heads (also main+#6028, then this PR) conflicts only in that file. ai-sdk-turn.ts auto-merges because the edits are about 30 lines apart. The runtime behaviors work together: required names do not touch the Session activation map that #6028 introduces. Whichever PR lands second needs a small test-file rebase.

No protocol or persisted-schema files are touched, so there is no epoch impact.

Mergeability: merges cleanly into current main (c11a5336). CI on 594329d5: label and test pass.

toolAvailability?: ToolAvailabilityConfig;
fullSurface?: boolean;
resolveTools?: () => readonly MakaTool[];
extraTools?: readonly MakaTool[];

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.

P3: #6028 adds loadTurnRuntimeEvents to this same helper input and inserts tests after the same test, so the two PRs conflict textually in this file. Whichever lands second needs a rebase. The runtime changes themselves do not conflict.

…ions

Host binds the widening tool only when the Session is not Full access, but
tool_search still deferred it. Models then searched for it, activated
neighbors, and missed the prompt cache. Pass it through requiredToolNames
whenever it is bound so the schema stays on the provider list for the
whole Session, without depending on a live boundary prompt.

Refs apache#5879

Generated-by: Cursor
Required names are already on the provider list. Leave them out of the
search inventory and ranking so an exact-name search does not activate a
tool that is already visible.

Align the deferred-tools backend helper with apache#6028 so the two PRs rebase
without a test-file conflict.

Refs apache#5879

Generated-by: Cursor
@cursor
cursor Bot force-pushed the cursor/sandbox-boundary-required-tool-6adb branch from 594329d to 7fb7985 Compare October 9, 2026 14:49
@Master-Frank

Copy link
Copy Markdown
Contributor Author

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 range: 560a27c1f..594329d5 (one commit, first review, no prior findings).

The PR adds requiredSandboxBoundaryToolNames(hostTools) and merges its result into the requiredToolNames passed to prepare(). When the Host binds request_sandbox_boundary (Sessions that are not Full access), it is now on the provider tool list from step 0 without a tool_search hop. Full access Sessions, where the tool is unbound, see no change. I checked the parts that could interact:

  • Required names are filtered by knownNames, are added to step.active, and never write to the activation map. The tool is therefore callable through gating.
  • Turn-level denial and finalization still remove the tool. boundaryAwareToolNames() and the code-mode catalog filter run after prepare(), so a required name does not override the "denied for this Turn" or finalization-step removal.
  • The set is computed from the step's Host snapshot, not from a live prompt, so it stays fixed for the Session unless the Host binding changes. A permission-mode change alters the tool set anyway.
  • The composition test now expects the tool on the step-0 list.

No P0-P2 findings.

P3 - the tool is still listed in the tool_search inventory. request_sandbox_boundary stays searchable, so it remains in the tool_search description, and an exact-name search still "activates" a tool that is already visible. The required orchestration tools behave the same way and this is harmless, but excluding required names from the inventory would save a few tokens and avoid a redundant search. This is optional.

P3 - possible conflict with #6028. Both PRs edit packages/runtime/src/__tests__/deferred-tools-backend.test.ts in the same hunks: this PR adds extraTools to the backend() helper input, #6028 adds loadTurnRuntimeEvents at the same spot, and both insert tests after the same test. A git merge-tree of the two heads (also main+#6028, then this PR) conflicts only in that file. ai-sdk-turn.ts auto-merges because the edits are about 30 lines apart. The runtime behaviors work together: required names do not touch the Session activation map that #6028 introduces. Whichever PR lands second needs a small test-file rebase.

No protocol or persisted-schema files are touched, so there is no epoch impact.

Mergeability: merges cleanly into current main (c11a5336). CI on 594329d5: label and test pass.

Thanks. Required names are now omitted from the tool_search inventory and ranking, so an exact-name search does not activate a tool that is already visible. The deferred-tools helper is aligned with #6028 so the two PRs rebase without a test-file conflict.

@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: 594329d5 (our last reviewed head) to 7fb79850. The branch was rebased onto current main. git range-diff shows the original commit unchanged (594329d5 = 7e3df714), plus one new commit, 7fb79850 "omit required tools from the tool_search inventory".

The new commit addresses our optional P3 (a required tool was still listed in tool_search).

  • prepare() now computes the required names before building the search connector. buildSearchConnector passes them to renderInventory, which omits them from the inventory, and to rankDeferredSearchHits, which withholds them from exact-name and fuzzy hits alongside already-active tools.
  • A search for a required tool now returns activated: [] instead of re-activating something already on the provider list.
  • The tests cover both request_sandbox_boundary and the orchestration-required case: absent from the inventory, and an exact search activates nothing. When the tool is not required, it is still listed and stays deferred.

One small behavioral shift: requiredNames is now filtered against toolsByName instead of the canonicalized provider-tool set. A required tool that canonicalization drops would be omitted from the inventory without being on the provider list. I don't see a path where a bound required tool fails canonicalization, so this is not a finding.

Findings: None at P0-P3 in the delta. The test-file overlap with #6028 is gone: both heads now carry the same extraTools helper field, and git merge-tree of the two heads is clean.

Status: MERGEABLE. The fork CI run on this head was waiting for approval, and I approved it after confirming the PR changes no .github files. Results were pending at posting time. No protocol files, so there is no epoch impact.

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

@Colafornia Colafornia 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.

Approved.

Making request_sandbox_boundary visible from step 0 removes an unnecessary search hop and avoids tool-loading cache invalidation for this common case, while preserving approval and denial enforcement. This is a focused improvement; cache invalidation when loading other deferred tools remains separate follow-up work. CI passes, and no blocking issues were found.

@Colafornia
Colafornia merged commit 2463d86 into apache:main Oct 10, 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.

4 participants