fix: Go codegen enum prefixes and type name reconciliation#883
fix: Go codegen enum prefixes and type name reconciliation#883MackinnonBuck wants to merge 11 commits intoupdate-copilot-1.0.7from
Conversation
…names Rename all references to copilot session event type and rpc constants to use the new prefixed naming convention matching the generated code: - copilot.SessionCompactionStart -> copilot.SessionEventTypeSessionCompactionStart - copilot.ExternalToolRequested -> copilot.SessionEventTypeExternalToolRequested - copilot.PermissionRequested -> copilot.SessionEventTypePermissionRequested - copilot.ToolExecutionStart -> copilot.SessionEventTypeToolExecutionStart - copilot.AssistantReasoning -> copilot.SessionEventTypeAssistantReasoning - copilot.Abort -> copilot.SessionEventTypeAbort - rpc.Interactive -> rpc.ModeInteractive - rpc.Plan -> rpc.ModePlan - rpc.Warning -> rpc.LevelWarning - rpc.Error -> rpc.LevelError - rpc.Info -> rpc.LevelInfo (and all other constants listed in the rename) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add 'mcp' to goInitialisms so toPascalCase produces SessionMCP* matching quicktype - Post-process enum constants to use canonical Go TypeNameValue convention (replaces quicktype's Purple/Fluffy/Tentacled prefixes and unprefixed constants) - Reconcile type names: extract actual quicktype-generated struct names and use them in RPC wrapper code instead of recomputing via toPascalCase - Extract field name mappings from quicktype output to handle keyword-avoidance renames - Update all handwritten Go references to use new prefixed constant names Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes Go SDK build/regeneration issues introduced by updated schemas by reconciling quicktype-generated names with wrapper code and normalizing enum constant naming.
Changes:
- Post-processes quicktype Go output to normalize enum constant prefixes and reconcile type/field names used by RPC wrapper generation.
- Updates Go SDK code, samples, and E2E tests to use the new enum constant names.
- Regenerates Go RPC/session-events generated files reflecting the new naming rules (including MCP-related types).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/codegen/go.ts | Adds enum-constant post-processing and extracts quicktype-generated type/field names for wrapper emission. |
| go/session.go | Updates event-type and RPC enum constant references to the new prefixed names; updates LogOptions docs/examples. |
| go/samples/chat.go | Updates sample event-type constants to the new prefixed names. |
| go/rpc/generated_rpc.go | Regenerated RPC types/wrappers with normalized enum constants and MCP naming (e.g., MCPRpcApi, SessionRpc.MCP). |
| go/internal/e2e/testharness/helper.go | Updates error event constant to new prefixed name. |
| go/internal/e2e/session_test.go | Updates session event-type and log-level constants to new prefixed names. |
| go/internal/e2e/rpc_test.go | Updates Mode enum constants to new Mode* names. |
| go/internal/e2e/permissions_test.go | Updates tool execution event constant to new prefixed name. |
| go/internal/e2e/multi_client_test.go | Updates external tool/permission event constants to new prefixed names. |
| go/internal/e2e/compaction_test.go | Updates compaction event constants to new prefixed names. |
| go/generated_session_events.go | Regenerated session-events types with normalized enum constants (including SessionEventType* values). |
You can also share your feedback on Copilot code review. Take the survey.
SDK Consistency Review ✅I've reviewed PR #883 for cross-SDK consistency. This PR fixes Go-specific codegen bugs without creating inconsistencies across the SDK implementations. SummaryScope: Go codegen only (no changes needed in other SDKs) Changes:
Cross-SDK Consistency CheckEach SDK follows its own language's enum conventions idiomatically:
The field name fix ( Conclusion✅ No cross-SDK consistency issues found. The changes are appropriate Go-specific fixes that align Go codegen with both Go conventions and cross-SDK API semantics. No similar changes are needed in other language implementations.
|
The generated enum constant was renamed from copilot.File to copilot.AttachmentTypeFile to follow Go's TypeNameValue convention. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…onyms The Python codegen used toPascalCase() to compute type names like SessionMcpListResult, but quicktype generates SessionMCPListResult (uppercase MCP). This caused runtime NameError in Python scenarios. Apply the same approach as go.ts: after quicktype runs, parse the generated output to extract actual class names and build a case-insensitive lookup map. Use resolveType() in emitMethod() and emitRpcWrapper() instead of recomputing names via toPascalCase(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- TestAgentSelectionRpc: CLI now returns built-in agents, so instead of asserting zero agents, verify no custom agents appear when none configured - TestMultiClient: increase broadcast event timeout from 10s to 30s Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The generated Rpc.LogAsync method added a 'url' parameter between 'ephemeral' and 'cancellationToken', causing a type mismatch when Session.LogAsync passed cancellationToken as the 4th positional arg. Added the 'url' parameter to Session.LogAsync to match the generated Rpc method signature and pass it through correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…, add pr/ado - valuePascal now uses goInitialisms so 'url' -> 'URL', 'mcp' -> 'MCP', etc. - Phase 2 regex uses [\s\S]*? to match multi-line func bodies - Added 'pr' and 'ado' to goInitialisms Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cross-SDK Consistency ReviewI've reviewed this PR for consistency across the Node.js, Python, Go, and .NET SDKs. Here are my findings: ✅ Go Enum Naming Convention ChangeThe primary change in this PR—standardizing Go enum constants to use the
The Go change brings it in line with Go best practices and avoids name collisions—this is good.
|
The CLI now returns built-in/default agents even when no custom agents are configured. Update the assertion to verify no custom test agent names appear in the list, rather than asserting the list is empty. Matches the pattern used in the Go E2E test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CLI 1.0.7 no longer delivers broadcast external_tool events to secondary clients. Skip the 'both clients see tool request and completion events' test in all three languages with a clear note. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes Go (and related Python wrapper) codegen regressions introduced by the @github/copilot 1.0.7 update by reconciling generated names with quicktype output and normalizing Go enum constant naming.
Changes:
- Go codegen now post-processes quicktype output to enforce
TypeNameValueenum constant naming and to reconcile wrapper type/field names with actual generated identifiers. - Python codegen now resolves RPC params/result type names from quicktype-emitted classes to avoid casing/initialism mismatches (e.g.,
MCP). - E2E tests are adjusted for CLI 1.0.7 behavior changes (multi-client external_tool broadcasts), including skips and updated assertions.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/codegen/python.ts | Resolve wrapper type names against quicktype-emitted Python classes to avoid casing mismatches. |
| scripts/codegen/go.ts | Add enum post-processing + resolveType/field-name extraction to align Go wrappers with quicktype output. |
| python/e2e/test_multi_client.py | Skips multi-client external_tool broadcast test due to CLI behavior change. |
| python/e2e/test_agent_and_compact_rpc.py | Makes agent-list assertion resilient to built-in/default agents. |
| python/copilot/generated/rpc.py | Regenerated Python RPC wrapper now references MCP-cased types. |
| go/session.go | Updates Go SDK usage to new prefixed session event + enum constant names. |
| go/samples/chat.go | Updates sample to new prefixed session event constants. |
| go/rpc/generated_rpc.go | Regenerated Go RPC types/wrappers with normalized enum constants and MCP naming. |
| go/internal/e2e/testharness/helper.go | Updates event-type comparisons to new prefixed constants. |
| go/internal/e2e/session_test.go | Updates tests to new prefixed session event + enum constant names. |
| go/internal/e2e/rpc_test.go | Updates tests to new prefixed enum constants (e.g., ModeInteractive). |
| go/internal/e2e/permissions_test.go | Updates tests to new prefixed session event constants. |
| go/internal/e2e/multi_client_test.go | Skips multi-client external_tool broadcast test; updates event constants. |
| go/internal/e2e/compaction_test.go | Updates tests to new prefixed compaction event constants. |
| go/internal/e2e/agent_and_compact_rpc_test.go | Makes agent-list assertion resilient to built-in/default agents; updates naming. |
| go/generated_session_events.go | Regenerated with TypeNameValue enum constants (incl. SessionEventType*). |
| dotnet/test/MultiClientTests.cs | Skips multi-client external_tool broadcast test due to CLI behavior change. |
| dotnet/src/Session.cs | Adds optional url parameter to Session.LogAsync and forwards to RPC. |
| docs/features/image-input.md | Updates Go docs to use renamed attachment type constant. |
You can also share your feedback on Copilot code review. Take the survey.
| Fleet *FleetRpcApi | ||
| Agent *AgentRpcApi | ||
| Skills *SkillsRpcApi | ||
| Mcp *McpRpcApi | ||
| MCP *MCPRpcApi | ||
| Plugins *PluginsRpcApi |
python/e2e/test_multi_client.py
Outdated
| self, mctx: MultiClientContext | ||
| ): | ||
| """Both clients see tool request and completion events.""" | ||
| pytest.skip("CLI 1.0.7 no longer broadcasts external_tool events to secondary clients") |
go/internal/e2e/multi_client_test.go
Outdated
| t.Cleanup(func() { client2.ForceStop() }) | ||
|
|
||
| t.Run("both clients see tool request and completion events", func(t *testing.T) { | ||
| t.Skip("Skipped: CLI 1.0.7 no longer broadcasts external_tool events to secondary clients") |
dotnet/test/MultiClientTests.cs
Outdated
| private CopilotClient Client2 => _client2 ?? throw new InvalidOperationException("Client2 not initialized"); | ||
|
|
||
| [Fact] | ||
| [Fact(Skip = "CLI 1.0.7 no longer broadcasts external_tool events to secondary clients")] |
Remove the t.Skip/pytest.skip/Fact(Skip=...) additions that were disabling the multi-client broadcast tests across Go, Python, and C#. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
resolveType() already handles type name reconciliation from quicktype output, so these initialisms aren't needed and would cause an unnecessary breaking change to the SessionRpc.Mcp field name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ SDK Consistency Review: No Issues FoundThis PR fixes Go-specific codegen bugs and maintains cross-SDK consistency. The changes are Go-specific implementation details that align with Go conventions. Summary of Changes
Cross-SDK Consistency ✅Each SDK follows language-specific idioms for enum/constant representation:
Why This Is ConsistentWhile the syntax differs, the semantic consistency is maintained:
Verification✅ Documentation updated for Go examples Recommendation: Approve. This PR fixes Go-specific issues while maintaining appropriate cross-SDK consistency.
|
|
We should fix https://github.com/github/copilot-agent-runtime/pull/5035 before merging this. |
Summary
Fixes two Go codegen bugs introduced in #878 (Update @github/copilot to 1.0.7).
Bug 1: Build-breaking type name mismatch
RPC wrapper code computed type names via
toPascalCase()(e.g.,SessionMcpListResult) but quicktype generated different names following Go initialism rules (e.g.,SessionMCPListResult). The Go SDK didn't compile.Fix: After quicktype runs, extract actual generated struct names and use a
resolveType()lookup instead of recomputing viatoPascalCase. Also addedmcptogoInitialisms.Bug 2: Nonsense/missing enum prefixes
quicktype used whimsical prefixes for colliding enum constants (
PurpleDisabled,FluffyFailed,TentacledFailed) and left non-colliding constants unprefixed (Running,Connected,Error). The canonical Go convention isTypeNameValue.Fix:
postProcessEnumConstants()renames all unprefixed constants insideconstblocks and their associated marshal/unmarshal functions to followTypeNameValueconvention, while preserving struct field names.Additional fix: Field name reconciliation
quicktype sometimes renames struct fields to avoid Go keyword conflicts. The wrapper code now extracts actual field names from quicktype output instead of recomputing them.
Breaking change
All Go enum constants now use
TypeNameValueprefixes. Downstream code referencing old names (e.g.,copilot.SessionIdle->copilot.SessionEventTypeSessionIdle,rpc.Interactive->rpc.ModeInteractive) must be updated.Verification
go build ./...passesgo test ./...passes (2 pre-existing E2E failures unrelated to this change)