Tool Lazy Loading

Tool Lazy Loading Mechanism

Hawa Code supports tool lazy loading functionality. By default, the system does not provide all tools to the model at once. Instead, the model dynamically selects and loads the required tools based on actual needs. This lazy loading mechanism significantly reduces token consumption.

Key Features

  • Lifecycle Management: Loaded tools remain effective until the end of a single conversation. When users engage in multiple interactions, tools are automatically unloaded after each conversation ends and need to be reloaded for the next conversation.

  • Tool Adaptation: Currently, both Hawa Code built-in tools and custom MCP tools support lazy loading functionality.

  • Automatic Unloading: If certain tools are not needed for the current task, Hawa Code automatically unloads them.

Usage

Set the following environment variable to enable tool lazy loading mode. Restart the terminal for the changes to take effect:

HAWA_CODE_LAZY_TOOL=true

Environment Variable Configuration Methods:

  1. Recommended Method: Configure directly in the env field of ~/.hcode/settings.json
  2. System Environment Variables: Configure through the operating system’s environment variable mechanism