> For the complete documentation index, see [llms.txt](https://docs.csml.dev/language/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.csml.dev/language/memory/temporary-and-long-term-variables.md).

# Temporary and Long-Term variables

## Temporary Variables

**Local or temporary variables** are only usable within the current step. It is rather a way to write more readable, expressive code. But they are really powerful, because they allow you to do everything that a regular memory does, but temporarily. For more information about local variables, see the `as` keyword.

Local variables are useful for temporary calculations. You do not want to memorize your internal temporary steps, rather save useful information about the user.

```cpp
somestep:
  do tmpvar = "Hi there"
  say tmpvar // "Hi there"
  goto otherstep
  
otherstep:
  say tmpvar // NULL
```

## Long-Term Memory

**Long-term memories** on the other hand are at the core of the purpose of CSML. When two persons converse, they constantly memorize information, which they can reuse in other discussions. For example, if I gathered that my friend likes Iron Man, I might propose later that we go see Captain America together. I do not have to ask them again about their favorite film, because I already learned this information before, even if it was in a different conversation, even if the topic of that conversation might have been completely unrelated.

The memory API is very powerful: by default a bot never forgets anything about the current user. For more information, see the `remember` keyword.

```cpp
somestep:
  remember tmpvar = "Hi there"
  say tmpvar // "Hi there"
  goto otherstep
  
otherstep:
  say tmpvar // "Hi there"
```

## The Memory object

CSML provides a `_memory` global, read-only variable, which contains all variables saved until now for the current user. This  especially useful if you need to debug the state of a user's memory at any given step:

```cpp
somestep:
  remember something = 1
  // ...

someotherstep:
  do something = 8
  // ...
  
wherever:
  // when we get there, is `something` set to 1, 8
  // or even available at all?
  say "{{_memory}}"
  
  
```

## ⚠️ Limitations

{% hint style="warning" %}
Variables and memories (of any type) can **not be larger than 50KB**. Using data larger than 50KB in variables (for example as the return value of a function) may result in undefined behavior. Also, please note that messages larger than 30KB in size can not be displayed in the test webapp.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.csml.dev/language/memory/temporary-and-long-term-variables.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
