Announcing Genkit Middleware: Intercept, extend, and harden your agentic apps

· Source: Google Developers Blog - AI · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering, Robotics & Autonomous Systems · Depth: Intermediate, short

Summary

Genkit, an open-source framework for building AI-powered and agentic applications, has introduced a new middleware system. This system provides composable hooks that intercept generation calls, including the tool execution loop, to inject custom behaviors for reliability, human approval, and observability. Middleware operates at three layers: Generate (per tool-loop iteration), Model (per model API call), and Tool (per tool execution). Genkit offers pre-built middleware for common use cases such as Retry for transient errors, Fallback to alternative models, Tool Approval for human-in-the-loop confirmation, Skills for injecting prompt content, and Filesystem for scoped model access. Developers can also create custom middleware to enforce specific application rules, like content filtering, and inspect their execution via the Genkit Developer UI.

Key takeaway

For AI Engineers building production-ready agentic applications, Genkit's new middleware system offers critical capabilities to harden your deployments. You should explore integrating pre-built middleware like Retry and Fallback for enhanced reliability, and consider developing custom middleware for application-specific logic such as content filtering or data governance. This approach centralizes control and improves the maintainability of complex AI workflows.

Key insights

Genkit middleware enhances agentic AI applications with composable hooks for reliability, control, and custom logic.

Principles

Method

Implement custom middleware by providing a name and a factory function that returns specific hooks (WrapModel, WrapGenerate, WrapTool) to intercept and modify AI generation calls.

In practice

Topics

Code references

Best for: AI Engineer, Machine Learning Engineer, Software Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Google Developers Blog - AI.