diff --git a/agents-api/agents_api/models/agent/list_agents.py b/agents-api/agents_api/models/agent/list_agents.py index 8c859521..593847ca 100644 --- a/agents-api/agents_api/models/agent/list_agents.py +++ b/agents-api/agents_api/models/agent/list_agents.py @@ -15,6 +15,20 @@ def list_agents_query( metadata_filter: dict[str, Any] = {}, client: CozoClient = client, ) -> pd.DataFrame: + """ + Constructs and executes a datalog query to list agents from the 'cozodb' database. + + Parameters: + developer_id: UUID of the developer. + limit: Maximum number of agents to return. + offset: Number of agents to skip before starting to collect the result set. + metadata_filter: Dictionary to filter agents based on metadata. + client: Instance of CozoClient to execute the query. + + Returns: + A pandas DataFrame containing the query results. + """ + # Transforms the metadata_filter dictionary into a string representation for the datalog query. metadata_filter_str = ", ".join( [ f"metadata->{json.dumps(k)} == {json.dumps(v)}" @@ -22,6 +36,7 @@ def list_agents_query( ] ) + # Datalog query to retrieve agent information based on filters, sorted by creation date in descending order. query = f""" {{ input[developer_id] <- [[to_uuid($developer_id)]]