Skip to content

feat(js): add init data support to client and express handler#5247

Draft
pavelgj wants to merge 26 commits intopj/bidi-actionsfrom
pj/init-transport
Draft

feat(js): add init data support to client and express handler#5247
pavelgj wants to merge 26 commits intopj/bidi-actionsfrom
pj/init-transport

Conversation

@pavelgj
Copy link
Copy Markdown
Member

@pavelgj pavelgj commented May 6, 2026

Parent PR: #4288

pavelgj added 24 commits March 11, 2026 21:07
…ectly into `ActionParams` and removing the separate `BidiActionParams` interface.
Add support for an `init` parameter in the action run pipeline to
establish long-running session states. This propagates the parameter
through the reflection server (v1 and v2), API schemas, and includes
tests for both streaming and non-streaming action invocations.
Add `init` parameter to `streamFlow` and `runFlow` client functions
and propagate it through the Express handler to action execution.
This allows passing initialization data (defined via `initSchema`)
from clients to flows and actions. Includes tests and documentation.
@github-actions github-actions Bot added docs Improvements or additions to documentation js labels May 6, 2026
@pavelgj pavelgj changed the title feat: add init data support to client and express handler feat(js): add init data support to client and express handler May 6, 2026
Copy link
Copy Markdown
Contributor

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

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 initialization data (init) across Genkit clients and server-side handlers, including Express, Fetch, and Next.js. The changes allow passing init data through runFlow and streamFlow, which is then validated against the action's initSchema on the server. The PR also includes updated documentation and new test cases for each plugin. Feedback was provided to enhance type safety in the Express handler by using the generic context type C instead of any in the Action definition.

Init extends z.ZodTypeAny = z.ZodTypeAny,
>(
action: Action<I, O, S>,
action: Action<I, O, S, any, Init>,
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.

high

The Action type parameter for context should use the generic C instead of any. This ensures that the action is compatible with the context provided by the contextProvider. Using any here bypasses type checking for context compatibility, which could lead to runtime errors if the action expects a specific context type that the provider does not supply. Stricter type validation is preferred in this repository to ensure consistency and safety.

Suggested change
action: Action<I, O, S, any, Init>,
action: Action<I, O, S, C, Init>,
References
  1. Stricter validation is preferable to maintain consistency and prevent runtime errors.

@pavelgj pavelgj force-pushed the pj/bidi-actions branch from 83f92e6 to 7efcdc0 Compare May 6, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation js

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant