Skip to content

feat(go): implement reflection API v2 over WebSocket#5150

Open
apascal07 wants to merge 13 commits intomainfrom
ap/go-reflection-v2
Open

feat(go): implement reflection API v2 over WebSocket#5150
apascal07 wants to merge 13 commits intomainfrom
ap/go-reflection-v2

Conversation

@apascal07
Copy link
Copy Markdown
Collaborator

@apascal07 apascal07 commented Apr 17, 2026

Implements the V2 Reflection API in Genkit Go, matching the JS implementation in js/core/src/reflection-v2.ts. Where V1 is a polling HTTP server running inside the runtime, V2 is a WebSocket client: the CLI manager runs the server and runtimes connect to it and handle JSON-RPC 2.0 requests.

Activated when GENKIT_REFLECTION_V2_SERVER is set to the manager's WebSocket URL; otherwise genkit.Init falls back to V1.

Protocol methods implemented

Method Direction Type Notes
register Runtime → Manager Notification Sent on connect with runtime ID, pid, genkit version, protocol version.
configure Manager → Runtime Notification Sets the telemetry server URL.
listActions Manager → Runtime Request Returns all registered + resolvable actions wrapped in an actions map.
listValues Manager → Runtime Request Returns registered values (note: type filtering is parsed for compatibility but not yet supported by the Go registry).
runAction Manager → Runtime Request Executes an action. Emits runActionState for early trace-ID delivery, and streamChunk notifications when stream: true. Errors are mapped to a JS-compatible Status shape with {code, message, details: {traceId, stack}}.
cancelAction Manager → Runtime Request Cancels an in-flight action by trace ID.
sendInputStreamChunk / endInputStream Manager → Runtime Notification No-op with debug log — bidirectional input streaming is not yet implemented on either side.

@github-actions github-actions bot added docs Improvements or additions to documentation js go tooling python Python config labels Apr 17, 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 the Genkit Reflection Protocol V2, transitioning from an HTTP polling model to a bidirectional WebSocket-based communication system between the Genkit CLI and runtimes. The changes include a new protocol specification, a refactored abstract BaseRuntimeManager architecture in the CLI tools, and new client implementations in both Go and JavaScript. Additionally, the tools server has been updated to support bidirectional streaming and input streaming for bidirectional actions. I have no feedback to provide.

# Conflicts:
#	docs/reflection-v2-protocol.md
#	genkit-tools/cli/src/commands/start.ts
#	genkit-tools/cli/src/utils/manager-utils.ts
#	genkit-tools/common/src/manager/manager-v2.ts
#	genkit-tools/common/src/types/reflection.ts
#	genkit-tools/common/tests/manager-v2_test.ts
#	genkit-tools/genkit-schema.json
#	go/ai/gen.go
#	go/internal/cmd/jsonschemagen/jsonschemagen.go
#	js/core/src/reflection-types.ts
#	js/core/src/reflection-v2.ts
#	js/core/tests/reflection-v2_test.ts
#	js/pnpm-lock.yaml
#	py/packages/genkit/src/genkit/_core/_typing.py
@apascal07 apascal07 requested a review from pavelgj April 17, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config docs Improvements or additions to documentation go js python Python tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants