feat: Add agent tasks API support#4225
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4225 +/- ##
=======================================
Coverage 97.45% 97.46%
=======================================
Files 189 190 +1
Lines 19164 19261 +97
=======================================
+ Hits 18677 18772 +95
- Misses 270 271 +1
- Partials 217 218 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @danyalahmed1995!
Just a couple tweaks/questions, then we should be ready for a second LGTM+Approval from any other contributor to this repo before merging.
cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra - @munlicode
Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
|
@gmlewis Thanks, sounds good. I’ll address the review comments and push an update shortly. |
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @danyalahmed1995!
LGTM.
cc: @stevehipwell - @alexandear - @zyfy29 - @Not-Dhananjay-Mishra - @munlicode
stevehipwell
left a comment
There was a problem hiding this comment.
Thanks for the PR @danyalahmed1995, I've added a couple of comments.
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
|
@stevehipwell @alexandear updated, thanks for the reviews. Changes in the latest update:
Validation:
|
|
@alexandear @stevehipwell Thanks for pointing me to the right direction. Root cause was generator-side: the Agent Tasks documentation URLs did not include an explicit I added a narrow metadata mapping for Validation:
|
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
|
@alexandear updated, thanks. I added I also added the public preview note to the Agent Tasks endpoint docs and kept I checked the schema for Validation:
I leave the api20260310 / github.go constant discussion untouched until @stevehipwell answers. |
# Conflicts: # github/github.go
|
@stevehipwell - @alexandear - could you please take another look when you get a chance? |
| // Deprecated: UserCollaborators is deprecated by GitHub. | ||
| UserCollaborators []*User `json:"user_collaborators,omitempty"` |
There was a problem hiding this comment.
I propose not adding the deprecated field. Or should we?
There was a problem hiding this comment.
This field is still present in the response schema, exposing it would keep the client complete and let callers read it if GitHub still returns it. I marked it deprecated so users are discouraged from relying on it.
GitHub’s official OpenAPI description still includes user_collaborators in the Agent Tasks response schema, marked deprecated. Since go-github models API response fields, exposing it keeps the SDK schema-complete and allows callers to read the field if GitHub still returns it.
| const ( | ||
| agentTaskID = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" | ||
| agentTaskSessionID = "s1a2b3c4-d5e6-7890-abcd-ef1234567890" | ||
| ) |
There was a problem hiding this comment.
Please do not declare global constants. It's better to have a separate constant for each test.
| createdAt := &Timestamp{time.Date(2025, time.January, 1, 0, 0, 0, 0, time.UTC)} | ||
| updatedAt := &Timestamp{time.Date(2025, time.January, 1, 1, 0, 0, 0, time.UTC)} |
There was a problem hiding this comment.
Could we use a different date, not 2025-01-01?
There was a problem hiding this comment.
What do you think could be a good golden number for the date here 🤔 ?
| testJSONMarshal(t, u, want, cmpJSONRawMessageComparator()) | ||
| } | ||
|
|
||
| func TestAgentTaskOwner_Marshal(t *testing.T) { |
There was a problem hiding this comment.
All *_Marshal tests are not needed and can be removed.
They are required only if we have custom marshal/unmarshal functions.
See #4253 (comment)
| // Keep this in sync with defaultAPIVersion in github/github.go. | ||
| const metadataDocsAPIVersion = "2022-11-28" | ||
|
|
||
| var customDocsAPIVersions = map[string]string{ |
There was a problem hiding this comment.
Maybe previewDocsAPIVersions would be a better name? And the var requires the comment.
There was a problem hiding this comment.
Yeah that was the plan initially but you asked to change it, you want me to revert it back ?
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Co-authored-by: Oleksandr Redko <oleksandr.red+github@gmail.com>
Summary
Adds typed client support for GitHub's Agent Tasks REST API.
This implements the documented public-preview Agent Tasks endpoints:
GET /agents/repos/{owner}/{repo}/tasksPOST /agents/repos/{owner}/{repo}/tasksGET /agents/repos/{owner}/{repo}/tasks/{task_id}GET /agents/tasksGET /agents/tasks/{task_id}Closes #4213.
Changes
AgentTasksServiceand registered it onClient.Notes
The Agent Tasks API is currently in public preview, so this PR keeps the implementation scoped to the fields and endpoints currently documented by GitHub.
Validation
Ran the repository validation flow from
CONTRIBUTING.md:script/fmt.shscript/test.sh ./...script/lint.shscript/generate.shgit diff --checkscript/test.shwith the default race configuration could not run on this Windows machine becausecgo/gccwas not available. I reran the full test script with the non-race fallback across all modules, and it passed.