Skip to content

fix(app): follow-ups to the agent tool limit - #2956

Merged
rdimitrov merged 7 commits into
feat/agent-tool-limitfrom
fix/agent-tool-limit-review
Nov 23, 2026
Merged

rdimitrov merged 7 commits into
feat/agent-tool-limitfrom
fix/agent-tool-limit-review

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-ups from reviewing #2937, stacked on feat/agent-tool-limit. Merge this into #2937's branch, or cherry-pick the commits there.

  • Fix a nil-function panic when a file-less team member closes. retainHarnessGeneration returns a nil close function when the harness instructions are not generation-backed. The new file-less member close in feat(identitybroker): limit each agent's gateway calls to its definition's tools #2937 called it without a check, so a member whose definition has inline MCP servers panicked on teardown. All three unguarded calls in buildMemberSelectorEngine now check for nil, including an older one on the file-ful path.
  • Apply a definition's tools allowlist to its file-less team member. The file-ful path narrows core tools with scopedToolNamesMode. The file-less path only applied disallowedTools, so tools: [Read] still got WebFetch, WebSearch, and the memory tools. Both paths now narrow core tools the same way, and MCP and gateway tools still follow mcpServers and disallowedTools. A file tool named in tools logs at Debug in the file-less path, because it doesn't exist there; a genuinely unknown name still warns.
  • Test the broker's refusal with definitions loaded from files. In the end-to-end tests the harness hides an excluded tool before the call reaches the broker, so removing check 7 broke no test. The new internal/app test loads a definition from disk through the startup loader and calls AuthorizeCall directly. It fails with check 7 removed.
  • Test that a ceiling survives re-registration in a reopened broker session. It fails if recordLocked overwrites the stored ceiling.
  • Build a ceiling's record form once. Ceiling is immutable, so String() now returns text computed in NewCeiling and intersect instead of sorting and joining on every AuthorizeCall.
  • Docs. mcp-authorization.md no longer says resolution runs against servers "and their tools". The tools.md sentence on file-less team members now says what tools, disallowedTools, and mcpServers each do.

Issue relationship

Relates to #2842

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe): tests and a small per-call allocation cut

Test plan

Baseline checks

  • Linting: golangci-lint run on ./internal/app/... and ./internal/identitybroker/... only, 0 issues
  • Focused tests: go test ./internal/app/ ./internal/identitybroker/... pass; go test -race ./internal/identitybroker/... passes
  • Pre-review race suite (task test:race): left to CI
  • Offline demo (go run ./cmd/mecademo): not run
  • Markdown changed: task docs passes
  • User docs/user-facing behavior changed: site build (task site:build): left to CI
  • Guarded engine API affected: not affected, engine/ is unchanged
  • Intentional engine API change: none

Each new test was checked against the regression it targets. The close test panics without the nil check. The loaded-definition test fails with check 7 removed. The re-registration test fails when recordLocked overwrites the ceiling.

Changes

File Change
internal/app/build.go nil checks on generationClose; comments mention the tools allowlist
internal/app/catalog.go newNoFSDefinedMemberCatalog scopes core tools with scopedToolNamesMode; file tools log at Debug
internal/app/nofs_team_test.go close without a harness generation; tools allowlist
internal/app/identitybroker_gateway_test.go broker refusal under a ceiling loaded from files
internal/identitybroker/ceiling.go cache the record form
internal/identitybroker/ceiling_test.go ceiling kept across re-registration in a reopened session
docs/drafts/agent-identity/mcp-authorization.md resolution wording
user-docs/features/sessions/tools.md file-less team member sentence

User-facing change

A file-less team member that names a definition with a tools list now gets only the listed core tools. For example, tools: [Read, Grep] leaves it with its team, MCP, and gateway tools only, which matches how tools already works with a filesystem.

API compatibility: no wire change. Nothing touches a proto, gRPC, HTTP, or event surface.

Special notes for reviewers

🤖 Generated with Claude Code

jhrozek and others added 7 commits November 23, 2026 13:43
retainHarnessGeneration returns a nil close when the harness instructions
are not generation-backed. The file-less member path called it unguarded,
so closing a defined member with its own MCP server panicked, and a failed
provider lookup did the same. Guard both, as the file-ful path does.

Co-Authored-By: mecatl <[email protected]>
…member

The file-less defined member catalog only filtered core tools by the
definition's disallowedTools, so a definition limited to a few tools still
got WebFetch, WebSearch and every memory tool. Scope the file-less core and
memory tools through scopedToolNamesMode, as the member with a filesystem
does. MCP and gateway tools keep following the definition's servers and
exclusions.

Co-Authored-By: mecatl <[email protected]>
Load a definition from files through the real broker path, with the
calendar server and one excluded tool, and register a helper running it.
Its call to the excluded tool and to a server it does not reference are
refused before any ID-JAG exchange, and its call to the server's other
tool passes the ceiling check.

Co-Authored-By: mecatl <[email protected]>
- Log filesystem tools named in a definition's `tools` at Debug instead of
  Warn "unknown tool": they do not exist without a filesystem. Genuinely
  unknown names still warn. Add the member name to the log, as the
  file-ful path does.
- Mention the `tools` allowlist in the buildMemberEngine comments.
- Reword the no-filesystem docs so disallowedTools is not described as
  limited to core and memory tools, and name the tools `tools` limits.
- Drop an always-true assertion and fix a stale definition description in
  the file-less member tests.

Co-Authored-By: mecatl <[email protected]>
@rdimitrov
rdimitrov merged commit 11e7fcd into feat/agent-tool-limit Nov 23, 2026
44 checks passed
@rdimitrov
rdimitrov deleted the fix/agent-tool-limit-review branch November 23, 2026 13:17

This branch was successfully deployed

1 active deployment
Preview — 11e7fcd5 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants