@Salad95238547: https://x.com/Salad95238547/status/2072971194165563600
Summary
In-depth analysis of ClaudeCode's tool system design, unifying file reading, Shell commands, sub-agents, etc. into a Tool interface, and introducing the implementation mechanisms of concurrent batch processing, asynchronous tasks, and MessageQueueManager.
View Cached Full Text
Cached at: 07/03/26, 02:39 PM
ClaudeCode’s Tool System: Everything is a Tool
Design Philosophy
Whether it’s reading a file, executing a shell command, or dispatching a sub-agent that can run autonomously for dozens of steps, it’s all the same to the LLM: output a tool_use block, wait for a tool_result.
Three lines, three tool calls — the LLM’s perspective is perfectly symmetric.
Tool Interface: A Unified Contract
Every tool implements the same interface. The core is: what call() returns doesn’t matter. Read returns file content, Bash returns stdout, AgentTool returns the sub-agent’s final reply. To the caller, it’s all just a string.
The LLM can request multiple tools at once, and the system splits them into batches:
- For consecutive read-only tools (
isConcurrencySafe = true), they are grouped into a concurrent batch - Any write operation forms its own sequential batch
Someone might ask: what if there’s a background tool call in the middle? In fact, a background tool is an “instant-completing tool” as far as the batch is concerned Once an async tool is invoked, it instantly returns
{ status: 'async_launched', agent_id: '...' }. When the background task actually finishes, the result is stored intomessageQueueManager; let me briefly digress to explainmessageQueueManager. Simply put, think of it as “ClaudeCode’s input queue, holding events that haven’t been processed yet.” There are several priority levels: 1.now— such events immediately terminate the current turn; e.g., user pressingesc. 2.next— after the current turn ends, before the next LLM call; e.g., a normal user message triggers the next turn. 3.later— processed only when the current round is completely idle; e.g., completion notifications for background tasks. When dequeuing, items are taken by priority order, FIFO within the same priority. Simply put, any user input in ClaudeCode goes throughMessageQueueManagerfor management (except slash commands). Back to the async tool: after the async task is dispatched, the LLM immediately receives a message: “Background task dispatched! Task ID: xxxx.” If the LLM can’t wait, it can check earlier. When the task finishes, the result is stored inmessageQueueManagerwithlaterpriority, and at the end of the current turn it gets injected into the context […]
Agent Tool: The Heaviest Tool, But Still a Tool
AgentTool is the “heaviest” Tool in the entire system, yet it follows the exact same interface.
Inside its call(), it does the following: spins up a brand new QueryEngine with its own message history, tool pool, and permission context, then runs a complete agent loop (LLM → tool → LLM → tool…) independently until the task is done.
From the outside, it’s no different from Read: you put an input in, you get a result string out.
Of course, it also uses the same synchronous and asynchronous handling approaches, exactly as described above.
Similar Articles
@thinkszyg: https://x.com/thinkszyg/status/2066837941477920993
A practical guide for developers (especially AI coding tool users) on how to safely and efficiently use Claude Code, Codex, and other tools for multi-agent parallel development, focusing on best practices such as task decomposition, file isolation (worktree), boundary control, sequential merging, etc., to avoid file conflicts and chaos.
@spandan_madan: https://x.com/spandan_madan/status/2067320100911493454
A detailed technical analysis of Claude Code's tool architecture, covering the tool interface, registry, dispatch pipeline, and concurrency scheduler that enable the AI to execute 43+ tools like file reading, shell commands, and web search.
@yaohui12138: I've finished reading it. Here are some key takeaways I've compiled for everyone: In this session, he primarily broke down a core mechanism overlooked by 90% of users: the CLAUDE.md context injection system. This system is divided into three levels: Enterprise-level: Organization-wide mandatory rules that cannot be overridden by individual settings. Project-level: Team-shared code standards and workflows. Loc...
The article shares key insights from a workshop by Boris on using CLAUDE.md for context injection in Claude, highlighting three usage levels, specific commands like /loop, and plan mode to improve developer workflows.
@Khazix0918: https://x.com/Khazix0918/status/2070403772703285575
This article introduces six ways to use Hooks in Claude Code, including permission pop-ups, startup schedule announcements, summary cards, automatic file organization, sedentary reminders, and long task notifications, demonstrating how event-driven automation can improve the efficiency of AI workflows.
@vincemask: The advanced use of Claude lies in building an Agent system that can automatically decompose tasks, generate prompts, assign roles, and review results. An efficient Claude workflow typically includes: 1. Using files like CLAUDE.md to accumulate long-term project context 2. Letting multiple Agents each...
Introduces the advanced use of Claude, which involves building an Agent system that automatically decomposes tasks, generates prompts, assigns roles, and reviews results, including using files like CLAUDE.md to accumulate context and multi-Agent collaboration to build automated workflows.