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: str,
    value: str
) -> MemorySetResponse

Parameters

Param
Type
Description

key

str

Unique identifier for the value (1 - 255 characters)

value

str

String value to store

Returns

  • MemorySetResponse

class MemorySetResponse:
    success: bool
    data: {
        key: str  # The key that was set
    } | None
    error: str | None
    error_details: dict | None

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

str

The key to retrieve

Returns

  • 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

str

The key to delete

Returns

  • 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

  • MemoryListResponse

Examples

Last updated