From 6c1a7244262c79e89384400510684faf3f41797f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 09:46:32 +0000 Subject: [PATCH 1/4] Initial plan From a4425b6b81217db81778be71676087431d5819db Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 09:52:05 +0000 Subject: [PATCH 2/4] fix: tolerate unknown hook types in .NET and Go SDKs Agent-Logs-Url: https://github.com/github/copilot-sdk/sessions/0ea3d153-24a4-4136-807f-cb4fd9223da0 Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com> --- dotnet/src/Session.cs | 2 +- go/session.go | 2 +- go/session_test.go | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/dotnet/src/Session.cs b/dotnet/src/Session.cs index 09a53efd3..6d0a78d4c 100644 --- a/dotnet/src/Session.cs +++ b/dotnet/src/Session.cs @@ -967,7 +967,7 @@ internal void RegisterHooks(SessionHooks hooks) JsonSerializer.Deserialize(input.GetRawText(), SessionJsonContext.Default.ErrorOccurredHookInput)!, invocation) : null, - _ => throw new ArgumentException($"Unknown hook type: {hookType}") + _ => null }; } diff --git a/go/session.go b/go/session.go index f7b4a852c..71facb03b 100644 --- a/go/session.go +++ b/go/session.go @@ -451,7 +451,7 @@ func (s *Session) handleHooksInvoke(hookType string, rawInput json.RawMessage) ( } return hooks.OnErrorOccurred(input, invocation) default: - return nil, fmt.Errorf("unknown hook type: %s", hookType) + return nil, nil } } diff --git a/go/session_test.go b/go/session_test.go index 75d5412ad..45c116087 100644 --- a/go/session_test.go +++ b/go/session_test.go @@ -1,6 +1,7 @@ package copilot import ( + "encoding/json" "fmt" "strings" "sync" @@ -530,6 +531,40 @@ func TestSession_ElicitationHandler(t *testing.T) { }) } +func TestSession_HookForwardCompatibility(t *testing.T) { + t.Run("unknown hook type returns nil without error", func(t *testing.T) { + session, cleanup := newTestSession() + defer cleanup() + + session.registerHooks(&SessionHooks{ + OnPostToolUse: func(input PostToolUseHookInput, invocation HookInvocation) (*PostToolUseHookOutput, error) { + return nil, nil + }, + }) + + output, err := session.handleHooksInvoke("postToolUseFailure", json.RawMessage(`{}`)) + if err != nil { + t.Errorf("Expected no error for unknown hook type, got: %v", err) + } + if output != nil { + t.Errorf("Expected nil output for unknown hook type, got: %v", output) + } + }) + + t.Run("unknown hook type with no hooks registered returns nil without error", func(t *testing.T) { + session, cleanup := newTestSession() + defer cleanup() + + output, err := session.handleHooksInvoke("futureHookType", json.RawMessage(`{"someField":"value"}`)) + if err != nil { + t.Errorf("Expected no error for unknown hook type with no hooks, got: %v", err) + } + if output != nil { + t.Errorf("Expected nil output for unknown hook type with no hooks, got: %v", output) + } + }) +} + func TestSession_ElicitationRequestSchema(t *testing.T) { t.Run("elicitation.requested passes full schema to handler", func(t *testing.T) { // Verify the schema extraction logic from handleBroadcastEvent From 5859e508f4bd9c37e78ed101e2c597bd8230904e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 09:55:58 +0000 Subject: [PATCH 3/4] test: improve clarity of unknown hook type tests in Go Agent-Logs-Url: https://github.com/github/copilot-sdk/sessions/0ea3d153-24a4-4136-807f-cb4fd9223da0 Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com> --- go/go.mod | 2 +- go/samples/go.mod | 11 ++++++++++- go/samples/go.sum | 23 +++++++++++++++++++++++ go/session_test.go | 7 ++++++- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/go/go.mod b/go/go.mod index ed06061a0..16114a0ab 100644 --- a/go/go.mod +++ b/go/go.mod @@ -10,6 +10,7 @@ require ( require ( github.com/google/uuid v1.6.0 go.opentelemetry.io/otel v1.35.0 + go.opentelemetry.io/otel/trace v1.35.0 ) require ( @@ -17,5 +18,4 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect - go.opentelemetry.io/otel/trace v1.35.0 // indirect ) diff --git a/go/samples/go.mod b/go/samples/go.mod index 889070f67..ec905229a 100644 --- a/go/samples/go.mod +++ b/go/samples/go.mod @@ -4,6 +4,15 @@ go 1.24 require github.com/github/copilot-sdk/go v0.0.0 -require github.com/google/jsonschema-go v0.4.2 // indirect +require ( + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/jsonschema-go v0.4.2 // indirect + github.com/google/uuid v1.6.0 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel v1.35.0 // indirect + go.opentelemetry.io/otel/metric v1.35.0 // indirect + go.opentelemetry.io/otel/trace v1.35.0 // indirect +) replace github.com/github/copilot-sdk/go => ../ diff --git a/go/samples/go.sum b/go/samples/go.sum index 6e171099c..605b1f5d2 100644 --- a/go/samples/go.sum +++ b/go/samples/go.sum @@ -1,4 +1,27 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8= github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= +go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= +go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= +go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= +go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= +go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go/session_test.go b/go/session_test.go index 45c116087..30b29e7a4 100644 --- a/go/session_test.go +++ b/go/session_test.go @@ -532,16 +532,21 @@ func TestSession_ElicitationHandler(t *testing.T) { } func TestSession_HookForwardCompatibility(t *testing.T) { - t.Run("unknown hook type returns nil without error", func(t *testing.T) { + t.Run("unknown hook type returns nil without error when known hooks are registered", func(t *testing.T) { session, cleanup := newTestSession() defer cleanup() + // Register known hook handlers to simulate a real session configuration. + // The handler itself does nothing; it only exists to confirm that even + // when other hooks are active, an unknown hook type is still ignored. session.registerHooks(&SessionHooks{ OnPostToolUse: func(input PostToolUseHookInput, invocation HookInvocation) (*PostToolUseHookOutput, error) { return nil, nil }, }) + // "postToolUseFailure" is an example of a hook type introduced by a newer + // CLI version that the SDK does not yet know about. output, err := session.handleHooksInvoke("postToolUseFailure", json.RawMessage(`{}`)) if err != nil { t.Errorf("Expected no error for unknown hook type, got: %v", err) From 98a5159744aa6123a602c62307b0b6f4cc150947 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Apr 2026 10:11:23 +0000 Subject: [PATCH 4/4] revert: remove spurious go.mod/go.sum changes unrelated to fix Agent-Logs-Url: https://github.com/github/copilot-sdk/sessions/fd4a2cd1-7805-4214-8268-d71285f1ecc0 Co-authored-by: SteveSandersonMS <1101362+SteveSandersonMS@users.noreply.github.com> --- go/go.mod | 2 +- go/samples/go.mod | 11 +---------- go/samples/go.sum | 23 ----------------------- 3 files changed, 2 insertions(+), 34 deletions(-) diff --git a/go/go.mod b/go/go.mod index 16114a0ab..ed06061a0 100644 --- a/go/go.mod +++ b/go/go.mod @@ -10,7 +10,6 @@ require ( require ( github.com/google/uuid v1.6.0 go.opentelemetry.io/otel v1.35.0 - go.opentelemetry.io/otel/trace v1.35.0 ) require ( @@ -18,4 +17,5 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect + go.opentelemetry.io/otel/trace v1.35.0 // indirect ) diff --git a/go/samples/go.mod b/go/samples/go.mod index ec905229a..889070f67 100644 --- a/go/samples/go.mod +++ b/go/samples/go.mod @@ -4,15 +4,6 @@ go 1.24 require github.com/github/copilot-sdk/go v0.0.0 -require ( - github.com/go-logr/logr v1.4.3 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/google/jsonschema-go v0.4.2 // indirect - github.com/google/uuid v1.6.0 // indirect - go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/otel v1.35.0 // indirect - go.opentelemetry.io/otel/metric v1.35.0 // indirect - go.opentelemetry.io/otel/trace v1.35.0 // indirect -) +require github.com/google/jsonschema-go v0.4.2 // indirect replace github.com/github/copilot-sdk/go => ../ diff --git a/go/samples/go.sum b/go/samples/go.sum index 605b1f5d2..6e171099c 100644 --- a/go/samples/go.sum +++ b/go/samples/go.sum @@ -1,27 +1,4 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= -github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/jsonschema-go v0.4.2 h1:tmrUohrwoLZZS/P3x7ex0WAVknEkBZM46iALbcqoRA8= github.com/google/jsonschema-go v0.4.2/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= -go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= -go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= -go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= -go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= -go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=