Skip to content

Tools

defineTool(options: ToolDefinitionOptions): ToolDefinition
import { defineTool } from 'agentfootprint';
const tool = defineTool({
id: 'search',
description: 'Search the web',
inputSchema: {
type: 'object',
properties: { query: { type: 'string' } },
required: ['query'],
},
handler: async (args) => {
return { content: 'Search results...' };
},
});
FieldTypeDescription
idstringUnique tool identifier
descriptionstringWhat the tool does (shown to LLM)
inputSchemaobjectJSON Schema for arguments
handler(args) => Promise<ToolResult>Execution function
interface ToolResult {
content: string; // Result text returned to LLM
error?: boolean; // true if the tool failed
}

Special tool that pauses the agent for human input:

import { askHuman } from 'agentfootprint';
const agent = Agent.create({ provider })
.tool(askHuman())
.build();
interface ToolProvider {
resolve(ctx: ToolContext): {
value: LLMToolDescription[];
chosen: string;
rationale?: string;
};
execute?(call: ToolCall, signal?: AbortSignal): Promise<ToolExecutionResult>;
}
import { staticTools } from 'agentfootprint/providers';
import { gatedTools, PermissionPolicy } from 'agentfootprint/security';
// gatedTools wraps a ToolProvider (not an array)
const gated = gatedTools(staticTools(allTools), policy.checker());
agent.toolProvider(gated);