Tools

Tools give Agents and Prompts access to external data and enable them to take action.

Tools on Humanloop are used to extend Agents and Prompts with access to external data sources and enable them to take action.

Types of Tools

Runnable Tools

Runnable Tools can be executed by Humanloop, meaning they can form a part of an Agent’s automatic execution. Python code Tools, an example of these, are run in a secure Python runtime and allow you to write custom code to be executed.

Editor for a Python Tool showing a `calculate` function and a calculation output.
An example Python Tool

Template Tools

Template Tools can be used within a Prompt’s template to dynamically insert information for the model when called. These include:

  • Snippet Tools: Reusable text components that can be shared across multiple Prompts
  • Integration Tools: Pre-built connectors to popular services like Google Search and Pinecone vector database
Editor for a Snippet Tool showing a `humanloop_context` Tool with various key-value pairs.

An example Snippet Tool. This can be referred to within a Prompt template with {{humanloop_context(key)}}.

Function calling Tools

Many models, such as those by OpenAI and Anthropic, now support function calling. You can provide these models with definitions of the available tools. The model then decides whether to call a tool, and which parameters to use.

On Humanloop, JSON schema Tools record the schema definitions that are used for function calling, allowing you to tweak and version control them.

1{
2 "name": "get_current_weather",
3 "description": "Get the current weather in a given location",
4 "parameters": {
5 "type": "object",
6 "properties": {
7 "location": {
8 "type": "string",
9 "name": "Location",
10 "description": "The city and state, e.g. San Francisco, CA"
11 },
12 "unit": {
13 "type": "string",
14 "name": "Unit",
15 "enum": [
16 "celsius",
17 "fahrenheit"
18 ]
19 }
20 },
21 "required": [
22 "location",
23 "unit"
24 ]
25 }
26}
A JSON schema Tool definition for getting current weather information.

In addition to JSON schema Tools, all Runnable Tools and Prompts can be used for function calling. Humanloop will automatically generate the schema definitions for these when they’re linked to a Agent or Prompt.

Agent Editor with a Calculator Tool linked. The Tool is called by the Agent and the results are shown.
A Calculator Python Tool linked to an Agent. When an Agent calls this Tool, Humanloop will automatically execute it and return the result back to the Agent.

Humanloop runtime versus your runtime

Humanloop supports running Python code Tools within the Humanloop runtime. If you have Tools that you want to run in your own environment, you can use the Humanloop API to manage versions and record Logs.

The simplest way to do this is by decorating a function with the Tool decorator in the SDK. Running the decorated function will automatically log the inputs and output of the function to Humanloop. If you’re using the Python SDK, the @tool decorator will also infer a JSON schema from the function’s type hints.