Interface IFetchInfoParams<T>

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

  • Called when fetchContent throws an exception
  • Error message is automatically passed to emptyContent handler

Content string to return to AI as tool output

"The tool named {toolName} is not available. Do not ever call it again"
// Fetch user data from database with error handling
const 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);
interface IFetchInfoParams<T = Record<string, any>> {
    emptyContent?: (
        content: string,
        clientId: string,
        agentName: string,
        toolName: string,
    ) => string | Promise<string>;
    fallback?: (error: Error, clientId: string, agentName: string) => void;
    fetchContent: (
        params: T,
        clientId: string,
        agentName: string,
    ) => string | Promise<string>;
}

Type Parameters

  • T = Record<string, any>

    The type of parameters expected by the fetch operation IFetchInfoParams

Properties

emptyContent?: (
    content: string,
    clientId: string,
    agentName: string,
    toolName: string,
) => string | Promise<string>
fallback?: (error: Error, clientId: string, agentName: string) => void
fetchContent: (
    params: T,
    clientId: string,
    agentName: string,
) => string | Promise<string>