Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions go/internal/e2e/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ func TestSessionRpc(t *testing.T) {
if err != nil {
t.Fatalf("Failed to create session: %v", err)
}

if err := session.SetModel(t.Context(), "gpt-4.1", copilot.SetModelOptions{ReasoningEffort: "high"}); err != nil {
if err := session.SetModel(t.Context(), "gpt-4.1", &copilot.SetModelOptions{ReasoningEffort: copilot.String("high")}); err != nil {
t.Fatalf("SetModel returned error: %v", err)
}
})
Expand Down
2 changes: 1 addition & 1 deletion go/internal/e2e/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ func TestSetModelWithReasoningEffort(t *testing.T) {
}
})

if err := session.SetModel(t.Context(), "gpt-4.1", copilot.SetModelOptions{ReasoningEffort: "high"}); err != nil {
if err := session.SetModel(t.Context(), "gpt-4.1", &copilot.SetModelOptions{ReasoningEffort: copilot.String("high")}); err != nil {
t.Fatalf("SetModel returned error: %v", err)
}

Expand Down
13 changes: 6 additions & 7 deletions go/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,25 +792,24 @@ func (s *Session) Abort(ctx context.Context) error {
// SetModelOptions configures optional parameters for SetModel.
type SetModelOptions struct {
// ReasoningEffort sets the reasoning effort level for the new model (e.g., "low", "medium", "high", "xhigh").
ReasoningEffort string
ReasoningEffort *string
}

// SetModel changes the model for this session.
// The new model takes effect for the next message. Conversation history is preserved.
//
// Example:
//
// if err := session.SetModel(context.Background(), "gpt-4.1"); err != nil {
// if err := session.SetModel(context.Background(), "gpt-4.1", nil); err != nil {
// log.Printf("Failed to set model: %v", err)
// }
// if err := session.SetModel(context.Background(), "claude-sonnet-4.6", SetModelOptions{ReasoningEffort: "high"}); err != nil {
// if err := session.SetModel(context.Background(), "claude-sonnet-4.6", &SetModelOptions{ReasoningEffort: new("high")}); err != nil {
// log.Printf("Failed to set model: %v", err)
// }
func (s *Session) SetModel(ctx context.Context, model string, opts ...SetModelOptions) error {
func (s *Session) SetModel(ctx context.Context, model string, opts *SetModelOptions) error {
params := &rpc.SessionModelSwitchToParams{ModelID: model}
if len(opts) > 0 && opts[0].ReasoningEffort != "" {
re := opts[0].ReasoningEffort
params.ReasoningEffort = &re
if opts != nil {
params.ReasoningEffort = opts.ReasoningEffort
}
_, err := s.RPC.Model.SwitchTo(ctx, params)
if err != nil {
Expand Down
Loading