Skip to content

Add cancel endpoint for background responses #5180

@cdoern

Description

@cdoern

Summary

Add POST /v1/responses/{response_id}/cancel endpoint to cancel queued or in-progress background responses.

Motivation

The cancelled status already exists in the response schema but there is no API to trigger it. Users need a way to cancel background responses that are queued or still in progress.

Scope

  • CancelResponseRequest model and protocol method
  • Task tracking infrastructure to map response_id to asyncio.Task
  • Background worker handles CancelledError gracefully
  • Proper status transitions and terminal state protection (409 for completed/failed/incomplete responses)
  • Idempotent cancellation support
  • Integration tests covering all cancel scenarios

Tracking PR: #5051

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions