Reference
- Blázquez-Ochando, M., Prieto-Gutierrez, J. J., & Ovalle-Perandones, M. A. (2026). Prompt engineering for library agents: development of an AI-based conversational reading recommendation system. Library Hi Tech, 1-18. https://doi.org/10.1108/LHT-08-2025-0196 | System source code (MIT license): https://github.com/manublaz/laiabot
Commentary
The reference and reader guidance service is one of the most genuinely library-based functions: listening to an information need, often vaguely expressed, and translating it into relevant readings from the collection. It is also one of the services most vulnerable to the structural limitations of many libraries: reduced staffing, limited hours, and high assistive pressure that leave little room for the deliberate conversation required for effective recommendations.
The emergence of large language models appears to offer an immediate solution, but generic assistants present a fundamental problem for libraries: they do not know the collection. They may recommend titles the institution does not own, describe works inaccurately, or even fabricate references, and they leave no structured trace of the interaction that the library can later analyze. Moreover, they operate outside the professional principles guiding reader mediation—such as neutrality, inclusion, and equitable access to knowledge.
The article advances a thesis worth emphasizing: the quality of a library agent depends not only on the language model but above all on the design of the prompt that governs it. Deciding which reader variables matter, what filters to apply, how to anchor responses in the actual collection, and what data to return to the institution requires bibliographic expertise—not merely technical skill. Prompt engineering thus becomes a core competency of Documentation.
Research Purpose
The article presents the design, development, and implementation of LaIABot, an AI agent based on structured prompting for bibliographic recommendation in library environments. Its goal is to expand the availability and personalization of reader guidance services without requiring significant investment, as a response to staffing shortages and time constraints affecting many libraries.
The primary innovation lies in the design of prompts that generate two simultaneous outputs. The first is directed at the user, providing clear and contextualized recommendations. The second is directed at the institution, in JSON format, containing interaction metadata, enabling system feedback, integration with the ILS, and enrichment of documentation analysis and management processes.
The study adopts a user-centered approach grounded in the principles of Library Science and ethical criteria. The system is released as free software, featuring a modular architecture designed for replication in public, academic, and specialized libraries. The research focuses on reader mediation and personalized recommendation; implementation in real service environments and usability studies are planned as subsequent phases.
Conceptual framework: the prompt as a documentary instrument
In language models, the prompt is defined as the set of instructions, guidelines, examples, and parameters that guide response generation. It functions as a communicative and functional framework that determines the purpose of the interaction, the assumed role, the output format, thematic constraints, and information processing (Brown et al., 2020; Liu et al., 2023).
Prompt engineering has emerged as a discipline within natural language processing, aimed at developing systematic prompts that optimize the relevance, accuracy, and utility of responses (Reynolds & McDonell, 2021). It integrates contributions from applied linguistics, instructional design, and computational semiotics, resting on principles such as precise instruction formulation, iterative optimization based on outcomes, and adaptation to the domain and target audience.
Transposed to the library context, the prompt ceases to be a mere technical instruction and becomes the explicit codification of professional knowledge. Literature on recommendation systems in libraries (Beel et al., 2016; Ricci et al., 2022) emphasizes the importance of modeling both user profiles and organizational contexts. In a conversational agent, this modeling occurs precisely within the prompt: the agent knows about the reader, the collection, and the service exactly what the prompt teaches it.
Design of the base prompt: five configurable modules
IABot is built upon a configurable base prompt organized into five modules that each library can parameterize according to its context:
- User Profile. Captures variables that condition the relevance of a recommendation: age and reading level, preferred genres, and reading history (integrable via the ILS or OPAC), context and purpose of the query (recreational, educational, professional, or research-oriented), format preferences and accessibility needs, emotional state and momentary requirements, conversational tone, and desired number of recommendations.
- Suggestion Filtering. Establishes the criteria used to select and refine proposals: alignment with the reader’s profile, thematic relevance, and authorial and thematic diversity.
- Collection Typology. Informs the agent about the nature of available holdings, ensuring recommendations remain within the actual scope of what the library can provide.
- Library Services. Integrates institutional information (opening hours, lending policies, events) to address service-related queries and link recommendations with effective use of library resources.
- Feedback Mechanisms. Defines structured outputs intended for the institution and the channels through which each interaction contributes to service improvement.
The practical consequence of this design is that the agent’s behavior is not hardcoded. Prompts are stored in the database, organized by mode and type (evaluation, baseline, suggestion, follow-up, limits), and edited via the administrative panel. A library can adapt LaIABot to its audience and collection without reprogramming it.
System Architecture and Dual Output
The technical architecture combines Python and Flask on the server side, standard web technologies (HTML5, CSS3, and JavaScript) in the interface, and SQLite with its full-text search extension FTS5 as the data manager. Language processing relies on an 8-billion-parameter Llama 3 model served via the Groq API; however, the system is model-agnostic: it can connect to LM Studio or any LLM accessible through a standard REST API.
Data are distributed across three databases: the bibliographic catalog with its FTS5 index, the conversational system (threads, messages, users, and prompts), and information on library services and events, also fully text-indexed.
Three operational modes. Each user message is first processed by an evaluation prompt that classifies it into one of three modes: book recommendation (Mode 1), information about library services (Mode 2), or general conversation bounded by a limits prompt that redirects toward library-related topics (Mode 3). Classification is repeated at each turn, allowing the reader to shift from requesting a novel to asking about opening hours without restarting the conversation. If the API fails to respond, a keyword-based heuristic ensures continued service operation.
The dual output. In recommendation mode, the base prompt requires the model to respond with a JSON containing two fields:
The user_response field is delivered directly to the conversational channel. The system_keywords field is invisible to the reader: it is transformed into an FTS5 query against the catalog, with a LIKE search as fallback. Retrieved records are formatted as APA references, and a second prompt generates a brief commentary for each title.
The result is that recommended titles are not generated by the model but retrieved from the catalog; the model merely interprets the request and comments on the results. Each turn is additionally logged with its metadata (query category, keywords, recommended authors, and date), constituting the institutional dimension of the dual output.

Fig1. Workflow diagram of the reading recommendation agent for the OPAC of LaIABot libraries
The reader sees only user_response; system_keywords queries the catalog, ensuring that recommended titles always originate from the actual collection.
Evaluation Methodology: Test Corpus and Queries
- Bibliographic corpus. To validate the prototype in a controlled environment, a corpus of approximately 8,500 records was constructed by extracting data from Project Gutenberg using a web scraping script available in the repository. This choice is motivated by three factors: its open access eliminates institutional barriers and ensures reproducibility; its metadata structure emulates essential elements of MARC21; and its chronological breadth (16th to 20th centuries) reproduces the temporal heterogeneity of academic and heritage collections.
- Representative size. The figure of 8,500 records was deliberately chosen to reflect the order of magnitude of a small or medium-sized public or local library—the most likely deployment context for an open-source and low-cost tool.
- Query set. A total of 150 synthetic queries in natural language were developed, evenly distributed across three balanced categories of 50 each: academic (specialized requests oriented toward research), recreational (general and leisure reading), and complex (multicriteria requests combining temporal, thematic, and formal constraints).
- Construction criteria. The queries follow the RUSA (2008) reference transaction taxonomy and six explicit criteria declared in the dataset’s own metadata: terminological diversity, variation in complexity, coverage of historical periods, disciplinary breadth, natural language patterns, and deliberate inclusion of edge cases. Each query includes the expected subjects, enabling validation of keyword extraction.
- Automated execution. An evaluation script executed the full battery of queries and recorded metrics for technical stability, JSON output consistency, retrieval performance, diversity, and response times. Both the query set and detailed results are published in the repository, allowing any researcher to reproduce the test.
Results
The pilot test data suggest that the architecture is technically viable and stable in a controlled environment.
- System stability. All 150 queries were completed without critical errors (100%). Only a single isolated API failure was recorded, absorbed by backup mechanisms.
- Structural consistency. 99.33% of responses (149 out of 150) returned valid JSON. This indicates that structured prompting is sufficient for an 8-billion-parameter model to systematically adhere to the required output format—a prerequisite for dual output functionality.
- Effective retrieval. 96.67% of queries (145 out of 150) successfully retrieved records from the catalog via FTS5, with an average of 4.8 books per query and a total of 720 recommendations.
- Author diversity. The 720 recommendations corresponded to 493 distinct authors, representing a proportion of 68.5%, indicating a broad distribution with low concentration on a narrow canonical set of names.
- Interaction quality. Conversational responses had an average length of 323 characters—concise yet informative—and the model extracted an average of 4.6 keywords per query to interrogate the catalog.
- Response times. The average response time was 3.9 seconds per query, with approximately two model calls per request (295 total), a performance level adequate for a conversational service with room for optimization.
Discussion
Dual output as the central contribution. A single interaction produces two distinct outputs intended for different audiences. For the reader, a natural conversation with annotated readings; for the library, a structured record that can be integrated into the ILS, exploited statistically, or used to enrich the catalog. Queries returning no results, for instance, may be interpreted as indicators of unmet demand within the collection.
The catalog as the anchor of recommendation. By separating interpretation of the user’s request—handled by the model—from selection of titles—handled by the catalog—LaIABot reduces the risk of recommending works that are nonexistent or outside the collection. Moreover, searching across the entire holdings enhances the visibility of historical collections and lesser-known authors, reinforcing the library’s social and educational role.
Scalability and integration. FTS5 equips SQLite with full-text indexing capabilities comparable to those of major database management systems and commercial ILS platforms, making it suitable for small- and medium-sized catalogs. For collections numbering in hundreds of thousands or millions of records, the system should migrate to engines such as PostgreSQL, Elasticsearch, or Solr, and connect to institutional ILSs via APIs—for example, with Koha or Evergreen. The prompt architecture and processing logic, which constitute the methodological contribution, would remain unchanged.
Data ethics and governance. The recommendations may reproduce biases originating from the training data or the prompt design itself. Therefore, the article emphasizes the need for periodic audits on the representation of authorship, genders, and cultural perspectives, as well as the establishment of governance protocols that ensure neutrality, inclusion, transparency, and privacy—especially since institutional output generates metadata about user interactions.
Limitations. Validation has been conducted in a controlled environment using synthetic queries and a public-domain corpus. Implementation and usability studies with real readers constitute the next phases of the research, for which this work lays the methodological and technological foundations.
Conclusions
LaIABot demonstrates that it is possible to build a useful, open, and low-cost reader guidance agent when effort is focused on prompt design rather than solely on model selection. Its permanent availability, personalization according to the reader’s profile, and capacity for integration with existing systems make it a viable complement to reference services, particularly for libraries with limited resources.
The underlying conclusion is that the agent does not replace professional mediation but extends it. The criteria governing its operation—who the reader is, what collections the library holds, which principles guide selection, and what data the institution requires—are codified librarianship knowledge expressed in natural language. Therefore, prompt engineering must be understood as a core competency of information professionals, and its development as a legitimate field of research in Library and Information Science.
LaIABot is offered, ultimately, as an open and adaptable methodological framework capable of evolving with each institution’s needs. Its value lies not only in personalized recommendations but also in the structured data it returns to the library to better understand its readers and improve its services.
Resources
- Article in Library Hi Tech: https://doi.org/10.1108/LHT-08-2025-0196
- LaIABot source code (MIT license): https://github.com/manublaz/laiabot
- Set of queries and evaluation results: files
test_queries.json,test_results.json, andtest_metrics.jsonfrom the repository.