fix(pr-metrics): Resolve run_id/group_id locally for Cursor attribution#119815
Open
giovanni-guidini wants to merge 2 commits into
Open
fix(pr-metrics): Resolve run_id/group_id locally for Cursor attribution#119815giovanni-guidini wants to merge 2 commits into
giovanni-guidini wants to merge 2 commits into
Conversation
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.
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.
0110e14 to
167c4e5
Compare
vaind
approved these changes
Jul 16, 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.
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_CURSORattribution rows withrun_idalways null and no group linkage, unlike the GitHub Copilot and Claude Code polling paths, which both passrun_idexplicitly.sync_coding_agent_statusalready looks up theSeerRunCodingAgentHandoffrow for the incomingagent_idto update its status — that same row'sseer_rungives us therun_id, and the run'sSeerAgentRunsibling (populated whenever the run was launched against an issue) gives us the originatinggroup_id. Both are resolvable locally, with no additional Seer round trip.This threads that data through:
sync_coding_agent_statusnow returns aCodingAgentSyncResult(known_to_seer,run_id,group_id) instead of a bare bool.run_id/group_idsintoattribute_delegated_agent_pull_request.DelegatedAgentSignalDetailsgains agroup_idsfield, mirroring the oneSentryAppSignalDetailsalready has.Considered instead calling Seer's existing
/v1/pr-metrics/delegated-agent-matchsync endpoint, but that's keyed ongroup_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.