Issue
Task gets completed under the original agent's name even though the agent had transferred it.
Product
Twilio Flex
Cause
When a task is transferred to another agent either through a warm or a cold transfer, a new reservation is created for the available agent in the target queue.
Once this new reservation is accepted and the agent wraps up the task, the task transitions through the Wrapping and Completed states. At this stage, the task reverts back to the original worker who was initially assigned to this task.
This is the expected behavior. As per the Twilio Flex task lifecycle, the system attributes are updated to reflect the initial worker and not the transferred one.
Resolution
This is the standard behavior. However if the user wants that the transferred agent should remain the owner even after completion, use the TaskRouter REST API to explicitly reassign the workerSid before marking the task as completed.
Additional Information
Lifecycle of a Task: Task state
Warm transfer
Task Resource