Conversation
Summary of ChangesHello @pavelgj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a powerful new middleware system for Genkit's Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive middleware system for the generate function, which is a great feature for adding cross-cutting concerns like logging, caching, and telemetry. The implementation is well-structured, with clear separation of concerns and good test coverage. I've left a few comments on minor improvements and a potential design smell in the plugin interface. Overall, this is a solid contribution.
…te the test to verify multi-turn execution.
…rity audit - Add 7 new gaps (G38-G44) for Middleware V2, Bidi Action/Flow/Model, Agent primitive, Plugin V2, and Reflection API V2 - Mark middleware gaps G1-G3, G12-G16 as PAUSED (blocked on upstream JS #4515 and Go #4422 Middleware V2 RFCs) - Mark G19 (Model API V2) as SUPERSEDED by G38 + G41 - Add deep-dive sections §8l-8p covering all 5 active RFC designs - Update dependency graph: critical path now G38→G2→G1→G3 (4 levels) - Restructure phased roadmap: Phase 1 (unblocked), Phase 2-3 (paused), Phase 4 (bidi/agent, blocked), Phase 5 (integration), Phase 6 (deferred) - Update §5g cross-SDK gaps table with new primitives - Update §9b status tracker and §9c dependency matrix - Update summary metrics: 36 total gaps, 8 paused, 6 upstream-blocked Co-authored-by: Cursor <cursoragent@cursor.com>
…interactions including generate, stream, and embed.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a powerful middleware system for the generate function, allowing interception of different stages of the generation process (generate, model, tool). This is a significant feature that enables cross-cutting concerns like logging, caching, and telemetry. The implementation is well-structured, with a new generateMiddleware helper, clear definitions for middleware hooks, and support for both new object-based middleware and backward compatibility with old function-based middleware.
The PR also includes a significant and beneficial refactoring, extracting core AI functionalities into a new GenerateAPI base class, which the main Genkit class now extends. This improves code organization and separation of concerns.
The changes are accompanied by comprehensive tests covering various middleware scenarios and documentation to guide users on the new feature.
I have one minor suggestion to improve an error message in the reflection API to make it more accurate. Overall, this is an excellent contribution.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| /** | ||
| * `GenerateAPI` encapsulates model generate APIs. | ||
| */ | ||
| export class GenerateAPI { |
There was a problem hiding this comment.
What use cases were you thinking of?
There was a problem hiding this comment.
Some use-cases:
- Automatic Context compression middleware (requires access to an llm)
- LLM classifier based model routing (simple tasks use small model, complex models use large model)
- agentic RAG use-case require embedders
| ): Promise<{ | ||
| response?: ToolResponsePart; | ||
| interrupt?: ToolRequestPart; | ||
| preamble?: GenerateActionOptions; |
There was a problem hiding this comment.
This is just for backwards compat, right?
Updates the generation loop and middleware logic to safely handle cases where tool execution yields no result. - Updates `generateActionTurn` to verify `toolMessage` existence before streaming chunks or adding to the message history, preventing runtime errors on undefined values. - Updates middleware types and `resolveToolRequest` to allow `void` return values. - Ensures `resolveToolRequests` returns an empty object if no response parts or transfer preamble are generated, rather than constructing a malformed tool message.
- Simplify `GenerateMiddlewareDef` to return `ToolResponsePart | void` directly, removing the complex wrapper object that included `interrupt` and `preamble`. - Move `isPromptAction` check in `resolveToolRequest` to execute before the middleware chain, ensuring prompt actions are handled immediately without passing through tool middleware. - Update `executeTool` implementation and return types to align with the simplified middleware signature.
… and merge order Comprehensive update reflecting current state of all merged and open PRs: Merged PRs reflected: - #4511 (G5+G6: span_id + X-Genkit-Span-Id) → marked Done - #4507+#4508 (G11: CHANGELOG.md) → marked Done - #4509 (plugin test coverage uplift) → marked Done - #4505 (PARITY_AUDIT.md baseline) → marked Done - #4488 (sample naming, py.typed, check_consistency) → marked Done Open PRs tracked: - #4516 (G1+G2: model middleware storage) - #4514 (Transfer-Encoding fix) - #4513 (G18: multipart tools) - #4512 (G20-G22: constructor parity) - #4510 (G3+G12-G16: middleware functions) - #4504 (Checks plugin) - #4495, #4494, #4401 (bug fixes + reflection v2) New content: - Middleware Taxonomy section with 4-layer diagram - Decision guide for which middleware layer to use - G38 gap (auto-wiring via get_model_middleware) - PR merge order graph with file conflict matrix - Updated summary metrics and phase tables fix: address review comments — fix G1/G2 status consistency, middleware level count, #4514 merged docs(py): update PARITY_AUDIT.md — mark #4494 and #4514 merged, add #4518 Cohere Update PR status tracking: - #4494 (RedactedSpan fix): marked merged - #4514 (Transfer-Encoding fix): marked merged - #4518 (Cohere provider plugin): added as open PR - Updated dependency chain, summary metrics, and open PR counts docs(py): update PARITY_AUDIT.md — add #4519 (Core fix) docs(py): update PARITY_AUDIT.md with latest merged PR status Rationale: Several PRs have merged since the last update. This syncs the document with the current state of all PRs. Changes: - Mark #4495, #4518, #4520 as merged in all tables - Move #4495, #4518 from INDEPENDENT to MERGED in dependency chain - Add #4520 (converter extraction) to merged list - Update summary metrics: 6 open PRs (down from 8) - Simplify Layer 3 deps since #4495 is now merged docs(py): add issue tracker analysis, dependency graph, model conformance roadmap, and sample flow test plan Rationale: Comprehensive update to PARITY_AUDIT.md with 5 new sections (§12–§16) covering: - Cross-SDK issue tracker analysis verified against Python source code - Dependency-aware reverse topological sort roadmap for prioritized fixes - Model conformance testing roadmap with provider parity matrix - Sample flow test plan with optimal execution order for error detection Changes: - §12: Fixability assessment of 9 'likely' issues with code-level verdicts - §13: Dependency graph (W1–W14), file conflict matrix, PR manifest with regression test specifications, sprint-based execution plan - §14: Model conformance roadmap (Phases 0–4), plugin parity matrix, conformance PR mapping, JS-only plugin gaps - §15: Combined roadmap unifying parity gaps, issue fixes, and conformance - §16: Sample flow test plan with 5-phase error detection priority pyramid, 36 samples ordered by feature coverage, quick-start commands, and env var reference table docs(py): add active RFC redesigns (Middleware V2, Bidi, Agent) to parity audit - Add 7 new gaps (G38-G44) for Middleware V2, Bidi Action/Flow/Model, Agent primitive, Plugin V2, and Reflection API V2 - Mark middleware gaps G1-G3, G12-G16 as PAUSED (blocked on upstream JS #4515 and Go #4422 Middleware V2 RFCs) - Mark G19 (Model API V2) as SUPERSEDED by G38 + G41 - Add deep-dive sections §8l-8p covering all 5 active RFC designs - Update dependency graph: critical path now G38→G2→G1→G3 (4 levels) - Restructure phased roadmap: Phase 1 (unblocked), Phase 2-3 (paused), Phase 4 (bidi/agent, blocked), Phase 5 (integration), Phase 6 (deferred) - Update §5g cross-SDK gaps table with new primitives - Update §9b status tracker and §9c dependency matrix - Update summary metrics: 36 total gaps, 8 paused, 6 upstream-blocked docs(py): update PARITY_AUDIT.md PR status to 2026-02-11 Comprehensive status update reflecting 23 PRs merged since last update (2026-02-09), 3 PRs closed/superseded, and 11 currently open PRs including releasekit tooling, dotprompt fixes, and CI workflow migration. Key changes: - §14f: Checks plugin marked as merged (#4504) - §15b: Split into Recently Merged / Closed / Currently Open - §15c: Updated metrics (31 merged, 11 open, 3 closed) - Added releasekit PRs (14 merged, 3 open) as new workstream
Checklist (if applicable):