memory

The memory namespace provides persistent key-value storage for your agent. All data is scoped to your agent session and persists across executions. Use memory to track state, store configuration, or maintain context between runs. Memory is automatically scoped to your session ID, and for now is simple string storage. You will need to handle serialization of whatever data you want to store here.

memory.set()

Store a string value with a unique key.

Signature

agent.memory.set(
  key: string,
  value: string
): Promise<MemorySetResponse>

Parameters

Param
Type
Description

key

string

Unique identifier for the value (1 - 255 characters)

value

string

String value to store

Returns

  • Promise<MemorySetResponse>

type MemorySetResponse = {
  success: boolean;
  data?: {
    key: string;  // The key that was set
  };
  error?: string;
  errorMessage?: string;
  errorDetails?: object;
}

Examples

Common Errors

Error
Cause
Solution

"Invalid key"

Key too long (>255 chars) or empty

Use keys between 1-255 characters

"Invalid value"

Value exceeds size limit

Keep values reasonable size, consider splitting large data

memory.get()

Retrieve a previously stored value by key.

Signature

Parameters

Param
Type
Description

key

string

The key to retrieve

Returns

  • Promise<MemoryGetResponse>

Examples

Common Errors

Error
Cause
Solution

"Key not found"

Key doesn't exist in memory

Check if key exists first, or handle missing keys gracefully

memory.delete()

Remove a key-value pair from storage. Succeeds even if the key doesn't exist.

Signature

Parameters

Param
Type
Description

key

string

The key to delete

Returns

  • Promise<MemoryDeleteResponse>

Examples

memory.list()

Get an array of all keys stored for this agent session. Useful for debugging or iterating through stored data.

Signature

Returns

  • Promise<MemoryListResponse>

Examples

Last updated