# latest_goal_state_message_index

> **Function** in `deepagents_code`

📖 [View in docs](https://reference.langchain.com/python/deepagents-code/goal_state_notice/latest_goal_state_message_index)

Return the newest goal-state source index, including invalid messages.

## Signature

```python
latest_goal_state_message_index(
    messages: Sequence[object],
) -> int | None
```

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/e4c1ffe9ee63d7854147de490ca27495ef157a7b/libs/code/deepagents_code/goal_state_notice.py#L820)