Integrations

AI Tools Integration

Pre-built tool definitions for Vercel AI SDK, Anthropic, OpenAI, and Google Gemini.

AI Tool Definitions

The SDK provides pre-built tool definitions tailored for popular LLM providers. These tools map directly to State memory operations.

Available Imports

TypeScript

  • rice-node-sdk/tools/anthropic - Anthropic Claude format
  • rice-node-sdk/tools/google - Google Gemini format
  • rice-node-sdk/tools/openai - OpenAI function calling format
  • rice-node-sdk/tools/vercel - Vercel AI SDK format (with bound execute functions)

Python

  • rice_sdk.tools.anthropic
  • rice_sdk.tools.google
  • rice_sdk.tools.openai

Example Usage (Vercel AI SDK)

The Vercel AI SDK tools come with execute functions pre-bound to your StateClient, making integration seamless.

import { generateText, stepCountIs } from "ai";
import { google } from "@ai-sdk/google";
import { Client, statetool } from "rice-node-sdk";

const client = new Client({ runId: "my-agent-session" });
await client.connect();

// Create tools bound to your StateClient
const tools = statetool.createVercelTools(client.state);

// Use with generateText - tools are auto-executed!
const result = await generateText({
  model: google("gemini-2.0-flash"),
  tools,
  stopWhen: stepCountIs(5),
  system: `You are an assistant with persistent memory.
Use 'remember' to store facts and 'recall' to search memories.`,
  prompt: "Remember that I prefer Python for ML projects.",
});

console.log(result.text);

Example Usage (Anthropic)

import { state as anthropicTools } from "rice-node-sdk/tools/anthropic";
import { execute } from "rice-node-sdk/tools/execute";
import { Client } from "rice-node-sdk";

const client = new Client();
await client.connect();

// 1. Pass tools to your LLM
const response = await anthropic.messages.create({
  model: "claude-3-opus-20240229",
  tools: anthropicTools,
  // ...
});

// 2. Execute tools invoked by the LLM
for (const toolUse of response.content.filter((c) => c.type === "tool_use")) {
  const result = await execute(toolUse.name, toolUse.input, client.state);
  console.log("Tool result:", result);
}

Example Usage (OpenAI)

import { state as openaiTools } from "rice-node-sdk/tools/openai";
import { execute } from "rice-node-sdk/tools/execute";
import { Client } from "rice-node-sdk";

const client = new Client();
await client.connect();

// 1. Pass tools to OpenAI
const response = await openai.chat.completions.create({
  model: "gpt-4",
  messages: [
    /* ... */
  ],
  tools: openaiTools,
});

// 2. Execute tools
const toolCalls = response.choices[0].message.tool_calls;
if (toolCalls) {
  for (const toolCall of toolCalls) {
    const args = JSON.parse(toolCall.function.arguments);
    const result = await execute(toolCall.function.name, args, client.state);
    console.log("Tool result:", result);
  }
}

Example Usage (Google Gemini)

import { state as googleTools } from "rice-node-sdk/tools/google";
import { execute } from "rice-node-sdk/tools/execute";
import { Client } from "rice-node-sdk";

const client = new Client();
await client.connect();

// 1. Pass tools to Gemini
const model = genAI.getGenerativeModel({
  model: "gemini-2.5-flash",
  tools: [{ functionDeclarations: googleTools }],
});

// 2. Execute tools
const chat = model.startChat();
const result = await chat.sendMessage("Remember that I like pizza.");
const call = result.response.functionCalls()?.[0];

if (call) {
  const result = await execute(call.name, call.args, client.state);
  console.log("Tool result:", result);
}

Tools Included

ToolPurposeSDK Method
focusStore information in short-term working memoryclient.state.focus()
driftRead current items from short-term memoryclient.state.drift()
rememberStore information in long-term persistent memoryclient.state.commit()
recallRetrieve relevant memories from long-term memoryclient.state.reminisce()
triggerTrigger a registered skill or procedureclient.state.trigger()
setVariableSet a structured variable in working memoryclient.state.setVariable()
getVariableGet a structured variable from working memoryclient.state.getVariable()
listVariablesList all variables in working memoryclient.state.listVariables()
deleteVariableDelete a variable from working memoryclient.state.deleteVariable()
defineConceptDefine a concept with JSON schemaclient.state.defineConcept()
listConceptsList all defined conceptsclient.state.listConcepts()
addGoalAdd a new goal to the agent's goal stackclient.state.addGoal()
updateGoalUpdate the status of an existing goalclient.state.updateGoal()
listGoalsList all goals, optionally filtered by statusclient.state.listGoals()
submitActionSubmit an action for execution and loggingclient.state.submitAction()
getActionLogGet the action log for the current runclient.state.getActionLog()
runCycleRun a decision cycle with action candidatesclient.state.runCycle()
getCycleHistoryGet history of decision cyclesclient.state.getCycleHistory()