Skip to content

fix(github): stop offering the model GitHub tools the token can never use - #1197

Merged
LinuxDevil merged 2 commits into
mainfrom
fix/github-hide-disabled-tools
Nov 17, 2026
Merged

LinuxDevil merged 2 commits into
mainfrom
fix/github-hide-disabled-tools

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

GitHubTools permanently disables 13 tools that need more than the PR-scoped token's permissions, for example github_search_code and github_create_issue. getAll(), which is what spec integrations hand the model, still included them. The deployed PR reviewer called github_search_code on 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, and get() still fails fast with the same clear error, so direct callers are unaffected.
  • docs/approvals.md used one of the disabled tools as its example. It now uses github_add_pr_comment.

Test: getAll() offers the model only tools the token can use fails before the fix and passes after. Tool and spec suites: 236/236.

🤖 Generated with Claude Code

… 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>

@lousho-ai lousho-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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', () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread docs/approvals.md
@@ -487,7 +487,7 @@ rule means the model is never consulted.
```yaml
permissions:
- id: p1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.

Comment thread llms-full.txt
permissions:
- id: p1
tool: github_create_issue
tool: github_add_pr_comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@lousho-ai lousho-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: Added getAll() override that filters OUT_OF_SCOPE_TOOLS from 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 verifies github_get_pull_request is offered, no out-of-scope tools appear in getAll(), and all registered tools remain present (6 lines).
  • docs/approvals.md: Changed the permission example from github_create_issue to github_add_pr_comment.
  • llms-full.txt: Same documentation example fix.
  • api/integrations.api.md: Added getAll(): 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> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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', () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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().

Comment thread docs/approvals.md
@@ -487,7 +487,7 @@ rule means the model is never consulted.
```yaml
permissions:
- id: p1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.

Comment thread llms-full.txt
permissions:
- id: p1
tool: github_create_issue
tool: github_add_pr_comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Docs: changed permission example from github_create_issue to github_add_pr_comment.

Comment thread api/integrations.api.md
// @public (undocumented)
export class GitHubTools extends ToolRegistry {
constructor(config: GitHubConfig);
// (undocumented)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 API docs: added getAll(): Record<string, ToolDescriptor>; JSDoc entry for the new method.

@LinuxDevil
LinuxDevil merged commit da0ccb2 into main Nov 17, 2026
6 checks passed
@LinuxDevil
LinuxDevil deleted the fix/github-hide-disabled-tools branch November 17, 2026 21:39
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.

1 participant