---
title: "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
source_url: https://blog.logrocket.com/building-multi-turn-ai-agents-genkits-agents-api
type: article
source: "LogRocket"
published: 2026-08-24T08:09:28.518Z
updated: 2026-08-24T08:10:05.024Z
tags: ["ai-agents", "typescript", "firestore"]
reading_time: 16
upvotes: 0
comments: 0
language: 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

---

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)
