feat(pr-metrics): Capture branch_name in CodingAgentResult for delegated agents#117402
Merged
Merged
Conversation
…ted agents Add branch_name field to CodingAgentResult so the branch the agent created is shipped to Seer alongside the pr_url during state updates. For Claude Code: extract the branch name from the tree URL the agent returns (https://github.com/owner/repo/tree/<branch>) in addition to the existing URL extraction, and populate result.branch_name. For GitHub Copilot: read head_ref from branch-type artifacts returned by the task status API alongside the existing PR artifact lookup. Refs CW-1485 Co-Authored-By: Claude <noreply@anthropic.com>
vaind
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
branch_nametoCodingAgentResultand wires it in for both Claude Code and GitHub Copilot during the polling phase, so the branch the agent created is shipped to Seer alongsidepr_urlin state updates.Why:
branch_namewas never captured anywhere in this system — not in Sentry, not in Seer. It's a useful signal for matching delegated-agent sessions to GitHub PR webhooks (see CW-1485)What changed:
CodingAgentResultgainsbranch_name: str | None = Noneextract_result_from_eventsnow captures the branch name from the regex group in tree URLs (/tree/<branch>), which is what the agent returns whenauto_create_pr=Falsehead_reffrom branch-type artifacts in the task status response, which were already returned by the API but silently ignoredNo status or state transitions are affected — this only adds data to the payload already being sent.
Refs CW-1485
On the seer side,
CodingAgentResultalready includes thebranch_name.