@@ -12,6 +12,8 @@ import (
1212 "time"
1313)
1414
15+ const agentTasksAPIVersion = "2026-03-10"
16+
1517// AgentTasksService handles communication with the agent tasks
1618// methods of the GitHub API.
1719//
@@ -20,40 +22,40 @@ type AgentTasksService service
2022
2123// AgentTask represents a Copilot cloud agent task.
2224type AgentTask struct {
23- ID * string `json:"id,omitempty "`
25+ ID string `json:"id"`
2426 URL * string `json:"url,omitempty"`
2527 HTMLURL * string `json:"html_url,omitempty"`
2628 Name * string `json:"name,omitempty"`
2729 Creator * User `json:"creator,omitempty"`
2830 CreatorType * string `json:"creator_type,omitempty"`
2931 Owner * User `json:"owner,omitempty"`
3032 Repository * Repository `json:"repository,omitempty"`
31- State * string `json:"state,omitempty "`
33+ State string `json:"state"`
3234 SessionCount * int `json:"session_count,omitempty"`
3335 Artifacts []* AgentTaskArtifact `json:"artifacts,omitempty"`
3436 ArchivedAt * Timestamp `json:"archived_at,omitempty"`
35- CreatedAt * Timestamp `json:"created_at,omitempty "`
37+ CreatedAt Timestamp `json:"created_at"`
3638 UpdatedAt * Timestamp `json:"updated_at,omitempty"`
3739 Sessions []* AgentTaskSession `json:"sessions,omitempty"`
3840}
3941
4042// AgentTaskArtifact represents an artifact produced by an agent task.
4143type AgentTaskArtifact struct {
42- Provider * string `json:"provider,omitempty "`
43- Type * string `json:"type,omitempty "`
44- Data json.RawMessage `json:"data,omitempty "`
44+ Provider string `json:"provider"`
45+ Type string `json:"type"`
46+ Data json.RawMessage `json:"data"`
4547}
4648
4749// AgentTaskSession represents a session associated with an agent task.
4850type AgentTaskSession struct {
49- ID * string `json:"id,omitempty "`
51+ ID string `json:"id"`
5052 Name * string `json:"name,omitempty"`
5153 User * User `json:"user,omitempty"`
5254 Owner * User `json:"owner,omitempty"`
5355 Repository * Repository `json:"repository,omitempty"`
5456 TaskID * string `json:"task_id,omitempty"`
55- State * string `json:"state,omitempty "`
56- CreatedAt * Timestamp `json:"created_at,omitempty "`
57+ State string `json:"state"`
58+ CreatedAt Timestamp `json:"created_at"`
5759 UpdatedAt * Timestamp `json:"updated_at,omitempty"`
5860 CompletedAt * Timestamp `json:"completed_at,omitempty"`
5961 Prompt * string `json:"prompt,omitempty"`
@@ -112,7 +114,7 @@ type CreateAgentTaskOptions struct {
112114
113115// ListByRepo lists tasks for a repository.
114116//
115- // GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2026-03-10 #list-tasks-for-repository
117+ // GitHub API docs: https://docs.github.com/rest/agent-tasks/agent-tasks?apiVersion=2022-11-28 #list-tasks-for-repository
116118//
117119//meta:operation GET /agents/repos/{owner}/{repo}/tasks
118120func (s * AgentTasksService ) ListByRepo (ctx context.Context , owner , repo string , opts * AgentTaskListByRepoOptions ) (* AgentTaskList , * Response , error ) {
@@ -122,7 +124,7 @@ func (s *AgentTasksService) ListByRepo(ctx context.Context, owner, repo string,
122124 return nil , nil , err
123125 }
124126
125- req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion ("2026-03-10" ))
127+ req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion (agentTasksAPIVersion ))
126128 if err != nil {
127129 return nil , nil , err
128130 }
@@ -144,7 +146,7 @@ func (s *AgentTasksService) ListByRepo(ctx context.Context, owner, repo string,
144146func (s * AgentTasksService ) Create (ctx context.Context , owner , repo string , opts * CreateAgentTaskOptions ) (* AgentTask , * Response , error ) {
145147 u := fmt .Sprintf ("agents/repos/%v/%v/tasks" , owner , repo )
146148
147- req , err := s .client .NewRequest (ctx , "POST" , u , opts , WithVersion ("2026-03-10" ))
149+ req , err := s .client .NewRequest (ctx , "POST" , u , opts , WithVersion (agentTasksAPIVersion ))
148150 if err != nil {
149151 return nil , nil , err
150152 }
@@ -166,7 +168,7 @@ func (s *AgentTasksService) Create(ctx context.Context, owner, repo string, opts
166168func (s * AgentTasksService ) GetByRepoAndID (ctx context.Context , owner , repo , taskID string ) (* AgentTask , * Response , error ) {
167169 u := fmt .Sprintf ("agents/repos/%v/%v/tasks/%v" , owner , repo , taskID )
168170
169- req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion ("2026-03-10" ))
171+ req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion (agentTasksAPIVersion ))
170172 if err != nil {
171173 return nil , nil , err
172174 }
@@ -186,16 +188,13 @@ func (s *AgentTasksService) GetByRepoAndID(ctx context.Context, owner, repo, tas
186188//
187189//meta:operation GET /agents/tasks
188190func (s * AgentTasksService ) List (ctx context.Context , opts * AgentTaskListOptions ) (* AgentTaskList , * Response , error ) {
189- return s .list (ctx , "agents/tasks" , opts )
190- }
191-
192- func (s * AgentTasksService ) list (ctx context.Context , u string , opts * AgentTaskListOptions ) (* AgentTaskList , * Response , error ) {
191+ u := "agents/tasks"
193192 u , err := addOptions (u , opts )
194193 if err != nil {
195194 return nil , nil , err
196195 }
197196
198- req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion ("2026-03-10" ))
197+ req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion (agentTasksAPIVersion ))
199198 if err != nil {
200199 return nil , nil , err
201200 }
@@ -217,7 +216,7 @@ func (s *AgentTasksService) list(ctx context.Context, u string, opts *AgentTaskL
217216func (s * AgentTasksService ) Get (ctx context.Context , taskID string ) (* AgentTask , * Response , error ) {
218217 u := fmt .Sprintf ("agents/tasks/%v" , taskID )
219218
220- req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion ("2026-03-10" ))
219+ req , err := s .client .NewRequest (ctx , "GET" , u , nil , WithVersion (agentTasksAPIVersion ))
221220 if err != nil {
222221 return nil , nil , err
223222 }
0 commit comments