Skip to content

feat: middleware V2 - #125

Merged
xavidop merged 56 commits into
mainfrom
xavier/middleware-v2
May 8, 2026
Merged

feat: middleware V2#125
xavidop merged 56 commits into
mainfrom
xavier/middleware-v2

Conversation

@xavidop

@xavidop xavidop commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Re-design middleware to implement a v2 to wrap, generate, models and tools

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

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

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

Documentation

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

@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 the V2 GenerationMiddleware system, which provides granular hooks for the generation pipeline (Generate, Model, and Tool). It includes the core interfaces, parameter objects, and a base implementation, along with comprehensive tests and a new sample project. The Genkit class has been updated to support these hooks during generation, and a new ReflectionServerV2 has been implemented using WebSockets and JSON-RPC 2.0 for improved dev tool integration. Review feedback identified a critical bug in the action cancellation logic where all actions were interrupted regardless of trace ID, a missing implementation for streaming in the reflection server, and a failure to collect tools provided by middleware.

Comment thread genkit/src/main/java/com/google/genkit/ReflectionServerV2.java Outdated
Comment thread genkit/src/main/java/com/google/genkit/Genkit.java Outdated
Comment thread genkit/src/main/java/com/google/genkit/ReflectionServerV2.java
@xavidop
xavidop changed the base branch from main to xavier/reflection-v2-api March 29, 2026 23:17
@xavidop xavidop changed the title Xavier/middleware v2 feat: middleware V2 Mar 29, 2026
Comment thread ai/src/main/java/com/google/genkit/ai/middleware/BaseGenerationMiddleware.java Outdated
@xavidop

xavidop commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator Author

@pavelgj can you re-review?

@pavelgj pavelgj Apr 13, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just want to call one critical usecase to test for:

when restarting an interrupted tool, the middleware should trigger. But not just trigger, it must follow the same lifecycle. Ex, typically what happens inside a generate call:

generate - 1
    model
    tool1
    tool2
    tool3
    generate - 2
        model
        tool4
        generate - 3
            model
            // done

each of these lines can have a hook inside the generate middleware. Let's say we literally add a log statement that produces the above output.

Now, if one of those tools restartable and it interrupts. Let's say tool4... so the output would look something like:

generate - 1
    model
    tool1
    tool2
    tool3
    generate - 2
        model
        tool4 // <--- INTERUPT

so, when we restart the tool, it would continue execution as in the top output... right from the point where it got interrupted.

        generate - 1 // this is extra, but this is the restart generate call, generate call starts with generate
            tool4 // RESTART
            generate - 2
                model
                // done

i'm calling this out, because I had to fix this in JS. The implementation was naive and it looked something like:

        generate - 1
            tool4 // RESTART
            model
            // done

which is wrong.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oooh, good point, let me review that

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this should be fixed, added a sample that covers this:

===========================================================
  Middleware Interrupt Restart Lifecycle Test
===========================================================

>>> Step 1: Initial generate (expecting tool4 to interrupt)
-----------------------------------------------------------
generate - 1
    model
21:44:58.778 [com.google.genkit.samples.MiddlewareInterruptRestartSample.main()] DEBUG c.google.genkit.core.tracing.Tracer - OpenTelemetry tracer initialized with telemetry exporter
21:45:08.941 [com.google.genkit.samples.MiddlewareInterruptRestartSample.main()] DEBUG c.g.g.core.telemetry.TelemetryConfig - Using GlobalOpenTelemetry for meter: genkit
    tool1
    tool2
    tool3
    tool4

>>> tool4 interrupted as expected!

>>> Step 2: Restart tool4 (expecting nested lifecycle)
-----------------------------------------------------------
generate - 1
    tool4
    generate - 2
        model

>>> Restart completed. Final response:
All tasks have been executed:

- Task 1 result: **tool1-result**
- Task 2 result: **tool2-result**
- Task 3 result: **tool3-result**
- Task 4 confirmation result: **tool4-confirmed-result**

===========================================================
  Full Lifecycle Log
===========================================================
generate - 1
    model
    tool1
    tool2
    tool3
    tool4
generate - 1
    tool4
    generate - 2
        model

===========================================================
  Verification
===========================================================
Restart fires wrapTool for tool4: true
Restart has nested generate:      true
Nested generate calls model:      true

@xavidop
xavidop changed the base branch from xavier/reflection-v2-api to main April 13, 2026 19:16
dependabot Bot and others added 20 commits April 13, 2026 21:17
Bumps [com.google.cloud:google-cloud-trace](https://github.com/googleapis/google-cloud-java) from 2.87.0 to 2.88.0.
- [Release notes](https://github.com/googleapis/google-cloud-java/releases)
- [Changelog](https://github.com/googleapis/google-cloud-java/blob/main/java-document-ai/CHANGELOG.md)
- [Commits](https://github.com/googleapis/google-cloud-java/commits)

---
updated-dependencies:
- dependency-name: com.google.cloud:google-cloud-trace
  dependency-version: 2.88.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `aws.sdk.version` from 2.42.13 to 2.42.18.

Updates `software.amazon.awssdk:auth` from 2.42.13 to 2.42.18

Updates `software.amazon.awssdk:http-client-spi` from 2.42.13 to 2.42.18

Updates `software.amazon.awssdk:regions` from 2.42.13 to 2.42.18

---
updated-dependencies:
- dependency-name: software.amazon.awssdk:auth
  dependency-version: 2.42.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
  dependency-version: 2.42.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:regions
  dependency-version: 2.42.18
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `jackson.version` from 2.21.1 to 2.21.2.

Updates `com.fasterxml.jackson.core:jackson-databind` from 2.21.1 to 2.21.2
- [Commits](https://github.com/FasterXML/jackson/commits)

Updates `com.fasterxml.jackson.core:jackson-core` from 2.21.1 to 2.21.2
- [Commits](FasterXML/jackson-core@jackson-core-2.21.1...jackson-core-2.21.2)

Updates `com.fasterxml.jackson.datatype:jackson-datatype-jsr310` from 2.21.1 to 2.21.2

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-databind
  dependency-version: 2.21.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.fasterxml.jackson.core:jackson-core
  dependency-version: 2.21.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.fasterxml.jackson.datatype:jackson-datatype-jsr310
  dependency-version: 2.21.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `spring-boot.version` from 4.0.3 to 4.0.4.

Updates `org.springframework.boot:spring-boot-starter-web` from 4.0.3 to 4.0.4
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v4.0.3...v4.0.4)

Updates `org.springframework.boot:spring-boot-starter-test` from 4.0.3 to 4.0.4
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v4.0.3...v4.0.4)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-web
  dependency-version: 4.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.springframework.boot:spring-boot-starter-test
  dependency-version: 4.0.4
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.genai:google-genai](https://github.com/googleapis/java-genai) from 1.43.0 to 1.44.0.
- [Release notes](https://github.com/googleapis/java-genai/releases)
- [Changelog](https://github.com/googleapis/java-genai/blob/main/CHANGELOG.md)
- [Commits](googleapis/java-genai@v1.43.0...v1.44.0)

---
updated-dependencies:
- dependency-name: com.google.genai:google-genai
  dependency-version: 1.44.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.cloud:google-cloud-logging](https://github.com/googleapis/java-logging) from 3.28.0 to 3.29.0.
- [Release notes](https://github.com/googleapis/java-logging/releases)
- [Changelog](https://github.com/googleapis/java-logging/blob/main/CHANGELOG.md)
- [Commits](https://github.com/googleapis/java-logging/commits)

---
updated-dependencies:
- dependency-name: com.google.cloud:google-cloud-logging
  dependency-version: 3.29.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.cloud:google-cloud-monitoring](https://github.com/googleapis/google-cloud-java) from 3.88.0 to 3.89.0.
- [Release notes](https://github.com/googleapis/google-cloud-java/releases)
- [Changelog](https://github.com/googleapis/google-cloud-java/blob/main/CHANGELOG.md)
- [Commits](https://github.com/googleapis/google-cloud-java/commits)

---
updated-dependencies:
- dependency-name: com.google.cloud:google-cloud-monitoring
  dependency-version: 3.89.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.genai:google-genai](https://github.com/googleapis/java-genai) from 1.44.0 to 1.45.0.
- [Release notes](https://github.com/googleapis/java-genai/releases)
- [Changelog](https://github.com/googleapis/java-genai/blob/main/CHANGELOG.md)
- [Commits](googleapis/java-genai@v1.44.0...v1.45.0)

---
updated-dependencies:
- dependency-name: com.google.genai:google-genai
  dependency-version: 1.45.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.puppycrawl.tools:checkstyle](https://github.com/checkstyle/checkstyle) from 13.3.0 to 13.4.0.
- [Release notes](https://github.com/checkstyle/checkstyle/releases)
- [Commits](checkstyle/checkstyle@checkstyle-13.3.0...checkstyle-13.4.0)

---
updated-dependencies:
- dependency-name: com.puppycrawl.tools:checkstyle
  dependency-version: 13.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `google-cloud-firestore.version` from 3.38.0 to 3.39.0.

Updates `com.google.cloud:google-cloud-firestore` from 3.38.0 to 3.39.0
- [Release notes](https://github.com/googleapis/java-firestore/releases)
- [Changelog](https://github.com/googleapis/java-firestore/blob/main/CHANGELOG.md)
- [Commits](googleapis/java-firestore@v3.38.0...v3.39.0)

Updates `com.google.cloud:google-cloud-firestore-admin` from 3.38.0 to 3.39.0
- [Release notes](https://github.com/googleapis/java-firestore/releases)
- [Changelog](https://github.com/googleapis/java-firestore/blob/main/CHANGELOG.md)
- [Commits](googleapis/java-firestore@v3.38.0...v3.39.0)

---
updated-dependencies:
- dependency-name: com.google.cloud:google-cloud-firestore
  dependency-version: 3.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.google.cloud:google-cloud-firestore-admin
  dependency-version: 3.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `aws.sdk.version` from 2.42.18 to 2.42.23.

Updates `software.amazon.awssdk:auth` from 2.42.18 to 2.42.23

Updates `software.amazon.awssdk:http-client-spi` from 2.42.18 to 2.42.23

Updates `software.amazon.awssdk:regions` from 2.42.18 to 2.42.23

---
updated-dependencies:
- dependency-name: software.amazon.awssdk:auth
  dependency-version: 2.42.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
  dependency-version: 2.42.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:regions
  dependency-version: 2.42.23
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `spring-boot.version` from 4.0.4 to 4.0.5.

Updates `org.springframework.boot:spring-boot-starter-web` from 4.0.4 to 4.0.5
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v4.0.4...v4.0.5)

Updates `org.springframework.boot:spring-boot-starter-test` from 4.0.4 to 4.0.5
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v4.0.4...v4.0.5)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-web
  dependency-version: 4.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: org.springframework.boot:spring-boot-starter-test
  dependency-version: 4.0.5
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [io.modelcontextprotocol.sdk:mcp](https://github.com/modelcontextprotocol/java-sdk) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/modelcontextprotocol/java-sdk/releases)
- [Commits](modelcontextprotocol/java-sdk@v1.1.0...v1.1.1)

---
updated-dependencies:
- dependency-name: io.modelcontextprotocol.sdk:mcp
  dependency-version: 1.1.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
dependabot Bot and others added 17 commits April 13, 2026 21:17
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 4 to 5.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](actions/setup-java@v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps the npm_and_yarn group with 1 update in the /docs directory: [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite).


Updates `vite` from 6.4.1 to 6.4.2
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v6.4.2/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.4.2/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-version: 6.4.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `opentelemetry.version` from 1.60.1 to 1.61.0.

Updates `io.opentelemetry:opentelemetry-api` from 1.60.1 to 1.61.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-java/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-java/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-java@v1.60.1...v1.61.0)

Updates `io.opentelemetry:opentelemetry-sdk` from 1.60.1 to 1.61.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-java/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-java/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-java@v1.60.1...v1.61.0)

Updates `io.opentelemetry:opentelemetry-sdk-trace` from 1.60.1 to 1.61.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-java/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-java/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-java@v1.60.1...v1.61.0)

Updates `io.opentelemetry:opentelemetry-sdk-metrics` from 1.60.1 to 1.61.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-java/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-java/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-java@v1.60.1...v1.61.0)

Updates `io.opentelemetry:opentelemetry-exporter-otlp` from 1.60.1 to 1.61.0
- [Release notes](https://github.com/open-telemetry/opentelemetry-java/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-java/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-java@v1.60.1...v1.61.0)

---
updated-dependencies:
- dependency-name: io.opentelemetry:opentelemetry-api
  dependency-version: 1.61.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: io.opentelemetry:opentelemetry-sdk
  dependency-version: 1.61.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: io.opentelemetry:opentelemetry-sdk-trace
  dependency-version: 1.61.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: io.opentelemetry:opentelemetry-sdk-metrics
  dependency-version: 1.61.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: io.opentelemetry:opentelemetry-exporter-otlp
  dependency-version: 1.61.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.genai:google-genai](https://github.com/googleapis/java-genai) from 1.46.0 to 1.47.0.
- [Release notes](https://github.com/googleapis/java-genai/releases)
- [Changelog](https://github.com/googleapis/java-genai/blob/main/CHANGELOG.md)
- [Commits](googleapis/java-genai@v1.46.0...v1.47.0)

---
updated-dependencies:
- dependency-name: com.google.genai:google-genai
  dependency-version: 1.47.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps `aws.sdk.version` from 2.42.28 to 2.42.33.

Updates `software.amazon.awssdk:auth` from 2.42.28 to 2.42.33

Updates `software.amazon.awssdk:http-client-spi` from 2.42.28 to 2.42.33

Updates `software.amazon.awssdk:regions` from 2.42.28 to 2.42.33

---
updated-dependencies:
- dependency-name: software.amazon.awssdk:auth
  dependency-version: 2.42.33
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:http-client-spi
  dependency-version: 2.42.33
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: software.amazon.awssdk:regions
  dependency-version: 2.42.33
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.cloud:google-cloud-logging](https://github.com/googleapis/java-logging) from 3.29.0 to 3.31.0.
- [Release notes](https://github.com/googleapis/java-logging/releases)
- [Changelog](https://github.com/googleapis/java-logging/blob/main/CHANGELOG.md)
- [Commits](https://github.com/googleapis/java-logging/commits)

---
updated-dependencies:
- dependency-name: com.google.cloud:google-cloud-logging
  dependency-version: 3.31.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…k-api

Bumps [com.google.cloud.functions:functions-framework-api](https://github.com/GoogleCloudPlatform/functions-framework-java) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/GoogleCloudPlatform/functions-framework-java/releases)
- [Commits](GoogleCloudPlatform/functions-framework-java@java-function-invoker-v2.0.0...java-function-invoker-v2.0.1)

---
updated-dependencies:
- dependency-name: com.google.cloud.functions:functions-framework-api
  dependency-version: 2.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…-plugin

Bumps [com.google.cloud.functions:function-maven-plugin](https://github.com/GoogleCloudPlatform/functions-framework-java) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/GoogleCloudPlatform/functions-framework-java/releases)
- [Commits](GoogleCloudPlatform/functions-framework-java@function-maven-plugin-v1.0.0...function-maven-plugin-v1.0.1)

---
updated-dependencies:
- dependency-name: com.google.cloud.functions:function-maven-plugin
  dependency-version: 1.0.1
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.cloud:google-cloud-trace](https://github.com/googleapis/google-cloud-java) from 2.88.0 to 2.90.0.
- [Release notes](https://github.com/googleapis/google-cloud-java/releases)
- [Changelog](https://github.com/googleapis/google-cloud-java/blob/main/java-document-ai/CHANGELOG.md)
- [Commits](https://github.com/googleapis/google-cloud-java/commits)

---
updated-dependencies:
- dependency-name: com.google.cloud:google-cloud-trace
  dependency-version: 2.90.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [com.google.cloud:google-cloud-monitoring](https://github.com/googleapis/google-cloud-java) from 3.89.0 to 3.91.0.
- [Release notes](https://github.com/googleapis/google-cloud-java/releases)
- [Changelog](https://github.com/googleapis/google-cloud-java/blob/main/CHANGELOG.md)
- [Commits](https://github.com/googleapis/google-cloud-java/commits)

---
updated-dependencies:
- dependency-name: com.google.cloud:google-cloud-monitoring
  dependency-version: 3.91.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@xavidop
xavidop requested a review from pavelgj April 13, 2026 19:46
Comment thread ai/src/main/java/com/google/genkit/ai/middleware/GenerateParams.java Outdated
pavelgj and others added 5 commits May 7, 2026 16:48
…el classes

Move GenerateActionOptions and OutputConfig from inner classes of
GenerateAction into standalone files. Update GenerateParams to hold
GenerateActionOptions instead of ModelRequest, better reflecting
the generation pipeline's data flow. Update middleware interfaces
and tests accordingly.
…acking

Add `messageIndex` field to `GenerateParams` to track the position in the
conversation that the next model response will occupy. This mirrors the
JS SDK's `messageIndex` and supports streaming chunk attribution and
middleware that needs to track conversation position.

- Add 3-arg constructor and `withMessageIndex()` to `GenerateParams`
- Default `messageIndex` to message count when using 2-arg constructor
- Update `withRequest()` to preserve `messageIndex`
- Increment `messageIndex` during tool-loop iterations in `Genkit`
- Add corresponding unit tests
a couple of suggestions for the middleware PR
Add `onChunk` callback to `GenerateParams` and `withStreamCallback` to
`ModelParams`, enabling middleware to observe, transform, or replace
streaming chunks. This mirrors the JS SDK's `onChunk` middleware hook.

- Thread `onChunk` through `GenerateParams` and into `ModelParams`
- Add `withStreamCallback` to `ModelParams` for middleware wrapping
- Wire streaming callback through `GenerateAction` tool loop
- Add `StreamingMiddlewareTest` covering intercept, transform, and
  multi-middleware streaming scenarios
feat: add streaming chunk callback support to generation middleware
@xavidop
xavidop merged commit d5a210b into main May 8, 2026
7 of 8 checks passed
@xavidop
xavidop deleted the xavier/middleware-v2 branch May 18, 2026 16:45
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.

2 participants