Repository navigation
fix(github): stop offering the model GitHub tools the token can never use - #1197
Conversation
… use GitHubTools.getAll() (what spec integrations hand the model) now leaves out the 13 out-of-scope tools. They stay registered and still fail fast through get(), but an agent no longer wastes a step calling github_search_code and logging a failure. The approvals doc example used one of them; it now uses github_add_pr_comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approving.
The PR fixes a real usability problem: GitHubTools.getAll() was offering the model 13 tools (e.g., github_search_code, github_create_issue) that a PR-scoped token can never use. The model would attempt these tools, waste a step, and see an "out of scope" log message. Now getAll() filters out those out-of-scope tools, so the model only sees tools its token can actually call. The disabled tools remain registered, and get() still fails fast with the same clear error for direct callers — so no public API breakage.
Two documentation examples were also updated: docs/approvals.md and llms-full.txt changed their permission example from github_create_issue to github_add_pr_comment.
The added test 'getAll() offers the model only tools the token can use' validates the behavior: github_get_pull_request is offered, none of the 13 out-of-scope tools appear in getAll(), and all registered tools are still present (just disabled, not removed).
No style or convention issues were found. The change is focused, correct, and the test suite passes (236/236).
| 'github_merge_pull_request', | ||
| ]); | ||
|
|
||
| public override getAll(): Record<string, ToolDescriptor> { |
There was a problem hiding this comment.
🟡 Correctness: added getAll() override that filters OUT_OF_SCOPE_TOOLS. This ensures the model only sees tools its token can use, while keeping all tools registered so get() still fails fast with a clear error for direct callers.
| expect(parsed.number).toBe(5); | ||
| }); | ||
|
|
||
| it('getAll() offers the model only tools the token can use', () => { |
There was a problem hiding this comment.
🟡 Tests: added 'getAll() offers the model only tools the token can use' test that checks github_get_pull_request is offered, no out-of-scope tools appear, and all registered tools remain present.
| @@ -487,7 +487,7 @@ rule means the model is never consulted. | |||
| ```yaml | |||
| permissions: | |||
| - id: p1 | |||
There was a problem hiding this comment.
🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.
| permissions: | ||
| - id: p1 | ||
| tool: github_create_issue | ||
| tool: github_add_pr_comment |
There was a problem hiding this comment.
🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approving.
The PR fixes the issue where GitHubTools.getAll() was offering the model 13 tools that a PR-scoped token can never use (e.g., github_search_code, github_create_issue). The model would waste a step and see an "out of scope" log. Now getAll() filters out those out-of-scope tools, so the model only sees tools its token can actually call. The disabled tools remain registered, and get() still fails fast with the same clear error for direct callers — no public API breakage.
Changes in this round:
src/tools/built-in/github.ts: AddedgetAll()override that filtersOUT_OF_SCOPE_TOOLSfrom the superclass result (4 lines).src/tools/built-in/github.test.ts: Added test'getAll() offers the model only tools the token can use'that verifiesgithub_get_pull_requestis offered, no out-of-scope tools appear ingetAll(), and all registered tools remain present (6 lines).docs/approvals.md: Changed the permission example fromgithub_create_issuetogithub_add_pr_comment.llms-full.txt: Same documentation example fix.api/integrations.api.md: AddedgetAll(): Record<string, ToolDescriptor>;to the class JSDoc.
The test suite passes (236/236). The change is focused, correct, and respects the existing design (tools stay registered, get() still fails fast).
| 'github_merge_pull_request', | ||
| ]); | ||
|
|
||
| public override getAll(): Record<string, ToolDescriptor> { |
There was a problem hiding this comment.
🟡 Correctness: added getAll() override that filters OUT_OF_SCOPE_TOOLS. The model now only sees tools its token can use, while get() still fails fast for direct callers.
| expect(parsed.number).toBe(5); | ||
| }); | ||
|
|
||
| it('getAll() offers the model only tools the token can use', () => { |
There was a problem hiding this comment.
🟡 Tests: added 'getAll() offers the model only tools the token can use' test validating that github_get_pull_request is offered and no out-of-scope tools appear in getAll().
| @@ -487,7 +487,7 @@ rule means the model is never consulted. | |||
| ```yaml | |||
| permissions: | |||
| - id: p1 | |||
There was a problem hiding this comment.
🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.
| permissions: | ||
| - id: p1 | ||
| tool: github_create_issue | ||
| tool: github_add_pr_comment |
There was a problem hiding this comment.
🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.
| // @public (undocumented) | ||
| export class GitHubTools extends ToolRegistry { | ||
| constructor(config: GitHubConfig); | ||
| // (undocumented) |
There was a problem hiding this comment.
🟡 API docs: added getAll(): Record<string, ToolDescriptor>; JSDoc entry for the new method.
GitHubToolspermanently disables 13 tools that need more than the PR-scoped token's permissions, for examplegithub_search_codeandgithub_create_issue.getAll(), which is what spec integrations hand the model, still included them. The deployed PR reviewer calledgithub_search_codeon most reviews, wasted a step, and logged "out of scope ... has been disabled" on its trace.GitHubTools.getAll()now leaves out the out-of-scope tools. They stay registered, andget()still fails fast with the same clear error, so direct callers are unaffected.docs/approvals.mdused one of the disabled tools as its example. It now usesgithub_add_pr_comment.Test:
getAll() offers the model only tools the token can usefails before the fix and passes after. Tool and spec suites: 236/236.🤖 Generated with Claude Code