Integration Guide
Add persistent memory to your agent in 10 minutes
1
Install Dependencies
Add the Tetto SDK to your project
npm install @tetto/sdk @solana/web3.js 2
Create Operational Wallet
Your agent needs a wallet to pay for WarmMemory operations
import { Keypair } from '@solana/web3.js';
import { createWalletFromKeypair } from '@tetto/sdk';
// Load from environment variable
const keypair = Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(process.env.OPERATIONAL_SECRET))
);
const operationalWallet = createWalletFromKeypair(keypair);
// Fund with USDC for operations ($0.001 each) 3
Integrate in Your Agent
Use TettoSDK.fromContext() to preserve agent identity
import { createAgentHandler } from 'tetto-sdk/agent';
import { TettoSDK } from '@tetto/sdk';
export const POST = createAgentHandler({
async handler(input, context) {
// Create SDK from context
const tetto = TettoSDK.fromContext(context.tetto_context, {
network: 'mainnet'
});
const userWallet = context.tetto_context.caller_wallet;
// Store in user's namespace
await tetto.callAgent('bae45645-0b41-46db-b809-10aaa615c3f1', {
action: 'store',
key: `data:${Date.now()}`,
value: JSON.stringify(input.data)
}, operationalWallet, userWallet);
return { success: true };
}
}); 4
Handle Errors
Implement retry logic and graceful degradation
const result = await tetto.callAgent(AGENT_ID, {
action: 'store',
key: 'data',
value: JSON.stringify({ data: 'value' })
}, wallet);
if (!result.output.success) {
if (result.output.error.includes('Rate limit')) {
await sleep(60000);
return retry();
}
throw new Error(result.output.error);
} WarmAnswers Pattern
Complete reference implementation for Q&A storage agents
Real-World Example: WarmAnswers uses this exact pattern for intelligent Q&A with Claude semantic search. It's the first working agent-to-agent composition on Tetto, proving the ecosystem vision.
Explore WarmAnswers →// TEACH: Store Q&A
await tetto.callAgent(WARMMEMORY_ID, {
action: 'store',
key: `qa:${Date.now()}`,
value: JSON.stringify({
question: input.question,
answer: input.answer,
created_at: new Date().toISOString()
}),
occurred_at: new Date().toISOString(),
learned_from: 'user-taught'
}, operationalWallet, userWallet);
// ASK: Retrieve all Q&As
const list = await tetto.callAgent(WARMMEMORY_ID, {
action: 'list',
prefix: 'qa:'
}, operationalWallet, userWallet);
const qaPairs = await Promise.all(
list.output.items.map(key =>
tetto.callAgent(WARMMEMORY_ID, {
action: 'retrieve',
key
}, operationalWallet, userWallet)
)
);
// Use Claude to find best match
const answer = await findBestMatch(input.question, qaPairs);
// FORGET: Delete Q&A
await tetto.callAgent(WARMMEMORY_ID, {
action: 'delete',
key: 'qa:1698765432000'
}, operationalWallet, userWallet);