Configuration parameters for creating a fetch info handler (READ pattern). Defines the data fetching logic without modifying system state.
The name of the current agent
Content string to return to AI as tool output
"The tool named {toolName} is not available. Do not ever call it again" Copy
"The tool named {toolName} is not available. Do not ever call it again"
// Fetch user data from database with error handlingconst fetchUserData = createFetchInfo({ fallback: (error, clientId, agentName) => { console.error(`Failed to fetch user data for ${clientId} (${agentName}):`, error); }, fetchContent: async (params, clientId) => { const user = await getUserData(params.userId); return JSON.stringify(user); }, emptyContent: (content) => content || "User not found",});await fetchUserData("tool-123", "client-456", "UserAgent", "FetchUserData", { userId: "123" }, true); Copy
// Fetch user data from database with error handlingconst fetchUserData = createFetchInfo({ fallback: (error, clientId, agentName) => { console.error(`Failed to fetch user data for ${clientId} (${agentName}):`, error); }, fetchContent: async (params, clientId) => { const user = await getUserData(params.userId); return JSON.stringify(user); }, emptyContent: (content) => content || "User not found",});await fetchUserData("tool-123", "client-456", "UserAgent", "FetchUserData", { userId: "123" }, true);
The type of parameters expected by the fetch operation IFetchInfoParams
Optional
Configuration parameters for creating a fetch info handler (READ pattern). Defines the data fetching logic without modifying system state.
Param: error
The error object thrown during fetch
Param: clientId
The client identifier
Param: agentName
The name of the current agent
Param: params
Tool call parameters (validated if validateParams was provided in addFetchInfo)
Param: clientId
The client identifier
Param: agentName
The name of the current agent
Returns
Content string to return to AI as tool output
Param: content
The empty content from fetchContent
Param: clientId
The client identifier
Param: agentName
The name of the current agent
Param: toolName
The tool name
Returns
Message to commit as tool output
Default
Example