Repository navigation
[1.0.94/v1.0.18]New version python SDK could not work with BYOK #2826
Copy link
Copy link
Closed
Description
Works fine:
"copilot_version": "1.0.92",
"copilot_sdk_version": "v1.0.18"
Timeout after upgrade to:
"copilot_version": "1.0.94",
"copilot_sdk_version": "v1.0.18"
Code:
async with CopilotClient() as client:
async with await client.create_session(
on_permission_request=PermissionHandler.approve_all,
model="abc",
provider={
"type": "openai",
"base_url": "http://host.docker.internal:1234/v1",
# "api_key": os.environ.get("MY_API_KEY", "123"),
},
system_message={
"mode": "replace", "content": "You are a helpful AI assistant."
}
) as session:
def on_event(event):
print(event)
match event.data:
case AssistantMessageData() as data:
print(data.content)
case SessionIdleData():
print('Done')
session.on(on_event)
print("Hello!")
await session.send_and_wait("Hello!")
await session.disconnect()
await client.stop()Log:
SessionEvent(data=SessionStartData(copilot_version='1.0.94', producer='copilot-agent', session_id='ec13e13d-af1c-49bd-a1af-0b4af1ee27ea', start_time=datetime.datetime(2026, 10, 9, 4, 9, 59, 657000, tzinfo=tzutc()), version=1, already_in_use=False, auto_tier=None, auto_tier_managed=None, context=WorkingDirectoryContext(cwd='/app', base_commit=None, branch='xauto_hub/main', git_root='/app', head_commit='7055bb4619217c5488e4b0a03768fdef58614375', host_type=None, pending_git_context=None, repository=None, repository_host=None), context_tier=None, context_tier_managed=None, detached_from_spawning_parent_session_id=None, github_mcp_tool_config=None, provider_id=None, reasoning_effort=None, reasoning_effort_managed=None, reasoning_effort_model=None, reasoning_summary=None, remote_steerable=False, selected_model='abc', session_limits=None, verbosity=None), id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), timestamp=datetime.datetime(2026, 10, 9, 4, 9, 59, 675000, tzinfo=tzutc()), type=<SessionEventType.SESSION_START: 'session.start'>, agent_id=None, ephemeral=None, parent_id=None, raw_type=None)
SessionEvent(data=SessionManagedSettingsResolvedData(bypass_permissions_disabled=False, device_managed=False, fail_closed=False, managed_keys=[], server_managed=False, source=<ManagedSettingsResolvedSource.NONE: 'none'>, client_managed=False, permissions_allow_intersected=None, policy_helper_managed=False, sandbox_enabled_by_undetermined_policy=False, settings=None), id=UUID('08dd458a-573c-417c-8619-762e47f22fbe'), timestamp=datetime.datetime(2026, 10, 9, 4, 9, 59, 676000, tzinfo=tzutc()), type=<SessionEventType.SESSION_MANAGED_SETTINGS_RESOLVED: 'session.managed_settings_resolved'>, agent_id=None, ephemeral=True, parent_id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), raw_type=None)
SessionEvent(data=PendingMessagesModifiedData(), id=UUID('e142416d-5364-480e-93c3-0497451c0927'), timestamp=datetime.datetime(2026, 10, 9, 4, 9, 59, 728000, tzinfo=tzutc()), type=<SessionEventType.PENDING_MESSAGES_MODIFIED: 'pending_messages.modified'>, agent_id=None, ephemeral=True, parent_id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), raw_type=None)
CopilotSession.send_and_wait failed
SessionEvent(data=SessionShutdownData(code_changes=ShutdownCodeChanges(files_modified=[], lines_added=0, lines_removed=0), model_metrics={}, session_start_time=1791518999657, shutdown_type=<ShutdownType.ROUTINE: 'routine'>, total_api_duration=datetime.timedelta(0), _accounting_snapshot=None, agent_metrics=None, conversation_tokens=0, current_model=None, current_tokens=3, error_reason=None, events_file_size_bytes=None, provider_model_metrics=None, system_tokens=0, token_details=None, tool_definitions_tokens=0, total_nano_aiu=0.0, _total_premium_requests=0.0, usage_accounting_watermarks=None), id=UUID('8f7f5d4e-ad43-4045-b814-cc4adad5c3ad'), timestamp=datetime.datetime(2026, 10, 9, 4, 10, 59, 793000, tzinfo=tzutc()), type=<SessionEventType.SESSION_SHUTDOWN: 'session.shutdown'>, agent_id=None, ephemeral=None, parent_id=UUID('60bedb05-0b11-45c1-b997-577117d09a5e'), raw_type=None)
Traceback (most recent call last):
File "/usr/local/lib/python3.13/asyncio/tasks.py", line 507, in wait_for
return await fut
^^^^^^^^^
File "/usr/local/lib/python3.13/asyncio/locks.py", line 213, in wait
await fut
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/copilot/session.py", line 2239, in send_and_wait
await asyncio.wait_for(idle_event.wait(), timeout=timeout)
File "/usr/local/lib/python3.13/asyncio/tasks.py", line 506, in wait_for
async with timeouts.timeout(timeout):
~~~~~~~~~~~~~~~~^^^^^^^^^
File "/usr/local/lib/python3.13/asyncio/timeouts.py", line 116, in __aexit__
raise TimeoutError from exc_val
TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/Agent/debugs/debug_copilot_byok.py", line 52, in <module>
asyncio.run(main())
~~~~~~~~~~~^^^^^^^^
File "/usr/local/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/app/Agent/debugs/debug_copilot_byok.py", line 48, in main
await session.send_and_wait("Hello!")
File "/usr/local/lib/python3.13/site-packages/copilot/session.py", line 2269, in send_and_wait
raise TimeoutError(f"Timeout after {timeout}s waiting for session.idle")
TimeoutError: Timeout after 60.0s waiting for session.idleReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Oct 9, 2026
Thanks for the report. I could not reproduce this because it needs your local OpenAI-compatible server, so this is based on reading the code.
What I checked
python/copilot/client.py(_convert_provider_to_wire_format): yourtype,base_urland model are sent to the runtime correctly.base_urlbecomesbaseUrl, andapi_keyis only sent if you set it.python/copilot/session.py(send_and_wait): theTimeoutErroris the SDK's default 60s wait forsession.idle. The SDK never got an error event, and none appeared in your log. Your log showssession.startwithselected_model='abc', thenpending_messages_modified, then nothing until the shutdown after 60s.What this suggests
The Python SDK's provider handling looks fine. The turn seems to stall inside the Copilot CLI runtime (1.0.94) while it handles the BYOK provider. That could be a runtime change, such as stricter provider or model validation or a different request path. It could also be that the runtime can't reach
(host.docker.internal/redacted) from your container. I can't tell which from the SDK side. I'm labelling thisquestionrather thanbug` for now.Things to try
api_keyexplicitly, even to a dummy value. Newer runtimes may expect one fortype: "openai".wire_model,model_id,max_prompt_tokensandmax_output_tokens, in the provider config.wire_api: "completions"or"responses"to see whether the behaviour changes.log_level="debug".If the endpoint is reachable and a request is sent but the session still never goes idle, or the request is never sent, please reply with the debug logs and I'll reclassify this as a bug against the runtime.
zeerd commentedon Oct 9, 2026
I said, old version works fine which means the local-LLM could work with those codes.
zeerd commentedon Oct 14, 2026
Back to stable: