<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw" -->

---
title: Building multi-turn AI agents with Genkit’s Agents API
description: A hands-on guide walks through building a multi-turn AI agent using Genkit's Agents API (from the Firebase team). It covers defining an agent bound to a Gemini...
canonical: https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building multi-turn AI agents with Genkit’s Agents API | daily.dev
og:description: A hands-on guide walks through building a multi-turn AI agent using Genkit's Agents API (from the Firebase team). It covers defining an agent bound to a Gemini...
og:url: https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw
og:image: https://api.daily.dev/og/posts/DfGV5PuXW.png
og:image:alt: Building multi-turn AI agents with Genkit’s Agents API
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building multi-turn AI agents with Genkit’s Agents API

**[LogRocket](https://daily.dev/sources/logrocket)** · 16 min read · 0 upvotes · 0 comments

## Summary

A hands-on guide walks through building a multi-turn AI agent using Genkit's Agents API (from the Firebase team). It covers defining an agent bound to a Gemini model, persisting sessions to Firestore via FirestoreSessionStore instead of in-memory or file-based storage, exposing the agent over HTTP with remoteAgent() for frontend use, running detached long-running turns that survive client disconnects via chat.detach() and getSnapshot polling, and gating risky tool calls (like record deletion) behind human-approved interrupts using defineInterrupt, respond(), and resume(). The result is an agent architecture that survives restarts, outlives browser connections, and enforces approval gates against persisted session history rather than trusting client claims.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.logrocket.com/building-multi-turn-ai-agents-genkits-agents-api>

## Questions this post answers

### How do I persist Genkit agent sessions in Firestore instead of local files?

Install @genkit-ai/google-cloud and replace FileSessionStore with FirestoreSessionStore in the agent's store option, using the same SessionStore interface. An empty FirestoreSessionStore() constructor connects to the (default) database and authenticates via a service account with the Cloud Datastore User role, set through GOOGLE_APPLICATION_CREDENTIALS. Sessions then span three collections: genkit-sessions, genkit-sessions-pointers, and genkit-sessions-shards.

_See how developers track emerging tools like Genkit's Agents API on daily.dev before adopting them._

### How do detached turns work in Genkit's Agents API and do they survive the server restarting?

Detached turns, started with chat.detach(), let a long-running agent turn continue after the client disconnects, returning a DetachedTask with a snapshotId a client can poll via getSnapshot or reconnect to later. However, the turn continues inside the same server process that started it rather than moving to a separate worker, so that process must stay alive until the work finishes.

_Developers evaluating long-running AI agent architectures can follow tools like Genkit on daily.dev._

### How do you make an AI agent pause for human approval before running a risky tool call?

Define the risky action with Genkit's defineInterrupt instead of a regular tool, giving it no implementation. When the model calls it, the turn pauses and the call appears in res.interrupts; a human then approves by calling interrupt.respond() with a result and passing it into chat.resume(), or forces a re-run with interrupt.restart(). The server validates the resume against the session's recorded history, so a client cannot fabricate an approval for a call that never happened.

_Teams designing human-in-the-loop AI agent flows can track patterns like this on daily.dev._

## Similar posts on daily.dev

- [Google's Genkit Ships Agents API with Detached Turns and Human-in-the-Loop for TypeScript and Go](https://daily.dev/posts/google-s-genkit-ships-agents-api-with-detached-turns-and-human-in-the-loop-for-typescript-and-go-rhvlsvox2) · InfoQ · 0 upvotes · 0 comments
- [Build agentic full-stack apps with Genkit](https://daily.dev/posts/build-agentic-full-stack-apps-with-genkit-ckpxki271) · Google Developers · 4 upvotes · 0 comments
- [Firebase \+ Genkit: How I Actually Brought AI Into My Mobile App \(Without Losing My Mind\)](https://daily.dev/posts/firebase-genkit-how-i-actually-brought-ai-into-my-mobile-app-without-losing-my-mind--ta6av8kvz) · Medium · 0 upvotes · 0 comments
- [Build Agentic Apps with Angular, Genkit and Kendo UI: Part 1](https://daily.dev/posts/build-agentic-apps-with-angular-genkit-and-kendo-ui-part-1-8hdcrhiff) · Telerik · 0 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#typescript](https://daily.dev/tags/typescript), [#firestore](https://daily.dev/tags/firestore)

[View this post on daily.dev](https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Building multi-turn AI agents with Genkit’s Agents API","url":"https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw"},"datePublished":"2026-08-24T08:09:28.518Z","dateModified":"2026-08-24T08:10:05.024Z","description":"A hands-on guide walks through building a multi-turn AI agent using Genkit's Agents API (from the Firebase team). It covers defining an agent bound to a Gemini...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f3634f2332675b628663c3493a98f6f8?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/f3634f2332675b628663c3493a98f6f8?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"LogRocket","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"LogRocket","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/logrocket","url":"https://daily.dev/sources/logrocket"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,typescript,firestore","timeRequired":"PT16M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"LogRocket","item":"https://daily.dev/sources/logrocket"},{"@type":"ListItem","position":3,"name":"Building multi-turn AI agents with Genkit’s Agents API"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/building-multi-turn-ai-agents-with-genkit-s-agents-api-dfgv5puxw#faq","mainEntity":[{"@type":"Question","name":"How do I persist Genkit agent sessions in Firestore instead of local files?","acceptedAnswer":{"@type":"Answer","text":"Install @genkit-ai/google-cloud and replace FileSessionStore with FirestoreSessionStore in the agent's store option, using the same SessionStore interface. An empty FirestoreSessionStore() constructor connects to the (default) database and authenticates via a service account with the Cloud Datastore User role, set through GOOGLE_APPLICATION_CREDENTIALS. Sessions then span three collections: genkit-sessions, genkit-sessions-pointers, and genkit-sessions-shards. See how developers track emerging tools like Genkit's Agents API on daily.dev before adopting them."}},{"@type":"Question","name":"How do detached turns work in Genkit's Agents API and do they survive the server restarting?","acceptedAnswer":{"@type":"Answer","text":"Detached turns, started with chat.detach(), let a long-running agent turn continue after the client disconnects, returning a DetachedTask with a snapshotId a client can poll via getSnapshot or reconnect to later. However, the turn continues inside the same server process that started it rather than moving to a separate worker, so that process must stay alive until the work finishes. Developers evaluating long-running AI agent architectures can follow tools like Genkit on daily.dev."}},{"@type":"Question","name":"How do you make an AI agent pause for human approval before running a risky tool call?","acceptedAnswer":{"@type":"Answer","text":"Define the risky action with Genkit's defineInterrupt instead of a regular tool, giving it no implementation. When the model calls it, the turn pauses and the call appears in res.interrupts; a human then approves by calling interrupt.respond() with a result and passing it into chat.resume(), or forces a re-run with interrupt.restart(). The server validates the resume against the session's recorded history, so a client cannot fabricate an approval for a call that never happened. Teams designing human-in-the-loop AI agent flows can track patterns like this on daily.dev."}}]}
```

