HyperAIHyperAI

Command Palette

Search for a command to run...

Google Engineer Automates Technical Follow-Ups with Custom Deep Research System Using Genkit

Deep Research is a versatile and cutting-edge generative AI (GenAI) application design pattern that has evolved beyond traditional Retrieval-Augmented Generation (RAG) systems. This advanced pattern is particularly useful for handling complex and unspecific user queries, especially in domains requiring extensive technical knowledge, like Google Cloud Platform (GCP). Unlike standard RAG, Deep Research excels in scenarios where queries are intricate and the number and types of data sources are diverse, making it a powerful tool for automating tasks. In 2025, standard RAG systems are becoming inadequate for many AI use cases due to the complexity and specificity of user queries. Deep Research addresses these limitations by breaking down user requests, conducting parallel research to gather information, and aggregating the results into a cohesive and actionable report. This approach is particularly valuable for tasks like writing technical follow-up emails after client meetings. Building a Deep Research System Step 1: Understanding and Breaking Down User Requests The first step involves analyzing the initial meeting transcript to extract technical questions that need follow-up. This is achieved using a simple text prompt configured in Genkit, a platform for building and orchestrating GenAI workflows. The input to this prompt is the raw meeting transcript, and the output is an array of task objects, each containing a concise question. For example, a question might be, "How do I build my own Deep Research Assistant with Gemini 2.5 and Genkit?" The prompt ensures that all relevant questions are identified and summarized accurately. ```typescript const TaskSchema = z.object({ description: z.string(), }); const TaskArraySchema = ai.defineSchema( 'TaskArraySchema', z.array(TaskSchema) ); // Define the task extraction flow export const taskExtractionFlow = ai.defineFlow( { name: "taskExtractionFlow", inputSchema: z.string(), outputSchema: TaskArraySchema, }, async (transcript) => { const taskExtractionPrompt = ai.prompt('taskExtraction'); const { output } = await taskExtractionPrompt( { transcript: transcript }, { model: gemini25ProPreview0325, output: { schema: TaskArraySchema } } ); return output; } ); ``` Step 2: Parallel Research and Retrieval Pipeline Once the questions are extracted, the next step is to conduct parallel research to gather information. This involves using multiple knowledge sources to provide the most accurate and up-to-date answers. The system taps into custom-built knowledge bases of GCP documentation and the Google Programmable Search Engine API. The custom-built knowledge base uses Firestore Vector Index (VSI) to store and retrieve valuable GCP documentation chunks as text embeddings. The Programmable Search Engine API is used to simulate a Google search for each research task, providing real-time information from indexed documentation and GitHub repositories. The research results for each task are formatted into a strict schema that includes an answer, caveats, and document references. This schema helps in maintaining oversight and linking specific insights to their sources. ```typescript const TaskResearchResponse = ai.defineSchema( 'TaskResearchResponse', z.object({ answer: z.string(), caveats: z.array(z.string()), docReferences: z.array(z.object({ title: z.string(), url: z.string(), relevantContent: z.string().optional(), })), }) ); // Define the task research flow export const taskReseachFlow = ai.defineFlow( { name: "taskReseachFlow", inputSchema: TaskArraySchema, outputSchema: TaskResearchResponseArray, }, async (tasks) => { // Parallel retrieval of relevant documents const retrievalPromises = tasks.map(task => { return ai.retrieve({ retriever: 'simpleFirestoreVSRetriever', query: task.description, options: { limit: 10 } }); }); const taskDocsArray = await Promise.all(retrievalPromises); // Parallel task research generation const taskResearchPrompt = ai.prompt('taskResearch'); const generationPromises = tasks.map(async (task, index) => { const docs = taskDocsArray[index]; const { output } = await taskResearchPrompt( { question: task.description }, { docs: docs, output: { schema: TaskResearchResponse } } ); return output; }); const researchResults = await Promise.all(generationPromises); return researchResults; } ); ``` Step 3: Aggregation of Research Results After gathering the necessary information, the final step is to aggregate the research results into a format that is useful for both the user and the knowledge worker. In this case, the goal is to draft a professional and concise follow-up email. The email should start with a brief reference to the meeting, address each technical question concisely, and link to specific documentation sections wherever applicable. The prompt for this step is designed to ensure that the generated email maintains a professional but friendly tone and follows the specified structure. ```typescript // Define the email generation prompt ---config: temperature: 1 input: schema: tasks: string research: string output: schema: email: string Generate a professional follow-up email to the customer based on the technical research results. Original Task:{{tasks}} Research Findings:{{research}} Requirements for the email: 1. Start with a brief meeting reference and summary 2. Address each technical question briefly and concisely, most bullet points should not be longer than one sentence 3. Link to specific documentation sections whenever possible, but only as it makes sense in the context 4. Maintain a professional but friendly tone 5. End with next steps or an offer for further clarification Generated Email: See example in the full codebase ``` Practical Implementation The entire Deep Research workflow is orchestrated using Firebase Genkit, a powerful platform for building and deploying GenAI applications. The code repository is available on GitHub, allowing readers to fork it, understand the implementation details, and adapt it to their specific research-intensive tasks. Conclusion and Next Steps Deep Research represents a significant advancement in AI application design. By automating complex research tasks, it can drastically reduce the time and effort required by knowledge workers. The effectiveness of a Deep Research system depends heavily on the quality and relevance of its knowledge bases. Customizing the system to fit specific use cases is essential for its success. While the current implementation follows a straightforward workflow, more complex tasks might benefit from integrating agentic loops, where the system iterates over research reports until the findings are comprehensive. However, such capabilities often add unnecessary complexity, and the current workflow is sufficient for most tasks. As a Google Cloud Customer Engineer, I’ve found this system to be remarkably effective in automating a large portion of my follow-up email tasks. Industry insiders agree that Deep Research is a game-changer, poised to revolutionize knowledge work. By leveraging this pattern, companies can enhance productivity and accuracy, ultimately leading to better customer service and operational efficiency.

Related Links