> ## Documentation Index
> Fetch the complete documentation index at: https://docs.veadk.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Use in-memory storage

The `local` backend keeps sessions in process memory. It needs no external service and never touches disk — when the process exits, sessions are gone. It is the default backend of `ShortTermMemory`.

## When to use

* Local development and debugging;
* Unit tests, example scripts, and other ephemeral scenarios;
* When sessions don't need to survive across processes or restarts.

## Usage

```python lines theme={null}
import asyncio

from veadk.memory.short_term_memory import ShortTermMemory

stm = ShortTermMemory(backend="local")

async def main():
    await stm.create_session(
        app_name="memory_demo", user_id="user_42", session_id="chat_01"
    )
    session = await stm.session_service.get_session(
        app_name="memory_demo", user_id="user_42", session_id="chat_01"
    )
    assert session is not None
    print(session.id)

asyncio.run(main())
```

The output is `chat_01`, confirming that the session was created and read back. This example does not call a model. For conversations, pass the same `stm` to `Runner(short_term_memory=stm, agent=agent)` and keep the app, user, and session identifiers consistent

Because `local` is the default, the following select in-memory storage; separate instances do not share sessions:

```python lines theme={null}
ShortTermMemory()                    # uses the default backend
ShortTermMemory(backend="local")     # explicit
# or pass no short_term_memory to the Runner at all — it falls back to a local one
```

<Note>
  If the `Runner` receives no `short_term_memory` or `session_service`, it automatically creates a `local` instance as a fallback, so running an agent locally needs no extra configuration.
</Note>

## Parameters

`local` has no backend-specific settings. Use the common `ShortTermMemory` parameters below; most have no effect on `local`.

### ShortTermMemory constructor parameters (local)

| Parameter | Type | Default | Effective for local | Description |
| :- | :- | :- | :- | :- |
| `backend` | `str` | `"local"` | Yes | Set to `"local"` or omit this parameter; an empty string is not a valid backend |
| `db_url` | `str` | `""` | Yes (override) | Once set, `backend` is ignored and a database backend is used instead. Leave unset to stay in memory. |
| `backend_configs` | `dict` | `{}` | No | Not read by `local`. |
| `db_kwargs` | `dict` | `{}` | No | Used only by database backends. |
| `local_database_path` | `str` | `/tmp/veadk_local_database.db` | No | Used only by `sqlite`. |
| `after_load_memory_callback` | `Callable \| None` | `None` | Yes | Synchronous read callback; receives `Session` or `None` plus the query arguments. Use `def callback(session, *args, **kwargs)` |
| `after_create_session_callback` | `Callable \| None` | `None` | Yes | Runs after `ShortTermMemory.create_session()` creates a new session; accepts the new `Session` and can be synchronous or asynchronous |

<Warning>
  The `local` backend does not persist to disk; all session data is lost when the process exits. Do not use it in production for sessions that must survive. For persistence use [SQLite](/productions/veadk/preview/en/components/session/sqlite), [MySQL](/productions/veadk/preview/en/components/session/mysql), or [PostgreSQL](/productions/veadk/preview/en/components/session/postgresql).
</Warning>

## Environment variables

The `local` backend reads no environment variables.
