Repository navigation
Description
Problem
A captured BSH request for the plain message hello 8888 advertises 39 function tools, including workspace editing, shell execution, task orchestration, Federation, scheduling, MCP and surface tools.
BSH already has find_tool and a deferred-tool discovery path. The issue is not the absence of dynamic discovery: it is that the live initial request still exposes a broad tool set even when the current turn has no apparent tool intent.
This increases schema payload and model choice burden on ordinary turns, and weakens the distinction between conversational turns and execution turns.
This is a follow-up based on an actual request capture to the initial-schema budgeting and Tool Intelligence work; it should not reimplement those systems.
Required changes
- Trace the production path that selects the initial model-visible tool set.
- Apply a small, deterministic, intent-aware initial tool policy:
- ordinary conversation: no execution tools, or only the minimum discovery surface if required by the runtime contract;
- workspace read/edit tasks: expose the relevant core file/search/process tools and discovery;
- specialist tasks: expose the relevant capability tools, with the rest available through
find_tool.
- Preserve a safe fallback when intent classification is uncertain; do not silently make a required capability unavailable.
- Keep discovery, capability admission and invocation authorization separate. Advertising or discovering a tool must not grant permission.
- Reuse the existing schema budget, capability view and discovery telemetry rather than adding parallel registries or budgets.
- Keep tool ordering deterministic for stable request serialization and provider prompt caching.
Acceptance criteria
- A captured plain-chat request does not carry the full workspace/specialist tool set.
- Explicit file-edit, shell, MCP, Federation and scheduling scenarios receive the required tools either initially or through successful discovery.
- Every withheld tool remains discoverable when it is admitted by the current workspace/task capability view.
- Out-of-view, revoked and unauthorized capabilities remain denied at invocation time, even if a stale schema is present.
- Tests verify initial tool count/schema bytes, discovery success, no-tool decision accuracy and task completion for representative task classes.
- Benchmark the complete serialized request and report before/after schema bytes and token estimates; do not claim a saving from tool count alone.
- Existing Bound initial tool schemas and measure per-request prompt composition #292 schema-budget behavior, [Tool Intelligence] Upgrade find_tool to metadata-aware hybrid retrieval #284 discovery retrieval and [Tool Intelligence Runtime] Route model-facing tool discovery and invocation through the Workspace Capability View #285 capability-view enforcement remain authoritative.
Scope
Limit this change to the initial tool-admission decision and its integration with the existing request path. Do not introduce another tool registry, semantic search service or authorization layer.
Related
- Bound initial tool schemas and measure per-request prompt composition #292 — bound initial tool schemas and measure per-request prompt composition.
- [Tool Intelligence] Upgrade find_tool to metadata-aware hybrid retrieval #284 — metadata-aware hybrid tool retrieval.
- [Tool Intelligence Runtime] Route model-facing tool discovery and invocation through the Workspace Capability View #285 — route discovery and invocation through the Workspace Capability View.
- [Tool Intelligence Runtime] Enforce cumulative schema-context budgets for dynamically discovered tools #286 — cumulative schema-context budgets.
- [Tool Intelligence Runtime] Add end-to-end tool selection and invocation effectiveness telemetry #287 — tool selection and invocation effectiveness telemetry.
Review follow-up (2026-11-17)
The submitted intent-aware admission implementation is directionally correct and the review found no reason to redesign the admission architecture. The original scope and acceptance criteria above remain in force.
Remaining verification
The current tests establish the basic split between ordinary conversation, workspace-core tools and withheld specialist tools. Before closing, add or confirm end-to-end regression coverage for the following specialist paths:
- MCP: an admitted MCP capability is discoverable through
find_tool, can be invoked successfully, and remains subject to runtime authorization. - Federation: an admitted Federation capability is discoverable and invokable through the existing capability path.
- Scheduling: an admitted scheduling capability is discoverable and invokable through the existing capability path.
- Revocation/stale schema: after a capability is revoked or falls outside the current capability view, invocation is denied even if the model or conversation still carries an old tool definition.
- Turn-to-turn scope changes: a conversation turn followed by an explicit work turn (and the reverse) recomputes the initial tool set; no stale admission decision is reused.
These are verification additions, not requests for new registries, authorization layers or discovery mechanisms.
Acceptance additions
- Representative MCP, Federation and scheduling tasks complete through discovery when their capabilities are admitted.
- Revoked/out-of-view capabilities remain denied at invocation time with stale schemas.
- Consecutive turns with different intents use the correct per-turn tool set.
- Report the existing complete-request measurement (tool count, schema bytes, total request bytes and estimated tokens) alongside test results. Do not treat the estimate as a measured provider token count.
Review evidence
Review status: Implementation substantially meets the issue; close after the specialist discovery, revocation and per-turn regression coverage is confirmed.
Activity
feat(tools): scope the initial tool array by turn intent (#435)