> ## 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 • AI Agent SDK

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

# append\_to\_state

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**AgentTeam**](../classes/AgentTeam) class in the [**agents**](../modules/agents) 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

<ParamField query="key" type="str" required={true}>
  State key
</ParamField>

<ParamField query="value" type="Any" required={true}>
  Value to append
</ParamField>

<ParamField query="max_length" type="Optional" required={false}>
  Optional maximum length for the list
</ParamField>

### Returns

<ResponseField name="Returns" type="List[Any]">
  The updated list
</ResponseField>

### Exceptions

<AccordionGroup>
  <Accordion title="TypeError">
    If the existing value is not a list and convert\_to\_list=False
  </Accordion>
</AccordionGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agents/agents.py#L1446">
  `praisonaiagents/agents/agents.py` at line 1446
</Card>
