Chat offers the model only the tools its person may use #2067
Notifications
Due Date
No due date set.
Blocks
Reference: sam/archie#2067
Reference in new issue
Block a user
Why: Today the model is shown every connector tool in its prompt, and access is checked only when a tool is called. A person who may not use a tool can still see its name, description and parameter schema ("list all your tools"), and a prompt-injected model can emit a call to a withheld tool that only fails at execution time. Discovery must be filtered before prompt construction, and any invocation outside the permitted set must fail closed.
Today: modules/chat/tools.go tools() builds the tool set from every d.Toolbox.Declarations() entry plus builtins(), and toolSummaries() feeds that same set into the system prompt via prompts.ChatSystem in modules/chat/turn.go generate(). The turn acts as the conversation owner's current principal (actingAs in tools.go, put into ctx by generate()), but discovery is unfiltered: access is checked only at call time, in call() (m.allowed with ActionRun for actions, ActionRead for lookups, resource kind KindConnector) and in guarded() wrapping each builtin. There is no separate versioned tool manifest in chat; the running connectors' declaration set plus the builtins is the de facto manifest, and the session leg is the owner binding.
Source: the revised RFC exported at transcripts/2026-11-20-chat-authorization-rfc-3fa43269.md in sam/archie-product; citations below are RFC section numbers.
Required behaviour:
Out of scope: #2068 taint, #2069 memory scopes, #2070 connector credential modes, #2071 admin tools refused in chat, #2072 approval binding, #2073 image/CSP rendering, #2074 budgets and rate limits, #2075 audit, revocation and kill-switch, #2078 enforcement on every entry point, #2079 chat-triggered workflow execution contracts, #2080 disclosure authorization per audience and destination. Also out of scope: versioned-manifest admission and pinning of reviewed tool versions beyond what the running declaration set already provides (open question below).
Design notes: owning module is modules/chat: tools() and builtins() in modules/chat/tools.go, prompt assembly in modules/chat/turn.go generate(). Reuse m.allowed unchanged as the single per-tool decision, called once per declaration and per builtin and skipping denied ones; the decision point is modules/governance/engine.go Authorize, with ErrChainUnavailable treated as deny. Behaviour-only, no schema migration. Pitfalls: filter after actingAs so a resumed turn still acts as its owner; never let the model influence which tools are listed; keep the call-time check in call() and guarded() as the second enforcement point so a hallucinated or injected call to an omitted tool is refused, never run.
Tests: security-boundary seam, so table tests with fakes and no DB, alongside modules/chat/access_test.go:
Done when: task check passes with the new tests; on a running binary (task dev), signed in as a viewer, asking chat "what tools do you have" lists only tools the viewer may use and an attempted call to a withheld tool is refused at call time; signed in as an admin, the same conversation lists the action tools.
Open questions for the maintainer:
Part of #2066.
Implemented in
96fb0afcd.Tests in modules/chat/access_test.go cover admin versus viewer discovery, lookup versus action on one connector, builtin filtering, an unavailable policy chain, a stale declaration that must not run, a role change between turns, a withdrawal between model requests, and name collisions. task check passes on the commit.
The remaining verification is the live one from the issue: a disposable binary with an agent model configured, signed in as a viewer, checking the captured provider request and an attempted withheld call. It was not run here; the tests assert the same provider-facing set and the no-execution case.