Issue
The from collections import defaultdict import was added inside function bodies in multiple places:
api/src/routes/projects.py - lines 368, 537, 650, 1021
api/src/routes/activity.py - line 143
Fix
Move these imports to the top of each file with the other imports.
Note
In get_session() (projects.py ~line 650), the import is unused - sub_agent_ids is built with a regular list, not defaultdict. This import can be removed entirely from that function.