The SDK provides pre-built tool definitions tailored for popular LLM providers. These tools map directly to State memory operations.
rice-node-sdk/tools/anthropic - Anthropic Claude formatrice-node-sdk/tools/google - Google Gemini formatrice-node-sdk/tools/openai - OpenAI function calling formatrice-node-sdk/tools/vercel - Vercel AI SDK format (with bound execute functions)rice_sdk.tools.anthropicrice_sdk.tools.googlerice_sdk.tools.openaiThe 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);
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);
}
from rice_sdk.tools.anthropic import tools as anthropic_tools
from rice_sdk.tools.execute import execute
from rice_sdk import Client
client = Client()
client.connect()
# 1. Pass tools to your LLM
response = anthropic.messages.create(
model="claude-3-opus-20240229",
tools=anthropic_tools,
# ...
)
# 2. Execute tools invoked by the LLM
for block in response.content:
if block.type == "tool_use":
result = execute(block.name, block.input, client.state)
print(f"Tool result: {result}")
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);
}
}
from rice_sdk.tools.openai import tools as openai_tools
from rice_sdk.tools.execute import execute
from rice_sdk import Client
import json
client = Client()
client.connect()
# 1. Pass tools to OpenAI
response = openai.chat.completions.create(
model="gpt-4",
messages=[
# ...
],
tools=openai_tools,
)
# 2. Execute tools
tool_calls = response.choices[0].message.tool_calls
if tool_calls:
for tool_call in tool_calls:
args = json.loads(tool_call.function.arguments)
result = execute(tool_call.function.name, args, client.state)
print(f"Tool result: {result}")
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);
}
from rice_sdk.tools.google import tools as google_tools
from rice_sdk.tools.execute import execute
from rice_sdk import Client
client = Client()
client.connect()
# 1. Pass tools to Gemini
model = genai.GenerativeModel(
model_name="gemini-1.5-flash",
tools=[google_tools]
)
# 2. Execute tools
chat = model.start_chat()
result = chat.send_message("Remember that I like pizza.")
# (Function call handling varies by library version)
| Tool | Purpose | SDK Method |
|---|---|---|
focus | Store information in short-term working memory | client.state.focus() |
drift | Read current items from short-term memory | client.state.drift() |
remember | Store information in long-term persistent memory | client.state.commit() |
recall | Retrieve relevant memories from long-term memory | client.state.reminisce() |
trigger | Trigger a registered skill or procedure | client.state.trigger() |
setVariable | Set a structured variable in working memory | client.state.setVariable() |
getVariable | Get a structured variable from working memory | client.state.getVariable() |
listVariables | List all variables in working memory | client.state.listVariables() |
deleteVariable | Delete a variable from working memory | client.state.deleteVariable() |
defineConcept | Define a concept with JSON schema | client.state.defineConcept() |
listConcepts | List all defined concepts | client.state.listConcepts() |
addGoal | Add a new goal to the agent's goal stack | client.state.addGoal() |
updateGoal | Update the status of an existing goal | client.state.updateGoal() |
listGoals | List all goals, optionally filtered by status | client.state.listGoals() |
submitAction | Submit an action for execution and logging | client.state.submitAction() |
getActionLog | Get the action log for the current run | client.state.getActionLog() |
runCycle | Run a decision cycle with action candidates | client.state.runCycle() |
getCycleHistory | Get history of decision cycles | client.state.getCycleHistory() |