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

AreaExamples in the contractWhy it matters
Executioncall(), input schema, result shapeStandardizes how tools are invoked.
PermissioningcheckPermissions(), permission context, matcher hooksMakes tool access governable instead of implicit.
Safety metadataisReadOnly(), isDestructive(), isConcurrencySafe()Lets the system reason about risk and scheduling.
UI behaviorprogress callbacks, interrupt behavior, search/read collapsingLets tools integrate into the terminal product experience.
InteropMCP metadata and schema passthroughKeeps 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.ts
  • source/tools.ts
  • source/services/tools/toolExecution.ts
  • source/services/tools/toolOrchestration.ts
  • source/services/tools/StreamingToolExecutor.ts

Next Files to Read

  • source/tools/BashTool/BashTool.tsx
  • source/tools/FileReadTool/FileReadTool.ts
  • source/tools/AgentTool/AgentTool.tsx