AI agent that can create it's own tool implementations for function calling.
- Agent realises if it's tool are enough to complete the user task. If not, it will implement the tool and call it.
- Based on OpenAI/o1 by default, other models can be configured.
- User can approve or reject the new implementations.
- In case of an error the agent can automatically fix the tool and provide a new version of it.
- CLI-based chat interface for now.
- New tools are persisted.
- Set env variable
OPENAI_API_KEY
npm i
npm run start-dev
Starting agent..
Agent initialized with 2 tools:
* git-status
* read_website_content
What would you like to do?
> What is the weather in Espoo currently?
Adding new tool:
I would like to add a new tool get-weather-espoo:
import { get } from "https";
export const tool = {
declaration: {
type: "function",
function: {
name: "get-weather-espoo",
description: "Gets the current weather in Espoo, Finland from open-meteo.com, including temperature, wind speed, wind direction, weather code, and time.",
parameters: {
type: "object",
properties: {},
required: [],
},
},
},
execute: async (toolCall: any) => {
return new Promise((resolve, reject) => {
get("https://api.open-meteo.com/v1/forecast?latitude=60.21&longitude=24.66¤t_weather=true", (res) => {
let data = "";
res.on("data", (chunk) => {
data += chunk;
});
res.on("end", () => {
try {
const json = JSON.parse(data);
const currentWeather = json.current_weather;
resolve({
temperature: currentWeather.temperature,
windspeed: currentWeather.windspeed,
winddirection: currentWeather.winddirection,
weathercode: currentWeather.weathercode,
time: currentWeather.time,
});
} catch (e) {
reject(e);
}
});
}).on("error", (err) => {
reject(err);
});
});
},
};
Do you accept this as new tool get-weather-espoo? (yes/no) yes
importing tool/tools/user-defined/get-weather-espoo.ts
New tool get-weather-espoo added
Currently in Espoo, the temperature is -6.4 °C with a wind speed of 11.9 m/s from a direction of 18 degrees. The weather code is 3 (overcast), and this measurement was taken at 2025-02-14T08:45.
I would like to add a new tool weather-in-espoo:
import { https } from 'node:https';
export const tool = {
declaration: {
type: "function",
function: {
name: "weather-in-espoo",
description: "A tool to retrieve the current weather information for Espoo, Finland. Uses wttr.in, which provides a free JSON endpoint.",
parameters: {
type: "object",
properties: {},
required: []
}
}
},
execute: async (toolCall) => {
// ...
https.get(url, (res) => {
// ...
});
}
};
Do you accept this as new tool weather-in-espoo? (yes/no) no
How should I modify the tool?
> Please use fetch instead of https for fetching the data.
Adding new tool:
I would like to add a new tool weather-in-espoo:
export const tool = {
declaration: {
type: "function",
function: {
name: "weather-in-espoo",
description: "A tool to retrieve the current weather information for Espoo, Finland. Uses wttr.in, which provides a free JSON endpoint.",
parameters: {
type: "object",
properties: {},
required: []
}
}
},
execute: async () => {
// ..
const response = await fetch(url);
// ..
}
};
Do you accept this as new tool weather-in-espoo? (yes/no)