The salvaged regression exercises the worker counter and the shutdown gate
directly; this one drives the production entry point (APIServerAdapter._run_agent),
cancels the handler task while the executor thread is parked in the turn, and
asserts the worker-scoped count survives the cancellation and is released only when
the worker exits. Reverting just the api_server.py call-site hunk turns it red.
Refs #116535.