Skip to content

feat(acp): let clients turn tools off per session through _meta - #1915

Merged
addyCooks merged 2 commits into
Nano-Collective:mainfrom
addyCooks:feat/acp-session-disabled-tools
Oct 29, 2026
Merged

addyCooks merged 2 commits into
Nano-Collective:mainfrom
addyCooks:feat/acp-session-disabled-tools

Conversation

@addyCooks

Copy link
Copy Markdown
Collaborator

Description

Closes #1890

An ACP client can now turn tools off for a single session by sending _meta: {"nanocoder/disabledTools": [...]} on session/new, session/load or session/resume.

  • The session's list is merged with the user's global disabledTools. It never replaces it.
  • Disabled tools are left out of the tool list and the system prompt for that session only. Other sessions in the same process are unaffected.
  • If the model calls a disabled tool anyway, the call is refused with Error: <tool> is disabled in this session and nothing runs. Before this, the loop only checked that the tool existed, so a forced call would have run.
  • Subagents started by the session get the same list. It reaches them through the existing per-session subagent bridge, for both the tools they are offered and the execution-time check.
  • The effective list (user's plus client's) is reported in the response _meta under the same key, so a client can confirm it was honoured.
  • Unknown names are ignored with a debug log. Anything that isn't a list of strings is ignored.
  • The list is not persisted and the user's config is never written. It is sent on every load/resume, so sending none means none disabled.
  • getAlwaysAllowedTools (the approval policy reported in the same responses) now takes the session's list, so a client is not told a tool is pre-approved in a session where it is disabled.
  • Docs: docs/features/acp.md and docs/configuration/index.md.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Performance improvement
  • Code refactoring

Changeset

  • I have added a changeset (.changeset/acp-session-disabled-tools.md, minor)

Testing

Automated:

  • Merge and parse helpers (acp-capabilities.spec.ts).
  • New, load and resume honour the client's list on top of the user's, and report it in _meta (acp-agent.spec.ts).
  • A session that did not ask keeps the tool, in the same process.
  • A live session takes the list sent on a later load.
  • The list is not persisted, so a resume without it disables nothing.
  • Unknown and malformed names are ignored with a debug log.
  • A disabled tool is not offered, and a forced call is refused without running (acp-conversation.spec.ts).
  • Another session in the same process still has the tool.
  • The session's subagents are told the list, and a subagent from a disabling session cannot be offered or run the tool (subagent-executor.spec.ts).
  • Approval policy leaves out disabled tools (acp-approval.spec.ts).
  • Removing the execution-time refusal makes the forced-call test fail.
  • Full suite: no failures beyond those already present on main in this Windows environment.

Manual:

  • Not run against a real ACP client.

Checklist

  • Code follows the project's style (biome check . is clean)
  • Type check and knip are clean
  • New tests added, no fixed sleeps
  • Docs updated
  • All existing tests pass: on Windows, the same unrelated suites already fail on main
  • Logging added: only one debug line, for unknown names

A client can send _meta {"nanocoder/disabledTools": [...]} on session/new, session/load and session/resume. The names are merged with the user's global disabledTools for that session only: the tools are left out of the tool list and system prompt, a forced call to one is refused before anything runs, and the session's subagents get the same list. The effective list is reported back in the response _meta, unknown names are ignored with a debug log, and nothing is persisted or written to the user's config.
@github-actions github-actions Bot added area:tools Tool implementations and tool-calling area:docs Documentation labels Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

nc-review: comments — 2 important, 1 nit

@addyCooks — a few things worth a look, none blocking.

The PR adds a per-session disabled-tools list for ACP clients, delivered through _meta["nanocoder/disabledTools"] on session/new, session/load and session/resume, merged with the user's global disabledTools, threaded through the ACP tool list, the system prompt, the approval policy and the subagent bridge, and reported back in the response _meta. The plumbing is sound: the merge is done in one place (AcpSession.effectiveDisabledTools()), the execution-time refusal sits before the approval check in both the ACP loop and the subagent executor, and the new tests assert that a forced call does not run the handler rather than only that the tool is not offered. Two things need fixing before this is ready: the reported effective list still contains tool names that are not known tools (which the docs say are ignored, and which defeats the 'client can verify it was honoured' contract), and one of the new assertions in acp-agent.spec.ts is flaky because it substring-matches the random session UUID embedded in the log line it inspects.

🟠 important · correctness · source/acp/acp-agent.ts:952

buildDisabledToolsMeta logs a name that is not a registered tool, but still reports it in the effective list:

for (const name of session.disabledTools) {
    if (!this.initContext.toolManager.hasTool(name)) {
        logger.debug(`ACP session ${session.sessionId}: ignoring unknown disabled tool "${name}"`);
    }
}
return {[ACP_DISABLED_TOOLS_META]: session.effectiveDisabledTools()};

effectiveDisabledTools() returns the session list verbatim, so the response _meta echoes back a name that was never applied. The docs say the opposite — docs/features/acp.md: "A name that is not a known tool is ignored." — and the whole point of reporting the list is that "the client can verify it was honoured"; a client that sent ["browser", "typo"] gets ["browser", "typo"] back and cannot tell that typo was dropped rather than applied. Filtering the unknown names out of the returned list (in the same loop that already logs them) makes the response a truthful "list in effect" and matches the docs. The new test in acp-agent.spec.ts asserts only includes('browser'), so it would not catch this; t.deepEqual(created._meta?.[DISABLED_META], ['browser']) would.

🟠 important · tests · source/acp/acp-agent.spec.ts

In the new test 'AcpAgent - an unknown or malformed disabled tool is ignored, with a debug log', this assertion is flaky:

t.false(lines.some(line => line.includes('42')));

The captured line is the one buildDisabledToolsMeta writes, and it embeds the session's random v4 UUID (ACP session <uuid>: ignoring unknown disabled tool "no_such_tool"). A 32-hex-digit UUID contains the substring 42 roughly one time in five (the version nibble is always 4, so the pairs around it are 42 about 6% of the time each, plus ~10% from the remaining 25 digit pairs). The test therefore fails spuriously at that rate, and any other logger.debug call in the window that happens to contain 42 adds to it.

The assertion also does not test what it claims: the 42 in the request is a number, so parseDisabledTools drops it at the type filter and it can never reach the debug log — the assertion would pass for any implementation. Match the quoted name instead (line.includes('"42"')), or better, assert on the parsed list (e.g. t.deepEqual(created._meta?.[DISABLED_META], ['browser'])), which also covers the unknown-name case above.

⚪ nit · correctness · source/acp/acp-conversation.ts:301

runTurn snapshots the list once per turn (const disabledTools = session.effectiveDisabledTools();), whereas the mode right above it is deliberately re-read live on every call because "session/set_mode can arrive at any point in a turn". session/load can likewise arrive mid-turn: the new else branch in AcpAgent.loadSession assigns session.disabledTools and rebuilds the prompt while a turn is in flight, but the running turn keeps the old snapshot and can still execute a tool the client just turned off. Re-reading the list at the point of the refusal (as the mode is) would close this; as it stands the window is narrow — session/load during an active turn is unusual — so it is not a blocker, but the asymmetry with the mode handling is worth a comment.


🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional

Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with /re-review.

@github-actions github-actions Bot added the agent:comments nc-review left non-blocking findings label Oct 29, 2026
Resolves the conflicts with Nano-Collective#1913 (subagent lifecycle events), which touched the same ACP agent, subagent executor and spec files. The subagent now reads the session's mode and disabled tools from one bridge lookup before it announces itself.

Also addresses the nc-review comments: the response reports only the tools actually in effect (unknown names are logged and left out), the unknown-tool test no longer matches a substring of a random UUID, and the refusal re-reads the session's list live, as the mode is.
@addyCooks
addyCooks merged commit 9258ec2 into Nano-Collective:main Oct 29, 2026
18 checks passed
addyCooks added a commit to addyCooks/nanocoder that referenced this pull request Oct 30, 2026
Resolves the conflicts with the per-session tool registry (Nano-Collective#1914) and disabled tools (Nano-Collective#1915) on main: a session now builds its prompt with its own tool manager, provider and model, and keeps its disabled tools when it is created or loaded.

Also addresses the nc-review comments: aggressive compaction is now a per-session preset passed to auto-compact instead of the process-wide one, so one session switching provider cannot change when another compacts; switching to a provider that lists no models gives the session that provider's (empty) model instead of the previous provider's, and does not record it as the last-used selection; and the mid-turn test now observes the prompt rebuild directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:comments nc-review left non-blocking findings area:docs Documentation area:tools Tool implementations and tool-calling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Let ACP clients disable the built-in browser tool (and other tools) per session without editing user config

1 participant