Skip to content

chore(py): bump version to 0.7.0#5505

Merged
huangjeff5 merged 4 commits into
mainfrom
release-py-0.7.0
Jun 9, 2026
Merged

chore(py): bump version to 0.7.0#5505
huangjeff5 merged 4 commits into
mainfrom
release-py-0.7.0

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Genkit Python SDK v0.7.0 Release Notes

Genkit Python SDK v0.7.0 is here! In this release, we've focused on giving you more control over the generation pipeline, adding pre-built resilience tools, and making it easier to integrate Genkit into your production web applications.

What's New

Intercept the Generation Loop with Middleware (#5253)

We've added a pluggable middleware architecture to the core generate pipeline. By subclassing BaseMiddleware and using the @ai.middleware decorator, you can run custom code at key lifecycle points in the generation process.

Configure your middleware with a custom configuration model using Pydantic:

from pydantic import BaseModel
from genkit import Genkit, BaseMiddleware

ai = Genkit()

# Configure your middleware with a custom config using Pydantic
class LoggingConfig(BaseModel):
    prefix: str = "[AI]"

@ai.middleware(name="logger")
class Logger(BaseMiddleware[LoggingConfig]):
    # Wrap the outer loop of the generate call (includes tools)
    async def wrap_generate(self, params, ctx, next_fn):
        return await next_fn(params, ctx)

    # Wrap the raw model API call (inspect/mutate inputs/outputs)
    async def wrap_model(self, params, ctx, next_fn):
        print(f"{self.config.prefix} Running: {params.prompt}")
        res = await next_fn(params, ctx)
        print(f"{self.config.prefix} Response: {res.text}")
        return res

    # Wrap individual tool execution (inspect/mutate inputs/outputs or Interrupt)
    async def wrap_tool(self, params, ctx, next_fn):
        print(f"Tool {params.name} called with: {params.input}")
        return await next_fn(params, ctx)

# Apply it on generate calls with full IDE autocomplete:
await ai.generate(
    model='gemini-2.5-flash',
    prompt='Hello!',
    use=[Logger(prefix="[Veneer]")]
)
  • wrap_generate: Hooks into the outer loop of the generate call, wrapping both the model execution and subsequent tool calls.
  • wrap_model: Wraps the raw model API call, allowing you to inspect or mutate model input parameters and the raw generated output.
  • wrap_tool: Wraps individual tool executions. You can inspect or modify inputs/outputs of tool calls, or raise an Interrupt to pause execution (e.g., waiting for user approval).

Pre-built, Production-Ready Middleware (#5253)

We also released an official genkit-plugin-middleware package so you don't have to write common resilience patterns from scratch:

  • Smart Retries: Handle transient API failures with exponential backoff and randomized jitter (Retry).
  • Model Fallbacks: Automatically swap to backup models if a primary provider fails or hits rate limits (Fallback).
  • Tool Approval: Intercept sensitive tool calls to require user confirmation or automated validation (ToolApproval, supporting snake_case config options from #5479).
  • Filesystem Sandbox: Restrict agent actions to a sandboxed directory with secure file operations like read, write, edit, and list (Filesystem).
  • File System Skills: Bundle and execute groups of tools backed by simple file storage (Skills).

Expose AI Logic as HTTP Endpoints with Django (#5408)

To make it easier to deploy AI workloads, we built genkit-plugin-django to let you expose Genkit flows as standard Django endpoints. You can find a complete example showing how to wire this up in the new django-hello sample folder.

Fixes & Polish

  • Google GenAI Plugin: Added native constrained generation support when executing models with tool calls (#5403).
  • Typing: Added the key field to ToolDefinition to maintain parity with the JS SDK (#5267).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request bumps the version of genkit and its associated plugins from 0.6.0 to 0.7.0 across several pyproject.toml files and the uv.lock file. It also adds Apache 2.0 license files to the django and middleware plugins, introduces PEP 561 marker files (py.typed) for the evaluators and middleware plugins, and fixes minor typos in the docstrings of _tools.py and _middleware.py. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@huangjeff5 huangjeff5 merged commit 9d48cda into main Jun 9, 2026
24 of 25 checks passed
@huangjeff5 huangjeff5 deleted the release-py-0.7.0 branch June 9, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants