Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Go RPC surface and generator to modernize types (any), simplify API names, and reduce allocations in the generated RPC wrappers by sharing a common service struct.
Changes:
- Replace generated
interface{}usages withanyin Go RPC types. - Rename generated RPC API structs to drop the redundant
Rpc/RpcApisuffix (e.g.,ModelRpcApi→ModelApi). - Reduce per-wrapper allocations by sharing a single underlying service struct across API groups; adjust JSON-RPC client to treat
nilparams as{}.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/codegen/go.ts | Updates Go RPC codegen: replaces interface{} → any, renames API types, and emits shared-service wrapper structure. |
| go/rpc/generated_rpc.go | Regenerated Go RPC types/wrappers reflecting any, renamed APIs, and shared-service construction. |
| go/internal/jsonrpc2/jsonrpc2.go | Changes request/notify param encoding so nil params serialize as {} to support no-params calls without allocating empty maps. |
Comments suppressed due to low confidence (1)
go/internal/jsonrpc2/jsonrpc2.go:226
- This change introduces special handling for
params == nil(sending{}), which is important behavior to lock down because it affects the wire protocol for no-params calls. There are already unit tests for this package; please add coverage that asserts Request/Notify serializenilparams as an empty object (and notnull) so future refactors don’t regress this.
var paramsData json.RawMessage
if params == nil {
paramsData = json.RawMessage("{}")
} else {
var err error
paramsData, err = json.Marshal(params)
if err != nil {
return nil, fmt.Errorf("failed to marshal params: %w", err)
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
interface{}->any.Rpcfrom rpc struct names. The package is already namedrpc, there is no need to duplicate the "context" in the struct name. E.g.ModelRpcApi->ModelApi.NewSessionRpcandNewServerRpcnow allocate less.While here, fix
TestMultiClient.