github/copilot-sdk · error · ValueError
github_token and github_token_provider are mutually…
Error message
github_token and github_token_provider are mutually exclusive
What it means
Input validation in CopilotClient.create_session: the caller supplied both a static github_token and a github_token_provider callback. Only one GitHub credential source may be configured per session; supplying both is ambiguous, so the request is rejected before the session.create RPC is sent.
Solutions
- Pass only github_token for a static token
- Pass only github_token_provider when the token must be resolved or refreshed dynamically
- Remove the static token and wrap it in a provider callable if you need default-plus-override behavior
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at python/copilot/client.py:2533 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/0d9e45698d57196c.
Report an issue: GitHub.
Appendix: source
Thrown at python/copilot/client.py:2533
Raises:
ValueError: If ``on_permission_request`` is provided but not callable.
Example:
>>> session = await client.create_session(
... on_permission_request=PermissionHandler.approve_all,
... )
>>>
>>> # Session with model and streaming
>>> session = await client.create_session(
... on_permission_request=PermissionHandler.approve_all,
... model="gpt-4",
... streaming=True,
... )
"""
if on_permission_request is not None and not callable(on_permission_request):
raise ValueError("on_permission_request must be callable when provided.")
if github_token is not None and github_token_provider is not None:
raise ValueError("github_token and github_token_provider are mutually exclusive")
if ask_user_variant not in (None, "legacy", "elicitation"):
raise ValueError('ask_user_variant must be "legacy" or "elicitation"')
if not self._client:
await self.start()
tool_defs = []
if tools:
for tool in tools:
definition: dict[str, Any] = {
"name": tool.name,
"description": tool.description,
}
if tool.parameters:
definition["parameters"] = tool.parameters
if tool.overrides_built_in_tool:
definition["overridesBuiltInTool"] = True
if tool.skip_permission:
definition["skipPermission"] = TrueView on GitHub (pinned to cd8cf15dc3)