# Transformers Agent Chat State

**URL:** <https://discuss.huggingface.co/t/transformers-agent-chat-state/39856>\
**Category:** 🤗Transformers\
**Created:** [May 15, 2023, 4:27am UTC](https://discuss.huggingface.co/t/transformers-agent-chat-state/39856 "2023-05-15T04:27:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeromeku](https://avatars.discourse-cdn.com/v4/letter/j/6bbea6/32.png) [@jeromeku](https://discuss.huggingface.co/u/jeromeku)\
**Post date:** [May 15, 2023, 4:27am UTC](https://discuss.huggingface.co/t/transformers-agent-chat-state/39856/1 "2023-05-15T04:27:53Z")

</div>

Experimenting with Transformer Agent – specifically running the [colab notebook](https://colab.research.google.com/drive/1c7MHD-T1forUPGcC_jlwsIptOzpG3hSj).

When using `chat` mode (i.e., `agent.chat`), when is `agent.chat_state` updated? Traced through the [source code](https://github.com/huggingface/transformers/blob/main/src/transformers/tools/agents.py) and can’t seem to find when this internal state is updated to include the result of the last `tool` result. Specifically, the `chat` [function](https://github.com/huggingface/transformers/blob/cf11493dce0a1d22446efe0d6c4ade02fd928e50/src/transformers/tools/agents.py#L241) is pretty straightforward and directly returns the result of the `evaluate` call.

In the Colab notebook, there is a series of prompts demonstrating `chat` mode. After each `chat` call, if we examine `agent.chat_state`, we can see that it contains the results of the last `tool` call.
