def _get_latest_memory_item(
    memory: memory_component.Memory,
    tag: str,
) -> str:
  """Return the latest item prefixed by a tag in the memory."""
  retrieved = memory.scan(
      selector_fn=lambda x: x.startswith(tag),
  )
  if retrieved:
    result = retrieved[-1]
    return result[result.find(tag) + len(tag) + 1:]
  else:
    return ''
Return the latest item prefixed by a tag in the memory.
concordia/environment/scenes/runner.py