MCPcopy Index your code
hub / github.com/github/copilot-sdk / set_model

Method set_model

python/copilot/session.py:2837–2887  ·  view source on GitHub ↗

Change the model for this session. The new model takes effect for the next message. Conversation history is preserved. Args: model: Model ID to switch to (e.g., "gpt-4.1", "claude-sonnet-4"). reasoning_effort: Optional reasoning effort level

(
        self,
        model: str,
        *,
        reasoning_effort: str | None = None,
        reasoning_summary: ReasoningSummary | None = None,
        context_tier: ContextTier | None = None,
        model_capabilities: ModelCapabilitiesOverride | None = None,
    )

Source from the content-addressed store, hash-verified

2835 await self._client.request("session.abort", {"sessionId": self.session_id})
2836
2837 async def set_model(
2838 self,
2839 model: str,
2840 *,
2841 reasoning_effort: str | None = None,
2842 reasoning_summary: ReasoningSummary | None = None,
2843 context_tier: ContextTier | None = None,
2844 model_capabilities: ModelCapabilitiesOverride | None = None,
2845 ) -> None:
2846 """
2847 Change the model for this session.
2848
2849 The new model takes effect for the next message. Conversation history
2850 is preserved.
2851
2852 Args:
2853 model: Model ID to switch to (e.g., "gpt-4.1", "claude-sonnet-4").
2854 reasoning_effort: Optional reasoning effort level for the new model
2855 (e.g., "low", "medium", "high", "xhigh").
2856 reasoning_summary: Optional reasoning summary mode for supported
2857 models. Use "none" to suppress summary output regardless of
2858 whether reasoning is enabled.
2859 context_tier: Optional context window tier for supported models.
2860 Omit to use normal model behavior with no explicit tier.
2861 model_capabilities: Override individual model capabilities resolved by the runtime.
2862
2863 Raises:
2864 Exception: If the session has been destroyed or the connection fails.
2865
2866 Example:
2867 >>> await session.set_model("gpt-4.1")
2868 >>> await session.set_model("claude-sonnet-4.6", reasoning_effort="high")
2869 """
2870 rpc_caps = None
2871 if model_capabilities is not None:
2872 rpc_caps = _RpcModelCapabilitiesOverride.from_dict(
2873 _capabilities_to_dict(model_capabilities)
2874 )
2875 await self.rpc.model.switch_to(
2876 ModelSwitchToRequest(
2877 model_id=model,
2878 reasoning_effort=reasoning_effort,
2879 reasoning_summary=(
2880 _RpcReasoningSummary(reasoning_summary)
2881 if reasoning_summary is not None
2882 else None
2883 ),
2884 context_tier=(_RpcContextTier(context_tier) if context_tier is not None else None),
2885 model_capabilities=rpc_caps,
2886 )
2887 )
2888
2889 async def log(
2890 self,

Calls 4

_capabilities_to_dictFunction · 0.85
switch_toMethod · 0.80
from_dictMethod · 0.45