getTools / getAllTools / clearTools
Problem
After registering tools, you need a way to look them up by name, list everything registered, or reset the registry during testing. Without these utilities, you have no visibility into what the agent can actually access at runtime.
Solution
Three registry query functions give you full control over what is registered:
getTools(name)— fetch one tool by namegetAllTools()— list every registered toolclearTools()— wipe the registry (useful in tests)
Feature & Use-Case
Use these when:
- You want to inspect what tools are available before running an agent
- You are writing unit tests and need to reset the registry between test cases
- You want to validate that a required tool is registered before starting a workflow
Import
import { getTools } from "llm-layer-engine";
getAllToolsandclearToolsare available from the same module path internally. Import them from your tool-registry path if using directly, or usegetToolsfrom the main export.
Function Signatures
function getTools(name: string): Tool | undefined
function getAllTools(): Tool[]
function clearTools(): voidgetTools — Fetch One Tool by Name
import { getTools } from "llm-layer-engine";
const tool = getTools("get_weather");
if (tool) {
const result = await tool.execute({ city: "Karachi" });
console.log(result); // { city: "Karachi", temperature: "28°C" }
} else {
console.log("Tool not found");
}Returns undefined if the name is not registered — so always guard with a null check.
getAllTools — List Every Registered Tool
import { getAllTools } from "llm-layer-engine";
const tools = getAllTools();
tools.forEach((tool) => {
console.log(tool.name);
});
// → get_weather
// → web_searchUseful for debugging or building a dynamic tool-selector UI.
clearTools — Reset the Registry
import { clearTools, registerTool } from "llm-layer-engine";
// In a test file
beforeEach(() => {
clearTools();
});
test("registers a tool correctly", () => {
registerTool({ name: "test_tool", execute: async () => "ok" });
const tool = getTools("test_tool");
expect(tool).toBeDefined();
});Always call clearTools() in test teardown to prevent state leaking between test cases.
Conclusion
These three functions give you full observability and control over the tool registry. Use getTools when you want one tool, getAllTools to inspect the full set, and clearTools to keep tests isolated. They work together with registerTool and executeTools.