code: def _fix_json_agents(ag_obj):
      
      if isinstance(ag_obj, str):
          logger.info("Fixing string agent: %s." % ag_obj)
          ret = {'name': ag_obj, 'db_refs': {'TEXT': ag_obj}}
      elif isinstance(ag_obj, list):
          # Recursive for complexes and similar.
          ret = [_fix_json_agents(ag) for ag in ag_obj]
      elif isinstance(ag_obj, dict) and 'TEXT' in ag_obj.keys():
          ret = deepcopy(ag_obj)
          text = ret.pop('TEXT')
          ret['db_refs']['TEXT'] = text
      else:
          ret = ag_obj
      return ret
docs: Fix the json representation of an agent.