Deep agent live run: parallel tool calls race on shared run files
When a deepagents/langgraph agent's tools read-modify-write a shared file (e.g. an upsert into measures.json), the model's parallel tool calls run in threads and overwrite each other: a live run saved 4 measures while the report named more. Serialise tool calls per run with a threading.RLock in the tool wrapper, and add a ThreadPoolExecutor test. Other gotchas: resume an interrupt with Command(resume={"value": v}) even for None (bare None breaks langgraph); hold the final done event until the result is saved and the run is marked inactive, so GET agrees with the stream; a resumed segment drops earlier questions from the saved result, so re-add them. Subagents only call a tool (here sensitivity) if the prompt names it. Use UsageMetadataCallbackHandler in config callbacks to total tokens across subagents.