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

# append_to_state

> Append a value to a list state. Creates the list if it doesn't exist.

Method

> This is a method of the [**Agents**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/Agents.md) class in the [**agents**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/agents.md) module.

Append a value to a list state. Creates the list if it doesn't exist.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def append_to_state(key: str, value: Any, max_length: Optional[int]) -> List[Any]
```

## Parameters

**key** `str` *required*

State key

**value** `Any` *required*

Value to append

**max\_length** `Optional`

Optional maximum length for the list

### Returns

**Returns** `List[Any]`

The updated list

### Exceptions

> [accordion] TypeError
>
> If the existing value is not a list and convert\_to\_list=False


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.