MCPcopy Create free account
hub / github.com/github/gh-aw / evalAssignToAgent

Function evalAssignToAgent

pkg/cli/outcome_eval_agent.go:13–129  ·  view source on GitHub ↗

evalAssignToAgent checks whether an agent assignment led to a PR that was merged.

(item CreatedItemReport, repoOverride string)

Source from the content-addressed store, hash-verified

11
12// evalAssignToAgent checks whether an agent assignment led to a PR that was merged.
13func evalAssignToAgent(item CreatedItemReport, repoOverride string) OutcomeReport {
14 repo := resolveItemRepo(item, repoOverride)
15 num := resolveItemNumber(item)
16 outcomeEvalAgentLog.Printf("Evaluating assign_to_agent: repo=%s, num=%d, url=%s", repo, num, item.URL)
17 report := OutcomeReport{
18 Type: item.Type,
19 ObjectURL: item.URL,
20 ObjectNumber: num,
21 Repo: repo,
22 }
23 if num == 0 || repo == "" {
24 outcomeEvalAgentLog.Printf("Missing issue number or repo: num=%d, repo=%s", num, repo)
25 report.Result = OutcomeError
26 report.EvalError = "missing issue number or repo"
27 return report
28 }
29
30 // Check issue state first
31 issueData, err := ghAPIGet(fmt.Sprintf("issues/%d", num), repo)
32 if err != nil {
33 report.Result = OutcomeError
34 report.EvalError = err.Error()
35 return report
36 }
37
38 state, _ := issueData["state"].(string)
39 stateReason, _ := issueData["state_reason"].(string)
40
41 // Search for linked PRs from copilot-swe-agent via timeline events
42 events, err := ghAPIGetArray(fmt.Sprintf("issues/%d/timeline", num), repo)
43 var agentPR map[string]any
44 if err == nil {
45 for _, event := range events {
46 eventType, _ := event["event"].(string)
47 if eventType != "cross-referenced" {
48 continue
49 }
50 source, _ := event["source"].(map[string]any)
51 if source == nil {
52 continue
53 }
54 issue, _ := source["issue"].(map[string]any)
55 if issue == nil {
56 continue
57 }
58 // Check if it's a PR (has pull_request field)
59 if _, hasPR := issue["pull_request"]; !hasPR {
60 continue
61 }
62 user, _ := issue["user"].(map[string]any)
63 login, _ := user["login"].(string)
64 if strings.Contains(login, "copilot") || strings.Contains(login, "github-actions") {
65 agentPR = issue
66 break
67 }
68 }
69 }
70

Callers

nothing calls this directly

Calls 7

resolveItemRepoFunction · 0.85
resolveItemNumberFunction · 0.85
ghAPIGetFunction · 0.85
ghAPIGetArrayFunction · 0.85
timeBetweenFunction · 0.85
PrintfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected