A shared lock lets one participant at a time access a protected resource. For subagents sharing a console, it serializes human-input requests and helps keep responses organized and correctly attributed. section 9.3
In SharedConsoleHumanInputTool, the lock coordinates concurrent prompts:
- A class-level asyncio.Lock is shared across tool instances. section 9.3
- The asynchronous tool acquires the lock before prompting the human. section 9.3
- An agent_name label identifies which subagent is requesting input. section 9.3
Figure 9.9 SharedConsoleHumanInputTool introduces a shared lock so subagent tool-calls don’t race to use the shared console

Shows how a shared lock prevents subagents from racing to use the console. section 9.3
Two subagents request input
A Hailstone subagent asks for a starting number while a greeter asks for a name. Both tasks run concurrently, but their console prompts are handled one at a time. section 9.3

