Skip to content

fix(pr-metrics): Resolve run_id/group_id locally for Cursor attribution#119815

Open
giovanni-guidini wants to merge 2 commits into
masterfrom
gio/fix/cursor-pr-attribution-run-group-id
Open

fix(pr-metrics): Resolve run_id/group_id locally for Cursor attribution#119815
giovanni-guidini wants to merge 2 commits into
masterfrom
gio/fix/cursor-pr-attribution-run-group-id

Conversation

@giovanni-guidini

@giovanni-guidini giovanni-guidini commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Enhance the signal_details for Cursor delegated agent attribution. Brings it to parity with other delegated agents rows.


The Cursor delegated-agent webhook wrote SEER_DELEGATED_CURSOR attribution rows with run_id always null and no group linkage, unlike the GitHub Copilot and Claude Code polling paths, which both pass run_id explicitly.

sync_coding_agent_status already looks up the SeerRunCodingAgentHandoff row for the incoming agent_id to update its status — that same row's seer_run gives us the run_id, and the run's SeerAgentRun sibling (populated whenever the run was launched against an issue) gives us the originating group_id. Both are resolvable locally, with no additional Seer round trip.

This threads that data through:

  • sync_coding_agent_status now returns a CodingAgentSyncResult (known_to_seer, run_id, group_id) instead of a bare bool.
  • The Cursor webhook handler passes run_id/group_ids into attribute_delegated_agent_pull_request.
  • DelegatedAgentSignalDetails gains a group_ids field, mirroring the one SentryAppSignalDetails already has.

Considered instead calling Seer's existing /v1/pr-metrics/delegated-agent-match sync endpoint, but that's keyed on group_ids (used to match an anonymous PR back to a run) — the wrong shape here, since Cursor's webhook already tells us unambiguously which agent/PR this is; we just weren't threading the run/group we already had.

The Cursor delegated-agent webhook wrote SEER_DELEGATED_CURSOR attribution
rows with run_id always null and no group linkage, unlike the GitHub
Copilot/Claude Code paths. sync_coding_agent_status already looks up the
SeerRunCodingAgentHandoff row for the agent_id, which is enough to resolve
both the run_id (via its seer_run) and the originating group_id (via the
run's SeerAgentRun sibling) without any additional round trip.

Return both alongside the existing known_to_seer bool as a
CodingAgentSyncResult, thread them into attribute_delegated_agent_pull_request,
and add a group_ids field to DelegatedAgentSignalDetails to carry the group
linkage, mirroring the field SentryAppSignalDetails already has.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 16, 2026
@giovanni-guidini giovanni-guidini marked this pull request as ready for review July 16, 2026 13:08
@giovanni-guidini giovanni-guidini requested a review from a team as a code owner July 16, 2026 13:08
@giovanni-guidini giovanni-guidini requested review from a team and vaind July 16, 2026 13:09
test_seer_rpc.py had two more exact-equality checks on DelegatedAgentSignalDetails
that CI caught after the group_ids field was added; these were missed locally
because that suite wasn't in the set of tests re-run before pushing.

Also addresses code review nits on the prior commit: note that
CodingAgentSyncResult is always truthy as a tuple (check .known_to_seer
explicitly), document the new group_ids param on
attribute_delegated_agent_pull_request, and assert run_id/group_id are still
populated when the local handoff save fails.
@giovanni-guidini giovanni-guidini force-pushed the gio/fix/cursor-pr-attribution-run-group-id branch from 0110e14 to 167c4e5 Compare July 16, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants