
Google's Genkit Ships Agents API with Detached Turns and Human-in-the-Loop for TypeScript and Go
Quick Answer
Google's Genkit has launched a preview of its Agents API for TypeScript and Go, enabling full-stack AI applications with features like detached turns and human-in-the-loop capabilities.
Quick Take
Google's Genkit has launched a preview of its Agents API for TypeScript and Go, enabling full-stack AI applications with features like detached turns and human-in-the-loop capabilities. This open-source framework allows seamless scaling from simple chatbots to complex workflows while maintaining state persistence and compliance with data residency requirements.
Key Points
- Agents API integrates message history, tool execution, and state persistence in a single interface.
- Detached turns allow clients to poll for results without maintaining a connection.
- Human-in-the-loop control ensures user approval before executing potentially risky commands.
- Genkit supports multiple data stores, including Firestore and in-memory options.
- The framework is model-agnostic, compatible with various AI models and plugins.
📖 Reader Mode
~5 min readGoogle recently released the Agents API in preview for Genkit, its open-source framework for building full-stack AI applications. The API packages message history, the tool execution loop, streaming, state persistence, and a frontend protocol behind a single chat() interface that works identically whether the agent runs in-process or behind an HTTP endpoint. The preview is available today in TypeScript and Go, with Python and Dart support planned.
The design principle is one abstraction that scales up without swapping primitives. The same agent object handles a one-shot reply, a streamed multi-turn conversation, a paused tool call waiting for human approval, and a detached long-running task. Teams do not need to reach for a different framework component as the feature grows from a simple chatbot to a multi-agent workflow.
Genkit separates two kinds of agent data that most frameworks conflate. Custom state is typed application data that drives the next turn: a workflow status, a task list, or selected entities. Artifacts are generated outputs the user may inspect, download, or version independently: a report, a code patch, or a travel itinerary. Tools update either one through the active session, and Genkit streams changes to the client as they happen.
State persistence follows two paths. With a session store configured, the agent is server-managed: messages, custom state, and artifacts persist as snapshots, and clients reconnect by session ID. Genkit ships stores for Firestore (production multi-instance), in-memory (development), and file-based (local testing), with a pluggable interface for custom implementations. Without a store, the agent is client-managed: the server returns full state and the client sends it back on each turn.
Ebenezer Don, an AI engineer, highlighted the compliance dimension of this architectural choice:
Maintaining reliable context is the primary challenge when you decide to add memory to AI agents.
On client-managed state specifically, Don noted the data residency angle that server-managed approaches cannot offer:
This approach is ideal for ephemeral sessions or applications with strict data residency constraints where the server should not persist user data. The tradeoff is increased network payload size as the conversation grows.
Two capabilities stand out from the crowded agentic framework landscape.
Detached turns let a client start an agent task, disconnect, and poll for results later. Moreover, the agent continues working server-side, writing progress to snapshots that any client can read:
const chat = reportAgent.chat({ sessionId: 'report-123' });
const task = await chat.detach('Write the quarterly market report.');
savePendingSnapshot(task.snapshotId);
for await (const snapshot of task.poll({ intervalMs: 1000 })) {
renderStatus(snapshot.status);
if (snapshot.status === 'completed') renderMessages(snapshot.state.messages);
}
With detached runs, developers can create long research jobs, multi-step planning, and tool-heavy workflows practical without WebSockets, a separate job queue, or holding a connection open.
The other capability interruptible tools provide human-in-the-loop control with anti-forgery protection. When a tool is marked as interruptible, the agent pauses mid-execution, returns the pending action to the client, and resumes only after the user approves or rejects. The runtime validates the resume payload against session history, preventing a tool from being tricked into running with forged input. In Go:
runShell := genkitx.DefineInterruptibleTool(g, "run_shell",
"Run a shell command after a safety check.",
func(ctx context.Context, input ShellInput, confirm *Confirmation) (ShellOutput, error) {
if isRisky(input.Command) {
if confirm == nil {
return ShellOutput{}, tool.Interrupt(ShellInterrupt{
Command: input.Command, Reason: "The command can modify files.",
})
} else if !confirm.Approved {
return ShellOutput{}, errors.New("user rejected shell command execution")
}
}
return execute(input.Command)
},
)
For multi-agent orchestration, Genkit's middleware system (shipped in May) injects a delegation tool for each sub-agent, so an orchestrator model can route parts of a request to specialists. Sub-agents can run locally or behind HTTP endpoints using the same chat() interface. The middleware layer also provides composable hooks for retries with exponential backoff, model fallbacks across providers, tool approval gates, and a skills system that loads SKILL.md files into the system prompt.
Genkit is model-agnostic through its plugin architecture. Official plugins exist for Google AI (Gemini), Vertex AI, Anthropic, OpenAI, and Ollama. A Vercel AI SDK adapter lets teams integrate Genkit agents into Next.js applications. Every agent is already a servable action, and route helpers wire up turn, snapshot, and abort endpoints on a standard HTTP mux in a few lines.
The competitive context is a crowded field. LangChain, CrewAI, Semantic Kernel, Autogen, Mastra, and Pydantic AI all address overlapping problems. Google itself is building agent infrastructure at two layers simultaneously: Genkit for self-hosted agent apps, and Managed Agents in the Gemini API for a Google-hosted runtime where background execution, remote MCP servers, and sandboxed code execution are handled entirely server-side. Genkit's differentiator in the broader landscape is the full-stack approach: server-side agent logic, typed client SDKs for web and mobile, built-in streaming protocol, and deployment to Firebase, Cloud Run, or any environment that runs Node.js or Go. The tradeoff is that Genkit is younger and has a smaller ecosystem of community integrations than LangChain.
The Agents API is in preview. The middleware system is GA in TypeScript, Go, and Dart. Genkit is open source under the Apache 2.0 license on GitHub.
About the Author
Steef-Jan Wiggers
Show moreShow less
— Originally published at infoq.com
Want this in your inbox every morning?
Daily brief at your local 8am — bilingual EN/中文, free.
More from InfoQ AI, ML & Data Engineering
See more →
AlloyDB Ships Proxy Models That Replace LLM Calls with Local Inference Inside the Database
Google's AlloyDB AI functions now allow direct LLM calls within SQL, achieving 2,400x throughput improvements via smart batching and 23,000x with optimized proxy models. The proxy model architecture enables local inference, significantly reducing costs and latency for database queries.

