Skip to content

Add support for org-level discussions in list_discussion_categories tool #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

tommaso-moro
Copy link
Contributor

Overview

Closes: #818

This PR improves the existing list_discussion_categories tool, by adding logic to handle organisation-level discussions. (It implements similar logic to what I implemented in PR #775 )

Changes introduced

Before, the "repo" argument was required, so when the user would ask to query org-level discussions the model would either (i) hallucinate random values for repo or (ii) it would have to know the implementation detail about the Github API which is that org-level discussions are stored in a hidden .github repo.
With these changes:

  • the repo argument is made optional
  • the tool description is updated so that the model knows to omit repo if discussions are to be queried at the org-level
  • the repo value is deterministically set to .github when needed
  • the tests are updated to reflect these changes

Before (the model hallucinates repo values)
Screenshot 2025-08-04 at 17 14 44

After (the model correctly omits the repo argument, and the tool uses the deterministic flow to query org-level discussions)
Screenshot 2025-08-04 at 17 18 12

@tommaso-moro tommaso-moro requested a review from a team as a code owner August 4, 2025 16:36
@Copilot Copilot AI review requested due to automatic review settings August 4, 2025 16:36
Copilot

This comment was marked as outdated.

mattdholloway
mattdholloway previously approved these changes Aug 5, 2025
Copy link
Contributor

@mattdholloway mattdholloway left a comment

Choose a reason for hiding this comment

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

lgtm

@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 10:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the list_discussion_categories tool to support organization-level discussions by making the repo parameter optional and automatically defaulting to .github when querying at the organization level.

  • Makes the repo parameter optional instead of required
  • Adds logic to default to .github repo when repo is not provided for organization-level queries
  • Updates tool description and documentation to clarify the new behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/github/discussions.go Makes repo parameter optional and adds logic to default to .github for org-level queries
pkg/github/discussions_test.go Adds comprehensive test coverage for both repository and organization-level scenarios
README.md Updates documentation to reflect the optional repo parameter
Comments suppressed due to low confidence (2)

pkg/github/discussions_test.go:648

  • The test verifies that only 'owner' is required but doesn't verify that 'repo' is not in the required array. Consider adding an explicit assertion that 'repo' is not required to make the test more complete.
	mockClient := githubv4.NewClient(nil)
	toolDef, _ := ListDiscussionCategories(stubGetGQLClientFn(mockClient), translations.NullTranslationHelper)
	assert.Equal(t, "list_discussion_categories", toolDef.Name)
	assert.NotEmpty(t, toolDef.Description)
	assert.Contains(t, toolDef.Description, "or organisation")
	assert.Contains(t, toolDef.InputSchema.Properties, "owner")
	assert.Contains(t, toolDef.InputSchema.Properties, "repo")
	assert.ElementsMatch(t, toolDef.InputSchema.Required, []string{"owner"})

pkg/github/discussions_test.go:733

  • Consider adding a test case where repo is explicitly set to an empty string to verify the behavior when the parameter is present but empty, as this might behave differently from when the parameter is completely omitted.
			name: "list org-level discussion categories (no repo provided)",
			reqParams: map[string]interface{}{
				"owner": "owner",
				// repo is not provided, it will default to ".github"
			},

Copy link
Contributor

@mattdholloway mattdholloway left a comment

Choose a reason for hiding this comment

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

Test improvements look great 🚀

@tommaso-moro tommaso-moro merged commit 33a63a0 into github:main Aug 5, 2025
10 checks passed
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.

Add org-level discussions support to list_discussion_categories tool
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy