Repository navigation
feat(agent-handoff): Add public claim API - #131113
Conversation
116ee4c to
21d6d69
Compare
|
No findings on the latest commit. |
5da5010 to
3b2fe7c
Compare
ccb6454 to
9d6ade7
Compare
8266681 to
7c1d049
Compare
fa14263 to
1180f21
Compare
| class AgentHandoffClaimRequest(TypedDict): | ||
| handoff_code: Annotated[str, ApiDescription("The private agent handoff code to claim.")] | ||
|
|
||
|
|
||
| class AgentHandoffClaimRequestSerializer(serializers.Serializer[AgentHandoffClaimRequest]): | ||
| handoff_code = serializers.CharField( | ||
| help_text="The private agent handoff code to claim.", | ||
| ) |
There was a problem hiding this comment.
wait do we .. actually need both, is this a normal pattern?
There was a problem hiding this comment.
No, the serializer is sufficient here. I removed the separate TypedDict and now validate request.data through the serializer.
| def post( | ||
| self, request: Request | ||
| ) -> Response[AgentHandoffClaimResponse] | Response[DetailResponse]: | ||
| """Exchange a private handoff code for the context needed to authenticate the CLI.""" |
There was a problem hiding this comment.
And determine the next steps to guide the user or agent.
There was a problem hiding this comment.
Updated the endpoint description to cover determining the next steps used to guide the user or agent.
| handoff_code = serializers.CharField( | ||
| help_text="The private agent handoff code to claim.", | ||
| ) |
There was a problem hiding this comment.
Couldn't this be a regex field then
There was a problem hiding this comment.
Yes. This now uses a RegexField with the exact handoff-code length and pattern, and the endpoint reads only validated_data.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 7f2b365. Configure here.
7f2b365 to
954f923
Compare
|
🚨 Warning: This pull request contains Frontend and Backend changes! It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently. Have questions? Please ask in the |
| if not media_type_matches("application/json", request.content_type): | ||
| return Response({"detail": "Invalid handoff code."}, status=400) |
There was a problem hiding this comment.
not really necessary I think
There was a problem hiding this comment.
Agreed. Removed the explicit media-type check; JSONParser already owns content-type validation.
a3fa33e to
381288b
Compare
53bf5b5 to
5c50c1a
Compare
| if not serializer.is_valid(): | ||
| return Response({"detail": "Invalid handoff code."}, status=400) |
There was a problem hiding this comment.
better to just raise I think?
There was a problem hiding this comment.
Agreed. This now uses is_valid(raise_exception=True) and lets DRF own the validation response.
da9e2da to
59b03b7
Compare
622e30e to
1f505ce
Compare
e6cbf43 to
ca3272a
Compare
…132105) Refreshes `.github/workflows/scripts/backend-test-durations.json` from recent master runs, following #129569. **Source data:** the per-file median of the `backend-test-durations-*` artifacts from three green full-suite master `backend.yml` runs: [45447921880](https://github.com/getsentry/sentry/actions/runs/45447921880), [45445395411](https://github.com/getsentry/sentry/actions/runs/45445395411) and [45442363055](https://github.com/getsentry/sentry/actions/runs/45442363055) (master `712e106928c` through `6a3df08320e`). All three ran 30 shards with 4 workers on `ubuntu-26.04`. The file is the unedited output of the `merge` then `median` commands in the `backend-test-durations.py` docstring. **What changed vs master** (last resync: #131174) - **25 test files added, 6 removed** (the drift trigger). The added files are all under 11s, the largest being `integrations/supabase/test_integration.py` (10.1s) and `integrations/supabase/test_client.py` (9.3s). The removed files, such as the three `api/endpoints/release_thresholds/*` tests, no longer exist on master. - **`seconds_per_test`:** 0.400 → 0.451 (+12.7%), the other drift trigger. - **Files in both versions:** total time +12.9% (19,640s → 22,178s). Four files moved by more than 25% and 30s: - `tests/sentry/seer/endpoints/test_organization_agent_token.py` 493.8s → 748.5s, +52% (runs: 748.5 / 761.8 / 657.2). This crosses the regression bar. Recent commits touching it include #129239, #131473 and #131113. - `tests/snuba/api/endpoints/test_organization_events_span_indexed.py` 208.8s → 262.2s (+26%) - `tests/relay_integration/test_integration.py` 136.7s → 65.3s and `tests/relay_integration/test_message_filters.py` 111.3s → 49.2s. Both drops line up with #131170. **Acceptance durations aren't refreshed here.** `acceptance-test-durations.json` (#132407) gets refreshed from the median of 3 full master `acceptance.yml` runs that upload `acceptance-test-durations-*`. No such run has finished yet, so the coverage-instrumented seed stays in place. The weekly resync replaces it once three exist. **Not changed:** `WORKER_SECONDS_PER_SHARD` and `TESTS_PER_SHARD`. Shared files shifted +12.9%, under the 15% bar for retuning the budget. Opened by the weekly backend test durations resync. <!-- junior-request-attribution:start --> via [automation `sched_24013c871420a6cbab8d518dae1de4ae`](https://junior-prod.sentry.dev/automations/sched_24013c871420a6cbab8d518dae1de4ae) · Run ID `sched_24013c871420a6cbab8d518dae1de4ae:1795248000000`, @joshuarli. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent-dispatch%3Adispatch_6819e6c570f111d16716e7c099e1d6bc --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent-dispatch%3Adispatch_6819e6c570f111d16716e7c099e1d6bc) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent-dispatch%3Adispatch_6819e6c570f111d16716e7c099e1d6bc/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Joshua Li <[email protected]>

The CLI needs a stable machine-readable way to claim a handoff without coupling API behavior to the Markdown controller.
This adds public
POST /api/0/agent-handoff/, accepting a JSON body containinghandoff_codeand returning the Sentry account, organization, setup credentials, and flow instructions as JSON. The existing/agent-handoff.mdand/agent-handoff/routes retain their current behavior during the CLI migration.The endpoint publishes a typed OpenAPI request and response so the claim contract is generated into
@sentry/api.