How can I solve this constrained assignment problem?
This can be formulated as an instance of minimum-cost flow problem.  Have a graph with one vertex per agent, one vertex per task, and one vertex per category.  Now add edges:


Add an edge from the source to each agent, with capacity 1 and cost 0.
Add an edge from each agent to each task, with capacity 1 and cost according to the cost of that assignment.
Add an edge from each task to the category it is part of, with capacity 1 and cost 0.
Add an edge from each category to the sink, with capacity given by the maximum number of tasks assignable in that category and cost 0.


Now find the minimum-cost flow of size $t$, where $t$ is the number of tasks.  There are polynomial-time algorithms for that.