Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Users currently cannot change a session's model without creating a new session, which loses conversation context and session state.

Changes

  • types.py: Added model field to ResumeSessionConfig TypedDict
  • client.py: resume_session() now accepts and passes model parameter to CLI via session.resume RPC
  • test_session.py: Added test verifying model parameter acceptance

Usage

# Create session with initial model
session = await client.create_session({"model": "gpt-5"})
await session.send_and_wait({"prompt": "What is 2+2?"})

# Switch model while preserving context
session = await client.resume_session(session.session_id, {
    "model": "claude-sonnet-4.5"
})

Notes

  • Requires CLI support for model parameter in session.resume RPC endpoint
  • Other language SDKs (Node.js, Go, .NET) currently don't expose this - consider adding for consistency
  • Backward compatible: model parameter is optional
Original prompt

This section details on the original issue you should resolve

<issue_title>Can't change model of a session without creating new one.</issue_title>
<issue_description>On py module. There doesn't seem to be a way to change model of an existing session without creating a new one using CopilotClient.new_session, and if I do that I lose all context and .copilot/session_state disk files of the old session.

</issue_description>

<agent_instructions>Review the issue and make sure there isn't a bug. It should work.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 2, 2026 18:01
…ut losing context

Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
Co-authored-by: patniko <26906478+patniko@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with changing session model without creating new Add model parameter to resume_session for changing models without losing context Feb 2, 2026
Copilot AI requested a review from patniko February 2, 2026 18:11
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

Cross-SDK Consistency Review

Thank you for adding the ability to change a session's model without losing context in the Python SDK! This is a valuable feature that addresses issue #311.

However, I've identified a cross-SDK consistency issue: this feature is currently only implemented in the Python SDK, while the Node.js, Go, and .NET SDKs do not support changing the model when resuming a session.

Current State

Python SDK (this PR):

  • ResumeSessionConfig now includes model field
  • resume_session() passes model to CLI via session.resume RPC
  • ✅ Test coverage added

Node.js SDK:

  • ResumeSessionConfig does NOT include model (see types.ts:731-740)
  • resumeSession() does NOT pass model parameter (see client.ts:541-560)

Go SDK:

  • ResumeSessionConfig does NOT have Model field (see types.go:401-410)
  • ResumeSessionWithOptions() does NOT pass model parameter (see client.go:676-720)

.NET SDK:

  • ResumeSessionConfig does NOT have Model property (see Types.cs:771-790)
  • ResumeSessionAsync() does NOT pass model parameter (see Client.cs:435-449)

Recommendation

To maintain feature parity across all SDK implementations, I suggest:

  1. Add model to ResumeSessionConfig in each SDK:

    • Node.js: Add "model" to the Pick type in ResumeSessionConfig (types.ts)
    • Go: Add Model string field to ResumeSessionConfig struct (types.go)
    • .NET: Add public string? Model { get; set; } property to ResumeSessionConfig class (Types.cs)
  2. Update each SDK's resume method to pass the model parameter:

    • Node.js: Add model: config.model to the request payload in resumeSession() (client.ts)
    • Go: Add model parameter handling in ResumeSessionWithOptions() (client.go)
    • .NET: Add model parameter to ResumeSessionRequest record and pass it in ResumeSessionAsync() (Client.cs)
  3. Add test coverage in each SDK similar to the test in python/e2e/test_session.py

Note: All SDKs already have model in their SessionConfig for creating sessions, so this would simply extend that capability to resuming sessions as well, maintaining API consistency.

Would you like me to create follow-up issues for adding this feature to the other SDKs, or would you prefer to include these changes in this PR?

AI generated by SDK Consistency Review Agent

@bigguy345
Copy link

bigguy345 commented Feb 2, 2026

@copilot Instead of making the model only changeable on create/resume session, I think it would be more practical if we can directly set the model through the session object.

OR make the model settable per prompt send operation like openai or other SDKs.

This way if we want to change the ongoing session's model, we can directly do that without restarting it again. What do y'all think?

But as I have no knowledge of how the backend is setup, if this for some reason is not feasible and the session must be restarted to set the model properly, that's absolutely fine too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't change model of a session without creating new one.

3 participants