code: def update_annotation(values, annotation_field: str):
      field_to_update = f"{annotation_field}s"
      annotation = values.get(annotation_field)
      annotations = values.get(field_to_update) or {}
  
      if annotations:
          for key, value in annotations.items():
              value.agent = None  # Maybe we want key and agents with different values
  
      if annotation:
          if not annotation.agent:
              raise AssertionError("Agent must be defined!")
  
          annotations.update(
              {
                  annotation.agent: annotation.__class__.parse_obj(
                      annotation.dict(exclude={"agent"})
                  )
              }
          )
          values[field_to_update] = annotations
  
      if annotations and not annotation:
          # set first annotation
          key, value = list(annotations.items())[0]
          values[annotation_field] = value.__class__(
              agent=key, **value.dict(exclude={"agent"})
          )
  
      return values
  
imports: import uuid
  import warnings
  from datetime import datetime
  from typing import Any, Dict, Generic, List, Optional, TypeVar, Union
  from argilla import _messages
  from argilla.server.commons.models import PredictionStatus, TaskStatus, TaskType
  from argilla.server.constants import JS_MAX_SAFE_INTEGER, PROTECTED_METADATA_FIELD_PREFIX
  from argilla.server.daos.backend.search.model import BaseRecordsQuery, SortConfig
  from argilla.server.helpers import flatten_dict
  from argilla.server.pydantic_v1 import BaseModel, Field, conint, constr, root_validator, validator
  from argilla.server.pydantic_v1.generics import GenericModel
  from argilla.server.settings import settings
  from argilla.utils import limit_value_length
label_desc: Use image node_id 1 for calling the BaseRecordInDB obj's underlying member method code with example usage: obj.update_annotation(values, annotation_field) and returns: values