TypeScriptADK-TS

Built-in Tools

Ready-to-use tools for common tasks like search, file operations, and user interaction

ADK-TS provides a collection of pre-built tools that handle common agent tasks. These tools are tested, optimized, and ready to use without custom development. Simply import the tool you need and add it to your agent's tools list.

Quick Start

Here's how to use built-in tools with your agent:

import { LlmAgent, GoogleSearch, HttpRequestTool } from "@iqai/adk";

const agent = new LlmAgent({
  name: "research_agent",
  description:
    "An agent that helps users research topics using web search and HTTP requests.",
  instruction: "Help users research topics using web search and HTTP requests",
  tools: [new GoogleSearch(), new HttpRequestTool()],
});

That's it! The agent can now search the web and make HTTP requests.

Available Tools

ADK-TS includes these built-in tools:

ToolPurposeRequires Config
GoogleSearchSearch the web for informationNo
HttpRequestToolMake HTTP requests to APIsNo
FileOperationsToolRead/write files on diskOptional
UserInteractionToolPrompt users for inputNo
LoadMemoryToolSearch conversation historyNo
LoadArtifactsToolAccess uploaded filesNo
GetUserChoiceToolPresent multiple choice optionsNo
TransferToAgentToolHand off to another agentNo
ExitLoopToolExit workflow loopsNo

GoogleSearch

Search the web for real-time information.

Import:

import { LlmAgent, GoogleSearch } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "research_agent",
  description: "A research assistant that searches the web for information",
  tools: [new GoogleSearch()],
});

Tool Parameters:

ParameterTypeRequiredDescription
querystringYesThe search query to execute
num_resultsnumberNoNumber of results to return (default: 5, max: 10)

How It's Triggered:

The agent automatically uses this tool when the user asks about current information:

// User: "What are the latest updates about AI in 2024?"
// Agent internally decides it needs current information, so it calls:
// google_search({ query: "latest AI updates 2024", num_results: 5 })
// Agent receives search results and summarizes them for the user

Capabilities:

  • Real-time web search results
  • Configurable number of results
  • LLM-friendly response formatting

Current Status

The current GoogleSearch implementation returns mock results. Production use requires integration with actual Google Search API and proper credentials.

HttpRequestTool

Make HTTP requests to APIs and web services.

Import:

import { LlmAgent, HttpRequestTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "api_agent",
  description: "An agent that integrates with external APIs and services",
  tools: [new HttpRequestTool()],
});

Tool Parameters:

ParameterTypeRequiredDescription
urlstringYesThe URL to request
methodstringNoHTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS). Default: GET
headersobjectNoCustom headers (e.g., { "Authorization": "Bearer token" })
bodystringNoRequest body (for POST, PUT, PATCH)
paramsobjectNoURL query parameters to include
timeoutnumberNoRequest timeout in milliseconds. Default: 10000

How It's Triggered:

The agent uses this tool when it needs to call an external API:

// User: "Get the weather from the API"
// Agent calls:
// http_request({
//   url: "https://api.weather.com/forecast?city=london",
//   method: "GET",
//   headers: { "Authorization": "Bearer YOUR_API_KEY" }
// })
// Agent receives the response and processes it

Capabilities:

  • All HTTP methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
  • Custom headers for authentication
  • JSON and form data support
  • Response parsing

FileOperationsTool

Read, write, and manage files on disk.

Import:

import { LlmAgent, FileOperationsTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "file_agent",
  description: "An agent that manages file operations on the local filesystem",
  tools: [
    new FileOperationsTool({
      basePath: "/safe/directory", // Optional, defaults to cwd
    }),
  ],
});

Tool Parameters:

ParameterTypeRequiredDescription
operationstringYesOperation to perform: read, write, append, delete, exists, list, mkdir
filepathstringYesFile or directory path (relative to basePath)
contentstringNoContent to write (required for write and append)
encodingstringNoFile encoding to use. Default: utf8

How It's Triggered:

// User: "Save this data to a file called results.txt"
// Agent calls:
// file_operations({
//   operation: "write",
//   path: "results.txt",
//   content: "The data to save"
// })
// Agent: "Saved data to results.txt"

// User: "Read the contents of config.json"
// Agent calls:
// file_operations({
//   operation: "read",
//   path: "config.json"
// })
// Agent reads and displays the content

Supported Operations:

  • read - Read file contents
  • write - Write or overwrite files
  • append - Add content to existing files
  • delete - Remove files
  • exists - Check if file exists
  • list - List directory contents
  • mkdir - Create directories

Capabilities:

  • Read and write files with multiple encodings
  • Directory management (create, list)
  • File existence checks
  • Append to existing files
  • Delete files safely

Security:

  • Limited to specified basePath directory
  • Prevents path traversal attacks
  • Validates all file operations

UserInteractionTool

Prompt users for input during agent execution.

Import:

import { LlmAgent, UserInteractionTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "approval_agent",
  description: "An agent that handles user approvals and confirmations",
  tools: [new UserInteractionTool()],
});

Tool Parameters:

The LLM calls this tool with these parameters:

ParameterTypeRequiredDescription
promptstringYesThe question or message to display to the user
optionsarray of stringsNoMultiple choice options to present to the user
defaultValuestringNoDefault value if user provides no input

How It's Triggered:

The agent triggers this tool when it needs user input. For example:

// User: "I want to delete my account"
// Agent internally decides it needs confirmation, so it calls user_interaction:

// The agent LLM generates a call like:
// user_interaction({
//   prompt: "Are you absolutely sure you want to delete your account? This cannot be undone.",
//   options: ["Yes, delete it", "No, keep it"]
// })

// User sees: "Are you absolutely sure you want to delete your account? This cannot be undone?"
//            1. Yes, delete it
//            2. No, keep it
// User chooses: 1
// Agent receives: "Yes, delete it" and proceeds with deletion

Capabilities:

  • Get approval for critical actions
  • Present multiple options and let user choose
  • Confirm important operations before execution
  • Collect user preferences
  • Multi-step workflows requiring decisions
  • Support for default values

Long-Running by Nature

The UserInteractionTool is marked as isLongRunning: true because it waits for user input. The agent will pause execution until the user responds.

LoadMemoryTool

Search conversation history and past interactions.

Import:

import { LlmAgent, LoadMemoryTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "context_agent",
  description: "An agent that maintains context across conversations",
  tools: [new LoadMemoryTool()],
});

Tool Parameters:

ParameterTypeRequiredDescription
querystringYesWhat to search for in memory (e.g., "previous purchases")

How It's Triggered:

The agent uses this to recall past information:

// User: "What did I ask you about last time?"
// Agent calls:
// load_memory({ query: "previous conversation topics" })
// Agent retrieves relevant memories and responds with the information

// User: "I have that preference set, right?"
// Agent calls:
// load_memory({ query: "user preferences" })
// Agent confirms based on retrieved memory

Capabilities:

  • Search past conversations
  • Retrieve user preferences
  • Reference previous decisions
  • Maintain context across sessions

LoadArtifactsTool

Access and process uploaded files.

Import:

import { LlmAgent, LoadArtifactsTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "document_analyzer_agent",
  description: "An agent that analyzes and processes uploaded documents",
  tools: [new LoadArtifactsTool()],
});

Tool Parameters:

ParameterTypeRequiredDescription
artifact_namesarrayNoList of artifact names to load

How It's Triggered:

// User uploads files and asks: "Analyze my resume"
// Agent calls:
// load_artifacts({ artifact_names: ["resume.pdf"] })
// Agent retrieves the uploaded resume and analyzes it

// User: "What's in the contract?"
// Agent calls:
// load_artifacts({ artifact_names: ["contract.pdf"] })
// Agent reads and analyzes the contract

Capabilities:

  • Load specific artifacts by name
  • Access file contents
  • Automatic format detection
  • Support for various file types (PDF, images, text, etc.)
  • List all available artifacts

GetUserChoiceTool

Present users with multiple options and collect their selection.

Import:

import { LlmAgent, GetUserChoiceTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "choice_agent",
  description: "An agent that presents options and collects user selections",
  tools: [new GetUserChoiceTool()],
});

Tool Parameters:

ParameterTypeRequiredDescription
optionsarrayYesList of options for the user to choose from
questionstringNoThe question or prompt to show before presenting options

How It's Triggered:

// User: "I want to choose a subscription plan"
// Agent calls:
// get_user_choice({
//   question: "Which plan would you like?",
//   options: ["Basic - $9/month", "Pro - $29/month", "Enterprise - $99/month"]
// })
// User sees numbered options and selects one
// Agent receives the selected option and proceeds

Capabilities:

  • Present multiple choice options
  • Optional question/prompt text
  • Returns user's selected choice
  • Long-running operation (waits for user input)

TransferToAgentTool

Hand off work to another specialized agent.

Import:

import { LlmAgent, TransferToAgentTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "router_agent",
  description: "An agent that routes requests to specialized agents",
  tools: [new TransferToAgentTool()],
});

Tool Parameters:

ParameterTypeRequiredDescription
agent_namestringYesThe name of the agent to transfer control to

How It's Triggered:

// User: "I need help with my payment"
// Router agent recognizes this is a payment issue and calls:
// transfer_to_agent({ agent_name: "payment_specialist_agent" })
// Control transfers to the payment specialist agent

// User: "Can you check my order status?"
// Router agent calls:
// transfer_to_agent({ agent_name: "order_tracking_agent" })
// Control transfers to the order tracking agent

Capabilities:

  • Transfer control to specialized agents
  • Enable agent orchestration
  • Route requests based on expertise
  • Maintain conversation context during transfer

ExitLoopTool

Exit from workflow loops when completion criteria are met.

Import:

import { LlmAgent, ExitLoopTool } from "@iqai/adk";

Setup:

const agent = new LlmAgent({
  name: "loop_agent",
  description: "An agent that processes items in loops with exit control",
  tools: [new ExitLoopTool()],
});

Tool Parameters:

This tool takes no parameters.

How It's Triggered:

// Agent is processing items in a loop
// When instructed to exit, agent calls:
// exit_loop()
// Loop execution terminates and control returns to parent workflow

// Example workflow:
// Agent: Processing item 1... done
// Agent: Processing item 2... done
// Agent: Processing item 3... done
// Agent: All items processed, calling exit_loop()
// Workflow exits loop successfully

Capabilities:

  • Exit from execution loops
  • Controlled loop termination
  • Signal completion to parent workflow
  • Prevent infinite loops

Tool Combinations

Combine multiple built-in tools to create powerful agent capabilities. Here are some common combinations:

Information Gathering

Combine search and memory tools for comprehensive research that builds on previous conversations:

const researchAgent = new LlmAgent({
  name: "researcher_agent",
  description:
    "A research assistant that searches the web for current information and recalls relevant details from previous conversations to provide comprehensive, context-aware answers",
  instruction:
    "Use web search to find current information, then check memory for related previous discussions to provide complete context",
  tools: [new GoogleSearch(), new LoadMemoryTool()],
});

Document Processing

Process uploaded documents and save analysis results to files:

const documentAgent = new LlmAgent({
  name: "document_processor_agent",
  description:
    "An agent that analyzes uploaded documents, extracts key information, and saves processed results or reports to the filesystem",
  instruction:
    "Load and analyze uploaded documents, then save your findings, summaries, or processed data to files for future reference",
  tools: [
    new LoadArtifactsTool(),
    new FileOperationsTool({ basePath: "/output" }),
  ],
});

API Integration

Call external APIs and save response data for analysis or caching:

const apiAgent = new LlmAgent({
  name: "api_integration_agent",
  description:
    "An agent that calls external APIs to fetch data, processes the responses, and saves important information to files for later analysis or caching",
  instruction:
    "Make API calls to retrieve data, process the responses, and save relevant information to files for future reference or analysis",
  tools: [new HttpRequestTool(), new FileOperationsTool()],
});

Interactive Workflows

Collect user input and confirmations while managing file operations:

const interactiveAgent = new LlmAgent({
  name: "interactive_workflow_agent",
  description:
    "An agent that guides users through multi-step processes, collects their input and confirmations, and manages files as part of the workflow",
  instruction:
    "Interact with users to gather requirements and approvals, then perform file operations based on their input and decisions",
  tools: [new UserInteractionTool(), new FileOperationsTool()],
});

Built-in Tool Best Practices

To effectively use built-in tools in your agents:

  • Choose Relevant Tools: Only add tools that match your agent's purpose. Too many tools can confuse the LLM.
  • Configure Safely: Set restrictive basePath for FileOperationsTool to prevent unauthorized access.
  • Handle External Failures: Tools that call external services (GoogleSearch, HttpRequestTool) depend on network availability. Design agents to handle failures gracefully.
  • Secure Authentication: Be cautious with authentication headers in logs when using HttpRequestTool.
  • Protect Sensitive Data: Don't expose sensitive information in UserInteractionTool prompts.
  • Trust Built-in Error Handling: Built-in tools handle common errors automatically (network failures, invalid files, user cancellations).

How is this guide?