Skip to content

feat: add middelwares to the ui - #202

Merged
xavidop merged 6 commits into
mainfrom
xavier/middleware-v2-ui
Jul 4, 2026
Merged

feat: add middelwares to the ui#202
xavidop merged 6 commits into
mainfrom
xavier/middleware-v2-ui

Conversation

@xavidop

@xavidop xavidop commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test improvements
  • CI/CD improvements

Changes Made

Add middleware support to the Dev UI

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Screenshot 2026-05-25 at 16 41 33

Documentation

  • README updated
  • Plugin documentation updated
  • API documentation updated
  • Sample code updated

Reviewer Notes

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

Copy link
Copy Markdown

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 introduces support for registering and resolving generation middleware from the Genkit Dev UI. It adds a new use field to GenerateActionOptions to receive selected middleware names, resolves these names to fresh middleware instances in GenerateAction, and executes them through the wrapGenerate, wrapModel, and wrapTool chains. It also updates the registry to support typed value buckets (e.g., "middleware"), exposes these values via the reflection API endpoints (/api/values), and provides builder methods to pre-register middleware. The reviewer feedback highlights three key issues: a concurrency bug in Genkit.registerMiddlewareForDevUi due to a non-atomic check-then-act pattern, a thread-safety issue in DefaultRegistry.registerValue that can be resolved using putIfAbsent, and a potential deserialization issue in GenerateAction when converting tool inputs, suggesting the use of JsonUtils.convert(...) instead of the local objectMapper.

Comment thread genkit/src/main/java/com/google/genkit/Genkit.java
Comment thread core/src/main/java/com/google/genkit/core/DefaultRegistry.java
Comment thread ai/src/main/java/com/google/genkit/ai/GenerateAction.java Outdated
@xavidop xavidop changed the title feat: add middelwares to the UI feat: add middelwares to the ui Jul 4, 2026
@xavidop
xavidop merged commit b03fde8 into main Jul 4, 2026
12 of 13 checks passed
@xavidop
xavidop deleted the xavier/middleware-v2-ui branch July 4, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant