11. Tool Contracts in Tool.ts
This File Defines the Agent Platform
Tool.ts is one of the most important files in the tree because it defines the common contract between the model,
the tool runtime, permissions, UI updates, MCP metadata, and session state. If you want to understand how the app scales to many tools,
this is the file to internalize.
What the Contract Includes
| Area | Examples in the contract | Why it matters |
|---|---|---|
| Execution | call(), input schema, result shape | Standardizes how tools are invoked. |
| Permissioning | checkPermissions(), permission context, matcher hooks | Makes tool access governable instead of implicit. |
| Safety metadata | isReadOnly(), isDestructive(), isConcurrencySafe() | Lets the system reason about risk and scheduling. |
| UI behavior | progress callbacks, interrupt behavior, search/read collapsing | Lets tools integrate into the terminal product experience. |
| Interop | MCP metadata and schema passthrough | Keeps external tool ecosystems compatible. |
Key Lesson
Good agent systems do not just have “tools.” They have typed tool contracts with runtime context, policy semantics, and UX semantics. That is the difference between a toy agent and a maintainable product surface.
Source Navigation
Recommended Source Files
source/Tool.tssource/tools.tssource/services/tools/toolExecution.tssource/services/tools/toolOrchestration.tssource/services/tools/StreamingToolExecutor.ts
Next Files to Read
source/tools/BashTool/BashTool.tsxsource/tools/FileReadTool/FileReadTool.tssource/tools/AgentTool/AgentTool.tsx