Configuration object for the fetch tool
The registered agent tool schema
// Fetch user data with parameter validation and error handling
addFetchInfo({
toolName: "fetch_user_data",
function: {
name: "fetch_user_data",
description: "Fetch user data by user ID",
parameters: {
type: "object",
properties: {
userId: { type: "string", description: "User ID to fetch" },
},
required: ["userId"],
},
},
fallback: (error, clientId, agentName) => {
logger.error("Failed to fetch user data", { error, clientId, agentName });
},
validateParams: async ({ params, clientId, agentName, toolCalls }) => {
// Returns true if valid, false if invalid
return !!params.userId;
},
fetchContent: async (params, clientId) => {
const userData = await getUserData(params.userId);
return JSON.stringify(userData);
},
emptyContent: (content) => content || "User not found",
});
Creates and registers a fetch info tool for AI to retrieve data (READ pattern). This implements the READ side of the command pattern - AI calls tool to get information without modifying state.
Flow: